If you are not sure if your code complies, just send it in; we'll tell you in case it doesn't.
Code
-- do_something_one(foo) --> Makes xyz -- do_something_two(foo) --> Makes zxy; foo is a table that contains yxz local do_something_one = function(foo) * local bar = {} * for n, f in ipairs(foo) do if (foo == 5) then return foo else bar.x = f ** bar[n] = f ** table.insert(bar, f) print("test") end end 6* for _, b in pairs(bar) do print(dump(f)) end end 6* register_something("foo", function(foo, bar) *** if not foo then return end **** if (foo == bar) then print("foo = bar") else do_something_one (foo) 5* do_something_two (foo) 5* do_something_tree (foo) 5* do_something__with_a_ver_long_name_and_long_parameter_list (foo, bar, "1", 2, "3", 4) 7* end end)
There you go, that is some reference code for the coding style.
* = Make sure functions and variables that don't need to be public are defined local
** = To modify an array member by its index, preferably use bar.foo, not bar["foo"] if not required
*** = Define functions inside registrations; Makes things clearer, you know which function belongs to which registration
**** = You can put simple if constructions in one line only or use one line if the ifs do the same thing over and over again.
5* = If you use functions with similar parameters, it looks better to make it like the parameters are in a vertical line.
6* = Make spaces and empty lines between functions and inside functions for segments
7* = If a line becomes very long, try to split it. Try not to use more than 100 chars per line.
Random
GitHub