New mod: Raib

  • RadioActiveLua
    10th Nov 2013 Member 0 Permalink
    New element with lua. (use dofile("")) if you don't know how to I'm sure the wiki will explain this.

    Unknown Element. Comes in 6 colors. Has a very weird effects.

    local a = elements.allocate("C", "Q")
    elements.element(elements.C_PT_Q, elements.element(elements.DEFAULT_PT_HYGN))
    elements.property(elements.C_PT_Q, "Name", "RAIB")
    elements.property(elements.C_PT_Q, "Description", "Unknown Element.")
    elements.property(elements.C_PT_Q, "Colour", 0xFFFF0080)
    elements.property(elements.C_PT_Q, "MenuSection", 10)
    elements.property(elements.C_PT_Q, "Gravity", 0.3)
    elements.property(elements.C_PT_Q, "Flammable", 10000)
    elements.property(elements.C_PT_Q, "Explosive", 1)
    elements.property(elements.C_PT_Q, "Weight", 66)
    elements.property(elements.C_PT_Q, "Diffusion", 0)
    elements.property(elements.C_PT_Q, "HotAir", -0.1)
    elements.property(elements.C_PT_Q, "Hardness", 0)
    q={0x99FFFF,0x9999FF,0xCCFF00,0x00FFCC,0x00CC00,0x330099}
    z=q[math.random(1,6)]
    elements.property(elements.C_PT_Q, "Colour", z)

    Edit-jacob1: well, there newlines fixed
    Edited 2 times by jacob1. Last: 11th Nov 2013
  • FeynmanLogomaker
    11th Nov 2013 Member 0 Permalink

    What code editor do you use? Does it not write a newline properly, or what? (If it is the code editor, you should try SciTE, it comes with lua-for-windows)

  • mniip
    11th Nov 2013 Developer 0 Permalink
    @FeynmanLogomaker (View Post)
    newlines being not detected all suggests it's a mac
  • FeynmanLogomaker
    11th Nov 2013 Member 0 Permalink

    Oh, is that a Mac thing? In that case, a lua-for-windows package might not work.

  • RadioActiveLua
    11th Nov 2013 Member 0 Permalink

    Thanks for the line fix.

  • mniip
    12th Nov 2013 Developer 0 Permalink
    q and z are global. also your element doesn't change color randomly, it just gets a random color on startup
  • RadioActiveLua
    12th Nov 2013 Member 0 Permalink

    I never said it changed color randomly. I said it comes in 6 different colors. Meaning on startup.

  • mniip
    12th Nov 2013 Developer 0 Permalink
    yeah now just make those q and z local
  • RadioActiveLua
    12th Nov 2013 Member 0 Permalink

    I already did on my MOD i'm making. I added more to this also.

  • jacob1
    12th Nov 2013 Developer 2 Permalink
    @mniip (View Post)
    i'm sort of tired of seeing you post on every single script out there, a list of every single variable that's global. Having global variables might not be that good coding style, but it's not the end of the world, seriously. You should stop complaining and give actual advice, and once you see a coder get farther in lua then try explaining what globals and locals do.

    I think the script is fine the way it is, adding more too it would be better though :D it's sort of small now, just one simple element.

    I recommend you look into update functions, which allow you to do so much more than edit simple properties. Also maybe graphics functions, that way you could maybe give each one a random color when drawn. Which might not be what you want though. There is no simple tutorial, sometimes you just have to look at what's out there.