TIPS : Lua Scripting/Programing.

  • Linearus
    6th Apr 2013 Member 0 Permalink

    Hi guys!

     

    This is just a little something for people to help people coding...

     

     

    1. INDENTING

    Most people I have seen on theses forums dont INDENT their code. When I say indenting I mean per block of code you should leave 4 or 2 spaces. A block (for you who dont know) is a function and an end code. Eg.

     

    if someVar == anotherVar then

     

      print("Doing something")

     

    end

     

    from the if to the end is a block and notic how I indented my code in between the block? This should be done with every block even the block block is in another. Eg.

     

    if something then

     

      while true do

     

        print()

     

      end

     

    end

     

    2. SPACING

     

    Again not many people space their code out.. Eg.

     

    if sV==vS then

      print(sV)

    end

     

    I like to keep my code spread out. Eg.

     

    if sV == vS then

      print( sV )

    end

     

    You can put spaces between OPERATORS, brackets and all sorts of stuff.

     

    3. COMMENT

     

    Comment your work. Eg.

     

    if someVar == thatVar then -- Test someVar againist thatVar

     

      print() -- Print something

     

    end -- End if block

     

    Commenting will not be read by Lua but keep in mind after you have typed the -- it will comment out the rest of that line.

  • mniip
    6th Apr 2013 Developer 0 Permalink
    @Linearus (View Post)
    1) use tabs
    2) eww too much spaces
    3) i'm sure THAT kind of code is understandible without comments, and there is code i don't really want others to undersand
  • Linearus
    6th Apr 2013 Member 0 Permalink

    mniip:

    @Linearus (View Post)
    3) i'm sure THAT kind of code is understandible without comments, and there is code i don't really want others to undersand

     

     

    Well I'm sure you haven't seen some of my code.

  • mniip
    6th Apr 2013 Developer 0 Permalink
    @Linearus (View Post)
    well, i'm sure you haven't seen some of MY code
  • Linearus
    6th Apr 2013 Member 0 Permalink

    I have and it nothing special.

     

    Link your best...

  • mniip
    6th Apr 2013 Developer 0 Permalink
  • Linearus
    6th Apr 2013 Member 0 Permalink

    Oh wow. I have a made SHA256 Lua encrypt function..

     

    Paste: pastebin.com/fb1gVb3B

     

    suck a fat one
  • mniip
    6th Apr 2013 Developer 0 Permalink
    Is it sad that i can read it?
    Anyway, http://mniip.com/svg.zip
    an anti-alias svg renderer
  • Linearus
    6th Apr 2013 Member 0 Permalink

    Ok, ok, do you know anything about metatables/metamethods?

  • byzod
    6th Apr 2013 Member 1 Permalink

    What a wonderful guess-what-this-single-character-variable-is party.