#GLua Standard

1 messages · Page 1 of 1 (latest)

wide hill
#

My opinions:

  1. You should never use \\ or *\, use -- and --[[
  2. All local variables should be camelCase, even if it's a function
  3. Lua file names should have a prefix that stands for what realm(s) it will be loaded in (sv_, cl_, or sh_)

Other than that, I agree with everything here. By the way, syntax error on the 4th one

true grove
#

4 is arguing with gmod's default, your PRs would not be accepted with this standard

#

2.2 calling a file autorun_* inside the lua/autorun folder..

wide hill
true grove
#

Use 4 spaces for indentation, you probably mean "use tab" not 4 actual spaces, I will rdm you

wide hill
true grove
#

11, use dot with a space (can't), must use ["the key"] and I prefer it

#

what I haven't mentioned I do agree with though

wide hill
#

Also, preferably, the base Lua operators should always be used. Although, I do know that some people like to use !=

true grove
#

flavo(u)r, glua vs lua

#

You /dont/ need an MIT license for this either lol

wide hill
#

I do agree that != is better tho not sure why Lua changes it to ~=

true grove
#

It's just easier to type imo, only reason I use != is musclememoru

arctic saffron
#

if name != nil then is not always bad. Sometimes you need to defer between false and nil. E.g. for optional parameters being true by default.

function bla(optionalbool)
  if optionalbool == nil then
    optionalbool = true
  end

  -- whatever
  print("optionalbool", optionalbool)
end

bla() -- optionalbool true
bla(false) -- optionalbool false
bla(true) -- optionalbool true
true grove
#

type checking use case specific yeah

fluid ledge
distant jolt
balmy wedge
# true grove 2.2 calling a file autorun_* inside the lua/autorun folder..

The concept is that there is no need to clog the autorun folder with multiple files. Instead, you can create your own folder, which will contain ALL your scripts of a certain theme/addon. This way harmony is preserved

Conditionally:
lua/autorun/myeventsystem_autorun.lua

lua/myeventsystem/cl_hud.lua
lua/myeventsystem/sh_net.ua

A convenient thing, even **GmodStore ** adheres to this concept when accepting content on its platform

balmy wedge
balmy wedge
balmy wedge
daring snow
balmy wedge
open helm
#

use semicolons at every endline

#

lul

daring snow
balmy wedge
#

Added new things