Lua/scripts help

  • CCl2F2
    8th Sep 2020 Moderator 0 Permalink

    Recently, I was thinking about adding some new elements to TPT. And I did. I adden COIL (Crude Oil) and some reactions; turns into OIL when heated to ~300C, Turns to GAS when cooled to

    - 20C). But i want to add some more, how can I make for exemple COIL + BCOL = [something]? And how can I "access"  code of vanilla elements by Lua? Is there way to do that?
    Edited once by IlikeUssr. Last: 8th Sep 2020
  • polokus
    28th Sep 2020 Member 0 Permalink

    if r~=nil then
        if sim.partProperty(r,'type') == "GLAS" and math.random(1,60) == 1 then
            sim.partProperty(r,'type', elem.DEFAULT_PT_GOLD)

            sim.partProperty(i,'type', elem.DEFAULT_PT_PLUT)
        end
    end

     

    Every frame it throws a 60-sided dice which should land on 1 to make the GLAS it is touching transmute into GOLD.

    At the same time COIL will turn into PLUT.

     

    https://codeload.github.com/The-Powder-Toy/The-Powder-Toy/zip/snapshot-200

    Somewhere inside this .zip folder is src/elements/PROT.cpp

    Open it using any text editor. The code is not LUA however what is logic is found in all language.

    Edited 4 times by polokus. Last: 28th Sep 2020