Script Format

  • S117
    14th Dec 2015 Member 0 Permalink

    I already looked through the website and i could not find a "template" for new elements, does anybody know where i can find one?

    Specifically, I am looking for a template that includes most if not all of the properties.

    Any feedback would help. :)

    Edited once by S117. Last: 14th Dec 2015
  • ChargedCreeper
    14th Dec 2015 Member 0 Permalink

    S117:

    I already looked through the website and i could not find a "template" for new elements, does anybody know where i can find one?

    Specifically, I am looking for a template that includes most if not all of the properties.

    Any feedback would help. :)

     

    Did you look at the wiki? Specifically, https://powdertoy.co.uk/Wiki/W/Lua_API:Elements.html

  • S117
    14th Dec 2015 Member 0 Permalink

    For some reason I did not find that yesterday... thank-you.

     

    And as a second question, how do I add the graphic effect that dest has to one of my custom elements?

    I found the code for it but it's not exactly clear on how to implement it into the source code.

  • boxmein
    14th Dec 2015 Former Staff 0 Permalink
    Edited 2 times by boxmein. Last: 10th Apr 2016
  • S117
    14th Dec 2015 Member 0 Permalink

     

    Ok, not trying to sound like a newb but this is the element that i am trying to implement it into. (and im sorry if posting the source code like this breaks any rules) but I am still confused on where and how the PMODE_LFLARE   0x00000000 is supposed to be added. I dont really know javascript or c++.

     

    EDIT: The math and stuff isnt mine, i borrowed it from another custom energy element.

     

    local test1 = elem.allocate("S117", "TEST")
    elem.element(test1, elem.element(elem.DEFAULT_PT_ELEC))
    elem.property(test1, "Name", "TEST")
    elem.property(test1, "Description", "TEST ENERGY")
    elem.property(test1, "Colour", 0xff274)
    elem.property(test1, "MenuSection", elem.SC_RADIOACTIVE)
    elem.property(test1, "Properties", elem.TYPE_ENERGY)
    elem.property(test1, "State", elem.ST_NONE)
    elem.property(test1, "Temperature", 273.15)
    elem.property(test1, "HeatConduct", 0)
    elem.property(test1, "Weight", -1)
    elem.property(test1, "Collision", -0.99)


    local function energy(i, x, y, s, nt)
     local tmp2 = sim.partProperty(i, sim.FIELD_TMP2)
     if tmp2 == 0 then
      local angle = math.random() * math.pi*2

      sim.partProperty(i, sim.FIELD_TMP2, 1)
      sim.partProperty(i, sim.FIELD_VX, math.sin(angle)*5)
      sim.partProperty(i, sim.FIELD_VY, math.cos(angle)*5)
     end

     --for dx = -1, 1, 1 do
      --for dy = -1, 1, 1 do
      --end
     --end
    end

    elements.property(test1, "Update", energy)

    Edited once by S117. Last: 14th Dec 2015
  • jward212
    14th Dec 2015 Member 0 Permalink

    This is !o0o!lua!o0o!

    You only need to post a source if it's C++ in which you make your own '.exe'

    lua is a scipting language. you write a script, then powder toy runs it. There is no making of an '.exe'

    lua is better than C++ to work with for people new to coding as it doesn't require as much programs and resources to use.

    PMODE_LFLARE makes it have a flare like bomb elements, do you really want it?

    Edited once by jward212. Last: 14th Dec 2015
  • S117
    14th Dec 2015 Member 0 Permalink

    yes, i just cant figure a way to get it to work, any suggestions?

  • jward212
    14th Dec 2015 Member 0 Permalink

    Do you mean you want to run it or add the graphic?

  • S117
    14th Dec 2015 Member 0 Permalink

    add the graphic

  • jward212
    14th Dec 2015 Member 0 Permalink

    add this to the end of the script

     

    local function gfunc(i, r, g, b)
    return 1, 0x00000040, 255, 110, 255, 110, 255, 110, 255, 110
    end
    tpt.graphics_func(gfunc, test1)

     

    looks pretty cool, I like it!!!

    Edited 2 times by jward212. Last: 14th Dec 2015