Modding TPT

  • GreenFireDragon
    15th Jun 2013 Member 0 Permalink

    you need to edit elementclasses.h and elementclasses.cpp, in .cpp add 'elements.push_back(Element_DERP());' and in .h after the list with #define: '#define PT_DERP id' and at the bottom before 'std::vector<Element> GetElements();': 

    class Element_DERP: public Element
    {
    public:
    Element_DERP();
    virtual ~Element_DERP();
    static int update(UPDATE_FUNC_ARGS);

    static int graphics(GRAPHICS_FUNC_ARGS);
    };

    only update and/or graphics if you use them

  • greymatter
    15th Jun 2013 Member 0 Permalink
    @GreenFireDragon (View Post)
    I did that, but nothing happened in the mod...
  • GreenFireDragon
    15th Jun 2013 Member 0 Permalink

    what is the code of the element

  • xetalim
    15th Jun 2013 Member 0 Permalink
  • mniip
    15th Jun 2013 Developer 0 Permalink
    @greymatter (View Post)
    Do you have git? you can clone the TPT repository
  • greymatter
    16th Jun 2013 Member 0 Permalink
    @mniip (View Post)
    No i don't.

    Weird problem:
    When i coded DERP and ran generator.py, nothing was added to elementclasses.h and .cpp. When i add them manually, nothing happens in the mod. When i add them manually and run generator.py, what i added gets removed. Very wierd, because this didn't happen to my first element, which also never showed up in the mod.
    This is the code of DERP(all copied from BGLA)

    #include "simulation/Elements.h"
    //#TPT-Directive ElementClass Element_BGLA PT_BGLA 47
    Element_DERP::Element_DERP()
    {
    Identifier = "DEFAULT_PT_DERP";
    Name = "DERP";
    Colour = PIXPACK(0x424242);
    MenuVisible = 1;
    MenuSection = SC_POWDERS;
    Enabled = 1;

    Advection = 0.4f;
    AirDrag = 0.04f * CFDS;
    AirLoss = 0.94f;
    Loss = 0.95f;
    Collision = -0.1f;
    Gravity = 0.3f;
    Diffusion = 0.00f;
    HotAir = 0.000f * CFDS;
    Falldown = 1;

    Flammable = 0;
    Explosive = 0;
    Meltable = 5;
    Hardness = 0;

    Weight = 90;

    Temperature = R_TEMP+0.0f +273.15f;
    HeatConduct = 150;
    Description = "Broken Glass, Heavy particles. Meltable. Bagels.";

    State = ST_SOLID;
    Properties = TYPE_PART;

    LowPressure = IPL;
    LowPressureTransition = NT;
    HighPressure = IPH;
    HighPressureTransition = NT;
    LowTemperature = ITL;
    LowTemperatureTransition = NT;
    HighTemperature = 1973.0f;
    HighTemperatureTransition = PT_LAVA;

    Update = NULL;

    }

    Element_DERP::~Element_DERP() {}

    I didn't change the second line, because that was just a comment.
  • xetalim
    16th Jun 2013 Member 0 Permalink


    //#TPT-Directive ElementClass Element_BGLA PT_BGLA 47

    generator.py reads that comment

    change all BGLA to DERP

    change 47 to 174

  • GreenFireDragon
    16th Jun 2013 Member 0 Permalink

    generator.py only add the files in 'SOURCE_FOLDER\src\simulation\elements' and if you create a file it's almost always created in the 'SOURCE_FOLDER'

  • xetalim
    16th Jun 2013 Member 0 Permalink

    @GreenFireDragon (View Post)

     also, generator.py only changes in SOURCE_FOLDER\generated

    (i think so)

  • greymatter
    16th Jun 2013 Member 0 Permalink
    @GreenFireDragon (View Post)
    It is in src\simulation\elements. I don't make silly mistakes like that.
    @xetalim (View Post)
    I'll give it a try.

    EDIT:i just tried it, and it worked. Python reads comments? 0_0
    BUT, still nothing added to the mod. I must be missing something.


    I code an element, runs generator.py. That part is clear and works properly.What's next?