HELP ME D:

  • CATSSMAC
    22nd May Member 0 Permalink

    I'm not in danger or anything because of the title so mods dont ban this for being in a unrelated category, however, I am trying to make a TPT mod (CATSSMAC's mod) and i'm attempting to make an element called "MEOW" and when adding the lua script, it should work, but is not working :( i cant see the element anywhere and is nil (void) can anyone help me. here is the script if you need it to help this work. I only know Lua and not C++ so this is in Lua, along with my entire mod.

     

    local elemID = elements.allocate("CATSMACMOD", "MEOW")
    local elem = elements.element(elemID)

    elem.Name = "MEOW"
    elem.Description = "CATSSMAC mod element. Really doesn't do anything but explode into PROT, ELEC, and NEUT when heated over 1000."
    elem.Colour = 0x00B2FF
    elem.MenuSection = elements.SC_SOLIDS
    elem.Properties = elem.TYPE_SOLID
    elem.Temperature = 22
    elem.HeatConduct = 100

    function elem.Update(i, x, y, s, nt)
    local part = tpt.parts[i]

    if part.temp > 1000 then
    part.type = elements.PROT

    local right = tpt.get_particle_at(x + 1, y)
    if right then
    right.type = elements.ELEC
    else
    tpt.create(x + 1, y, elements.ELEC, 0, 0)
    end

    local left = tpt.get_particle_at(x - 1, y)
    if left then
    left.type = elements.NEUT
    else
    tpt.create(x - 1, y, elements.NEUT, 0, 0)
    end
    end

    return 0
    end

    Edited 6 times by CATSSMAC. Last: 22nd May
  • jacob1
    22nd May Developer 3 Permalink
    I can't help fix AI-generated scripts, my advice would be to stop using AI for tpt scripts, as it's never once generated anything valid.

    I'd suggest checking the wiki. First is this link, where you can find all the other links to the entire Lua API. There's also a beginner's tutorial linked on this page. It's a pdf from an old book, but Lua hasn't changed since it was written so it's still good.
    https://powdertoy.co.uk/Wiki/W/Powder_Toy_Lua_API.html

    Then, I'd recommend looking at the elements api. It has functions for creating elements, you should look at
    elem.element
    and
    elem.property
    .
    https://powdertoy.co.uk/Wiki/W/Lua_API:Elements.html

    You're also going to need the sim api, for functions like
    sim.partID
    or
    sim.partProperty

    https://powdertoy.co.uk/Wiki/W/Lua_API:Simulation.html
  • CATSSMAC
    22nd May Member 0 Permalink

    @jacob1 (View Post)

     ok ,well the script is ai but the concept like name and description were by myself. I'll check the wiki, thanks :) I also have made some scripts before by myself but they are unrelated to TPT

    Edited once by CATSSMAC. Last: 22nd May