How to create a new element?

  • dyaomaster
    19th Mar 2018 Member 0 Permalink

    I'm trying to make a new element. I'm using the page on the wiki that says how to do this, and I got stuck on part 1, step 1, sentence 1.

     

    Part One: Defining the Element's Properties

    Step One: Defining the Element

    Create a new element file, (HETR.cpp for this example, or whatever name your element will be) inside of src/simulation/elements.

     

    I don't know where this src/simulation/elements folder is. It's not in my TPT folder.

    How do I do this?

  • QuanTech
    19th Mar 2018 Member 0 Permalink

    @dyaomaster (View Post)

     Alright so first, you have to get the TPT source code. Go to https://github.com/ThePowderToy/The-Powder-Toy , click on that green button that says 'Clone or Download' , then click 'Download ZIP'. Unpack the zip, and voila, you'll have a folder with the source code stuff in it. Navigate to <source-folder-name>/src/simulation/elements, create a new file, and have fun modding!

  • jacob1
    19th Mar 2018 Developer 0 Permalink
    Are you trying to create it in C++, or in Lua? This guide is for C++.

    Do you know either of these languages? Lua is pretty easy and you can so some really basic stuff without knowing it well. C++ you will need to know more about if you are doing it that way.

    Lua reference: https://powdertoy.co.uk/Wiki/W/Powder_Toy_Lua_API.html
    Some stuff / a very basic tutorial on creating an element: https://powdertoy.co.uk/Wiki/W/Lua_API:Elements.html
    Edited once by jacob1. Last: 19th Mar 2018
  • SSA2012YT
    2nd Dec 2020 Member 0 Permalink

    @QuanTech (View Post)

     But how do you open? I can't find the file

  • phox
    2nd Dec 2020 Member 0 Permalink

    SSA2012YT:

    @QuanTech (View Post)

     But how do you open? I can't find the file

     



    winrar

    Edited once by phox. Last: 2nd Dec 2020
  • polokus
    2nd Dec 2020 Member 1 Permalink

    In other words, it's going to take you months, unless you already have a ton of coding experience.

    Even then, it won't be easy, and even when you get it right, it still won't work properly.

    Why is my TYPE_GAS not moving?

    elements.element(elements.DEFAULT_PT_NBLE)

    Is not enough. Enjoy being discouraged at every step while wondering why nobody made a program for this.

     

    oh and btw try the LUA version. ask around, LUA is much easier to work with, doesn't require 'compiling' which everyone says is easy but ITS NOT. download scripts other people made, change a few things, restart powder toy to get a feel for what the thing does that you changed, that way, you'll have a feel for this. then, copy their element, make a .lua file and edit everything until you actually have your own element. That worked for me, despite me absolutely hating how everything works.

     

    using Lua means you don't have to compile a new version of powder toy every single time:

    Oops, my element is supposed to be in another category. WELP, Time to Compile again (it doesn't take 10 seconds)

    Edited 2 times by polokus. Last: 2nd Dec 2020
  • FD_DE
    29th May 2023 Member 0 Permalink

    @phox (View Post)

     yeah but how do you run the folder you just modded

  • That_PowderToy_Guy
    23rd Nov 2023 Member 0 Permalink

    nice

  • OSMA
    19th November Member 0 Permalink

    SSA2012YT:

    @QuanTech (View Post)

     But how do you open? I can't find the file