Copy a value of one element to other?

  • coolkase
    15th Mar 2023 Member 0 Permalink

    I have one of my custom elements have all of the same elements near it react the same way when touching WATR. My script does this in the create function so it doesn't lag out. Heres what the update function looks like currently:

     

    local function create(i,x,y)
        sim.partProperty(i, sim.FIELD_LIFE, 475)
        for r in sim.neighbors(x,y,1,1) do
            local rtype = sim.partProperty(r, sim.FIELD_TYPE)      
            if rtype~=0 then
                sim.partProperty(i, sim.FIELD_TMP, rtype)
            end
            if rtype==251 then
                sim.partProperty(i, sim.FIELD_TMP, sim.partProperty(r, sim.FIELD_TMP))
            end
        end
    end
    elements.property(rsdm, "Create", create)
     
    Although only the top layer of the element reacts correctly, the ones below just turn into GRBG (done if the TMP value does not equal 2 or 27). Does anyone know how to fix this?
    Edited 2 times by coolkase. Last: 16th Mar 2023
  • ArolaunTech
    17th Mar 2023 Member 0 Permalink

    Use the update function. The create function only gets executed when the element is created.