Question

  • sfsjunior
    16th Mar 2014 Member 0 Permalink

    Hello, i want to update my mod with simple reactions, how do i make this in lua?

    I want something like (with my new elements)

    Argonium+oxygen = Air

    or Air + acid gases ( like methane, caustic gas and others) = Argonium, oxygen and hydrogen

  • CeeJayBee
    16th Mar 2014 Member 0 Permalink

    @sfsjunior (View Post)

     I'd check up on the API for TPT. It's simple to do heat/pressure changes, just do:

    elements.property(elements.A_PT_EL1, 'X', elements.A_PT_EL2)

    and replace X with either

    LowTemperatureTransition -- At low temperature change to this element

    HighTemperatureTransition -- At high temperature change to this element

    LowPressureTransition -- " ", pressure

    HighPressureTransition -- " ", pressure high

    I'm assuming you know what to change A_PT_EL1 and A_PT_EL2 for.

    EDIT: Use

    elements.property(elements.A_PT_EL1, 'LowTemperature', '123.4')

    to define what the low/high temp/pressure is.

    Edited 3 times by CeeJayBee. Last: 16th Mar 2014
  • sfsjunior
    16th Mar 2014 Member 0 Permalink

    Hi!

    Thanks!

    I've discovered that i need to use the object SIM but i did not understand how...

    If you can help, please help!

    Something like PROT+PHOT(without mods the result is HYDGN and OXYG)

    Edited 2 times by sfsjunior. Last: 16th Mar 2014
  • Faerindel
    16th Mar 2014 Member 0 Permalink

    For reactions between different elements, you'll need to set the update() function.

     

    You need to create a lua function specifying which elements, in which conditions and such.

    Then you set the "Update" property of your element like:

    elements.property(elements.YOUR_ELEMENT, "Update", your_update_function)

     

    For example, my update function for chlorine + hydrogen -> hydrogen chloride:

    http://pastebin.com/YGJFG6yT

     

    The function checks the immediate surroundings of the particle, and if HYGN is found, it reacts.

    The chance check is to control the overall reaction speed.

     

    When 89.3 comes and sim.neighbors() and sim.partID() are fixed, the code will be smaller and more clear.

    Edited once by Faerindel. Last: 16th Mar 2014
  • jacob1
    16th Mar 2014 Developer 0 Permalink
    @Faerindel (View Post)
    actually, instead of 89.3 it was just a re-release of 89.2 with all the bugfixes, so everything works properly now.
  • Faerindel
    17th Mar 2014 Member 0 Permalink

    jacob1:

    @Faerindel (View Post)
    actually, instead of 89.3 it was just a re-release of 89.2 with all the bugfixes, so everything works properly now.

     

    Awesome! Already tested sim.neighbors(), and it's faster than using the two for loops.

    For some reason, sim.partProperty() is noticeably slower than tpt.get_property() though.