Lua Code Conventions

Bad Code:

function f(sArg1 , ... )
   assert(type(sArg1)== "string", "me wants a strign!")
    if sArg1 then
        local nResult = 1
        --do some more stuff
        return nResult
  end
end
if  f ( "a" )  ==1 then
print"asd"
end

Good Code:

function f(name, ...)
  checkArg(1, name, "string")
  if name then
    local result = 1
    -- We extrapolate the b-spline of the non-euclidean space to
    -- determine the fraction of potential failures encountered.
    return result
  end
end
if f("a") == 1 then
  print("asd")
end

Contents

Addon Mods Addons Computronics
Supporting OpenComputers Thut's Concrete