Need help with certain events in Lua

  • creator_of_fail
    8th March Member 0 Permalink

    I'm trying to detect when an element has been created in Lua. I checked the wiki events section and only found some mouse clicks and some other functions. Maybe I'm blind, but I can't find anything about this when searching on google either. Can somebody help?

  • jacob1
    9th March Developer 1 Permalink
    It's not the most well-advertised right now. But you are looking for elem.property, which can set certain simulation events.

    Event list:
    https://powdertoy.co.uk/Wiki/W/Element_Properties.html#Callback_functions
    You want the "Create" event which tells you when that element is created, but depending on your exact needs you could also look at "ChangeType" as well.

    Set it using elem.property:
    https://powdertoy.co.uk/Wiki/W/Lua_API:Elements.html#elements.property
    elem.property(myelement, "Create", function(i, x, y, typ, v)
    -- Do something
    end)
  • creator_of_fail
    9th March Member 0 Permalink

    Thanks, I was going to make an energy particle but wasn't sure how to only make it move on creation.

    Edited 3 times by creator_of_fail. Last: 9th March