How to apply an update function to NONE?

  • _Theo
    28th Aug 2018 Member 0 Permalink

    I'm trying to make condensation occur when an element around NONE/Empty/Air is cooled down enough. I've made the update function but it doesn't seem to work. Here's the script:

    elements.property(elements.DEFAULT_PT_NONE, "Update", --*1
    function(i,x,y) --1
    for r in sim.neighbors(x,y,1,1) do --2
    if sim.partProperty(r, "temp") < 100 then --3
    if math.random(1,45000) == 1 then --4
    sim.partCreate(-1, x+math.random(-2,2), y+math.random(-2,2), elements.DEFAULT_PT_WATR)
    end --4
    end --3
    if sim.partProperty(r, "temp") < 200 then --5
    if math.random(1,45000) == 1 then --6
    sim.partCreate(-1, x+math.random(-2,2), y+math.random(-2,2), elements.DEFAULT_PT_LOXY)
    end --6
    end --5
    end --2
    end --1
    ) --*1

  • jacob2
    28th Aug 2018 Member 0 Permalink
    NONE isn't an element. It is the lack of an element. In !set commands we allow you to use none to delete elements, which is special cased in the code. The Lua API also lets you "set" it's properties, which are all default properties and not used for anything.

    So, you can't set an update function on something that doesn't exist.


    You'll have to do this a different way. Maybe you can use a tpt.register_step function.
    Edited once by jacob2. Last: 28th Aug 2018
  • _Theo
    29th Aug 2018 Member 0 Permalink

    Strange. Also now that I think of it since none is basically everywhere, the update function would lag alot if it would've worked.