All elements help.

  • Millions
    30th Dec 2013 Member 0 Permalink

    How would I make a element effect EVERY element in the game? Like for this gas i'm making i want it to change anything it touches to vine. how would I do this?

  • benthecrazy
    30th Dec 2013 Member 0 Permalink

    I don't know anything about the coding of TPT but if I were you I'd take a look at the code of CONV.

  • Sylvi
    30th Dec 2013 Moderator 0 Permalink
    Yeah, take a look at CONV or CAUS gas.

    If you can't find out how, just go onto the IRC and ask the developers there.
  • boxmein
    30th Dec 2013 Former Staff 0 Permalink
    @Millions (View Post)
    Just don't run element specific checks.
    When you usually would make your loops and then element type checks, it's as trivial as removing the type checks.
    See below for a reference.

    for (rx=-2; rx<3; rx++)<br/> for (ry=-2; ry<3; ry++)<br/> if (x+rx>=0 && y+ry>0 && x+rx {
    r = pmap[y+ry][x+rx];
    if (!r)
    continue;
    // if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500))
    // {

    sim->create_part((r&0xFF), parts[r>>8].x, parts[r>>8].y, PT_VINE);
    // ...

    Edited once by boxmein. Last: 30th Dec 2013
  • nucular
    31st Dec 2013 Member 4 Permalink
    Anyone even noticed that he posted inside Lua Scripting?

    Just iterate over all neighbours inside the update function and change them into VINE. For example like this:


    -- Create the element and copy properties from DUST
    local VNER = elements.allocate("NUCULAR", "VNER")
    elements.element(VNER, elements.element(elements.DEFAULT_PT_DUST))
    elements.property(VNER, "Name", "VNER")
    elements.property(VNER, "Description", "Viner, changes stuff into VINE.")

    -- Create an update function for VNER
    local function VNER_update(index, partx, party, space, nt)
    -- Get the particle neighbours and iterate over them
    for i in ipairs(simulation.partNeighbours(partx, party, 2)) do
    -- Don't change other VNER particles
    if simulation.partProperty(i, "type") != VNER then
    simulation.partChangeType(i, elements.DEFAULT_PT_VINE)
    end
    end
    end

    -- Bind our update function to VNER so it gets called every
    -- frame for every particle of VNER
    tpt.element_func(VNER_update, VNER)

    Keep in mind that this code was written from my phone and is totally and completly untested but should give you an idea of how to do it.

    EDIT: formatting .-.
    Edited 3 times by nucular. Last: 31st Dec 2013
  • Millions
    31st Dec 2013 Member 1 Permalink

    Thanks nucular.