Custom state changes

  • realbig
    24th May 2013 Member 1 Permalink

    I want to add an element that will condense into a default element, and conversely evaporate from that default element.  What would be the line of code for changing the default element's properties?  I havn't seen anything regarding state changes in lua, so I hope to get some info here.  Thanks!

  • NF
    24th May 2013 Member 0 Permalink

    Just go to the WIKI!

  • mniip
    24th May 2013 Developer 0 Permalink
    @NUCLEAR_FOX (View Post)
    uh-oh
    @realbig (View Post)
    There's wiki for that
    Owait... there aint anything regarding that...
    Anyway, i spent some time and had to find this: https://github.com/FacialTurd/The-Powder-Toy/blob/master/src/cat/LegacyLuaAPI.cpp#L156
    There's a table called tpt.eltransition , it contains keys for each of elements, for instance tpt.el.dust , which is a table as well, and has the following keys:
    presHighValue,presHighType,presLowValue,presLowType,tempHighValue,tempHighType,tempLowValue,tempLowType
    for instance tpt.el.dust.tempHighValue
    I hope the meaning of the keys is obvious...
    I'm currently too lazy to add this into the wiki, maybe someone should...
  • jacob1
    24th May 2013 Developer 0 Permalink
    You can do that, but there is one other way too.

    old way (I don't think it works with custom elements):
    tpt.el.dust.presLowValue = -10
    tpt.el.dust.presLowType 2

    new way:
    elements.property(1, "LowPressure", -10)
    elements.property(1, "LowPressureTransition", 2)

    This makes dust transform into watr at -10 pressure. You would then set a high pressure transition on watr to dust at -10 or something (although this reaction makes no sense anyway)
    The other properties for the new way are:
    LowPressure
    LowPressureTransition
    HighPressure
    HighPressureTransition
    LowTemperature
    LowTemperatureTransition
    HighTemperature
    HighTemperatureTransition

    @NUCLEAR_FOX (View Post)
    it's 4PM there, so that means nothing. You don't need to message Simon for help on scripts / saves, because usually someone will answer that day quicker and with multiple good answers
  • realbig
    25th May 2013 Member 0 Permalink

    Thanks guys! That's really helpful.

     

    @jacob1 (View Post)

     Could I use the name of the element in quotes instead of the item ID? Like this:

    elements.property("WATR", "LowPressure", -10)

     

    edit:added question

  • mniip
    25th May 2013 Developer 0 Permalink