Help Plz?

  • blk
    7th Dec 2013 Member 0 Permalink

    Could someone tell me how to make a lua mod? I know how to use lua and i screw around with files alot in the console but i would like to know how to make new elements. I already know how to change the properties of elements that exist, but I need to know how to make a new element and then how to actually put it into use.

    Edited once by blk. Last: 7th Dec 2013
  • Box-Poorsoft
    7th Dec 2013 Banned 1 Permalink
    This post is hidden because the user is banned
  • RadioActiveLua
    7th Dec 2013 Member 1 Permalink

    local ELEMENT = elements.allocate("Something1","Something2")

    elements.element(elements.Something1_PT_Something2, elements.element(elements.DEFAULT_PT_WATR))

    elements.property(elements.Something1_PT_Something2, "Name", "EXAMPLE")

    elements.property(elements.Something1_PT_Something2, "Description", "Just an Example.")

    elements.property(elements.Something1_PT_Something2, "Gravity", 0.4)

    elements.property(elements.Something1_PT_Something2, "HotAir", 0.1)

    elements.property(elements.Something1_PT_Something2, "Colour", 0xFF0000)

    elements.property(elements.Something1_PT_Something2, "Loss", 0)

    elements.property(elements.Something1_PT_Something2, "Hardness", 9999)

     

    Simple way to create ane element.. A better example is the FOZO Element I created which is below.

     

    local FOZO = elements.allocate("ELEMENT", "FOZO")
    elements.element(elements.ELEMENT_PT_FOZO, elements.element(elements.DEFAULT_PT_GLOW))
    elements.property(elements.ELEMENT_PT_FOZO, "Name", "FOZO")
    elements.property(elements.ELEMENT_PT_FOZO, "Description", "Unknown Liquid. SUB/33/1/4/5/3[4]")
    elements.property(elements.ELEMENT_PT_FOZO, "Colour", 0x0000FF)
    elements.property(elements.ELEMENT_PT_FOZO, "Weight", 50)
    elements.property(elements.ELEMENT_PT_FOZO, "Temperature", 70000)
    elements.property(elements.ELEMENT_PT_FOZO, "LowTemperature", 10.0)
    elements.property(elements.ELEMENT_PT_FOZO, "LowTemperatureTransition", elements.DEFAULT_PT_BCOL)

     

     

    Hope this helped.

  • Cacophony
    7th Dec 2013 Member 1 Permalink

    Dunno the exact details,but it's like this:

    1.Make a lua script

    2.Save the script as autorun.lua

    3.Put it in the same folder as TPT

  • blk
    8th Dec 2013 Member 1 Permalink

    Thanks RadioActiveLua, you did help. While I was away I learned how to write in lua, and was stuck on trying to figure out how to melt my new element. Your post taught me how to do state changes and such.

     I am stuck on how to make it appear in the menu though, help would be nice.

    Edited once by blk. Last: 8th Dec 2013
  • Nobody905
    8th Dec 2013 Member 0 Permalink

    @Box-Poorsoft (View Post)

     Like mniip would ever help.

  • blk
    8th Dec 2013 Member 0 Permalink

    I also need help learning how to use elements.property(ID,"Color",xxxxxx) correctly. The only 2 colors I can get are shades of green or shades of blue. Another thing, how do I make an element I create change forms on contact with another element? Like NEUT hitting PLNT to create WOOD?

    Edited once by blk. Last: 8th Dec 2013
  • Nobody905
    8th Dec 2013 Member 0 Permalink

    @blk (View Post)

     1. It's "Colour", not "Color".

     2. The property uses hex format, with a 0x prefix. Don't understand it?

     

    http://lmgtfy.com/?q=Hexadecimal+colour+code+format

  • RadioActiveLua
    9th Dec 2013 Member 0 Permalink

    @blk (View Post)

     To make it appear on a menu its

     

    elements.property(elements.Something1_PT_Something2, "MenuSection", 1-11)

    1=Electronics

    2=Powder Materials

    3=Sensors

    4=Force

    5=Explosives

    6=Gasses

    7=Liquids

    8=Powders

    9=Solids

    10=Radioactive

    11=Special

  • jacob1
    9th Dec 2013 Developer 0 Permalink
    @RadioActiveLua (View Post)
    using numbers like that is bad, we might add a new menusecion in the future and that would put it in the wrong menu later.

    Use things like elements.SC_POWDERS instead, that will always be the number for the powders menu even if we change it. They are all documented in the wiki, lots of other numbers people use have constants they should be using ...

    @blk (View Post)
    both "Color" and "Colour" do work, but it's elements.property(ID,"Color",0xAARRGGBB) , use FF for AA (alpha), and the rest are hex values for the other colors. The deco editor gives a hex value for the whole thing so I would use the color picker to decide on a color

    The other thing you want to do is more complicated, but also the most important part of lua element modding. You need to write a lua update function, which is called every frame for every element to update it. You would probably want to create one for WOOD that doesn't overwrite the existing one, and then searched a random location around it for NEUT using some undocumented function ... maybe i'll write an example later, for now I have a lot of homework lol. The function is tpt.update_func though, might be in the legacy api section in the wiki.