Script help

  • cat
    9th Apr 2016 Member 0 Permalink

    how would I make plsm create thrm whenever it touches another element?

  • jacob1
    9th Apr 2016 Developer 2 Permalink
    Here you go! the PLSM reaction multiplies though O_o

    local function reaction(i, x, y, s, nt)
    for r in sim.neighbors(x,y,1,1) do
    local rtype = sim.partProperty(r, sim.FIELD_TYPE)
    if rtype ~= tpt.el.plsm.id and rtype ~= tpt.el.fire.id and rtype ~= tpt.el.smke.id and rtype ~= tpt.el.lava.id then
    sim.partCreate(-1, x+math.random(-1, 1), y+math.random(-1, 1), tpt.el.thrm.id)
    end
    end
    end
    elem.property(tpt.el.plsm.id, "Update", reaction)


    This uses some newer functions that not every script uses. sim.neighbors can look in a certain radius around an element for things. Then you just compare it to a list of elements not to react with, and create THRM in a random spot around it (which instantly melts into lava though).

    The -1 tells it to create a new particle. You can replace the existing particles instead though, which should make it multiply a little less, I think. Use 'i' there instead to replace the PLSM, and 'r' to replace the element it reacts with.