How to add elements permanently to TPT

  • Gelix
    12th Mar 2016 Member 0 Permalink

    I was woundering if can add my own elements that dont disapear when you close the game?

  • ChargedCreeper
    12th Mar 2016 Member 0 Permalink

    Gelix:

    I was woundering if can add my own elements that dont disapear when you close the game?

     

    Yes, you need to use a file named autorun.lua in the same folder as the TPT exe. I would strongly advise you to use this nice script manager:

    https://powdertoy.co.uk/Discussions/Thread/View.html?Thread=19400

     

    With it, you can download/install scripts and enable/disable scripts from within game (note that disabling a script requires the game to restart).

     

    To use your own scripts with this, you just need to put lua files in the scripts folder, then enable them from the in-game Lua button GUI.

    Edited 2 times by ChargedCreeper. Last: 12th Mar 2016
  • boxmein
    12th Mar 2016 Former Staff 0 Permalink
    Elements can be added in two ways:
    1) Lua scripts
    Those have to be loaded every time the game starts, but they work across most (if not all) mods and won't have to be maintained as intensely. These, I assume, are what you've done thus far.

    2) C++ elements
    These elements are straight in the source code of the EXE file itself. For this you need to use a different and more difficult programming language and your elements will only be usable with your mod's EXE file. For those, you can check out an example element here:
    http://boxmein.net/tpt/tptelements/editor.html#c++
    And if you read the Coding tutorial here:
    https://powdertoy.co.uk/Wiki/W/Coding-tutorial.html
    Check out the source code for all other elements in the default game here:
    https://github.com/simtr/The-Powder-Toy/tree/master/src/simulation/elements