error with modding tpt

  • RidiculousChick
    21st Apr 2022 Member 0 Permalink

    so basically I made my first mod of the powder toy, I also downloaded the lua modules from lua.org, after I put the file into the folder containing powder toy and opened powder.exe, I then proceeded to run the code dofile("NuclearUpdate.lua"). the error was "cannot open NuclearUpdate.lua: No such file or directory"

    my lua module is v5.4.3 and heres the code if anyone need it to check what is going on, my os is windows 10. tpt version is 96.2.

     

    I spent half an hour making this mod please help me fix this issue.

    thanks.

     

    heres the lua code:

     

    local element_id = elements.allocate("Things", "NIHO")
    elements.property(element_id, "Name", "NIHO")
    elements.property(element_id, "Colour", E78B00)
    elements.property(element_id, "AirDrag", 0.06f)
    elements.property(element_id, "Advection", 0.85)
    elements.property(element_id, "MenuVisible", 1)
    elements.property(element_id, "MenuSection", elem.SC_NUCLEAR)
    elements.property(element_id, "Enabled", 1)
    elements.property(element_id, "AirLoss", 0.95)
    elements.property(element_id, "Loss", 1.25)
    elements.property(element_id, "Gravity", 0.075f)
    elements.property(element_id, "Falldown", 1)
    elements.property(element_id, "Hardness", 0)
    elements.property(element_id, "Diffusion", 0)
    elements.property(element_id, "Flammable", 0)
    elements.property(element_id, "Explosive", 0)
    elements.property(element_id, "Weight", 99)
    elements.property(element_id, "Temperature", 713.15)
    elements.property(element_id, "HeatConduct", 150)
    elements.property(element_id, "Meltable", 1)
    elements.property(element_id, "HighTemperature", 9273.15)
    elements.property(element_id, "HighTemperatureTransition", PT_LAVA)
    elements.property(element_id, "Description", "Nihonium, Extremely Radioactive")
    elements.property(element_id, "Properties", bit.bor(elem.TYPE_PART, elem.PROP_RADIOACTIVE, elem.PROP_NEUTPASS, elem.PROP_DEADLY, elem.PROP_HOT_GLOW))

  • LBPHacker
    21st Apr 2022 Developer 0 Permalink
    Relative paths (which NuclearUpdate.lua is) are relative to the current directory of the powder process. This is the same as the "data folder", i.e. the folder you're directed to when you press Open Data Folder in Settings. If you put NuclearUpdate.lua in that folder, dofile("NuclearUpdate.lua") will work.
  • RidiculousChick
    28th Apr 2022 Member 0 Permalink

    @LBPHacker (View Post)

     I put the powder toy files in a folder on my desktop as spike viper suggested in his clip on youtube (i cant share link ill break rules), and the mod is in the folder. the folder currently has powder.exe, the two txt files and the NuclearUpdate.lua. the folder is on the desktop

     

    but thanks for responding to the OG text! and so quickly!

    Edited once by RidiculousChick. Last: 28th Apr 2022
  • LBPHacker
    28th Apr 2022 Developer 0 Permalink
    But none of that matters.

    What matters is what your current / working directory is. On Windows, this setting is hidden away from the user pretty well for some reason; it's what "Start in" refers to in the shortcut editing dialog, and if you just double-click on a .exe in the file explorer, the current directory will be whatever directory that .exe is in. This is further complicated by the fact that TPT first checks if it sees a powder.pref in the current directory, and if it can't, it changes the current directory to a common one.

    As a result, it's relatively difficult to try figure out where you should put your scripts, which is why we have a button to do it for you in Settings. The recommended way is to run TPT in whatever way you usually do, then go to Settings, and press Open Data Folder. This gets you a file explorer window showing the directory TPT looks for scripts in. If you put your stuff here, dofile and friends will work. If you don't, they won't.