-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyle.lua
More file actions
121 lines (96 loc) · 2.24 KB
/
style.lua
File metadata and controls
121 lines (96 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
--[[
-- This document contains details about the style guide of this project!
-- The style guide, is heavily influenced by OpenBSD's Kernal Norm Format.
-- The goal of that format is to keep code consistent, maintainable, and portable.
--]]
--[[ Single line comments look like this! ]]--
--[[
-- Important single line comments look like this!
--]]
--[[
-- Multiline comments look like this! Make them real sentences.
-- Fill up the space so it looks like (a) paragraph(s)!
--]]
--[[
-- When requiring files, do files from the util folder first.
-- Then, require the other files afterwards.
--]]
--[[
-- There should be no space between function name and the arguments.
--]]
--[[
-- Do this!
--]]
function CorrectFunction(my_arg) end
--[[
-- Not this!
--]]
function IncorrectFunction (my_arg) end
--[[
-- Types shouldn't use metatables. They also must be in their own file.
--]]
local MyType = {}
--[[
-- Do this!
--]]
function MyType.New()
local self = {}
self.MyParameter = 0
function self.MyMethod() end
return self
end
--[[
-- Not this!
--]]
function MyType.New()
return setmetatable({
MyParameter = 0
}, MyType)
end
--[[
-- Types must be PascalCased
--]]
--[[
-- Do this!
--]]
function MyType.New()
local self = {}
return self
end
--[[
-- Not this!
--]]
local mytype = {}
function mytype.New()
local self = {}
return self
end
--[[
-- Your code must fit PolyToria's style. PascalCased functions, variables, properties, etc.
-- The only things excluded from this style are, `self`, `arguments`, and one letter variables.
-- The exceptions must be camel_cased.
--]]
--[[
-- Do this!
--]]
local self = {}
local function MyFunction(arg1, arg2, cool_box) end
--[[
-- Not this!
--]]
local Self = {}
local function MyFunction(Arg1, Arg2, CoolBox) end
--[[
-- Prefer full names over abreviations. This helps the clairity of your code
-- As an example, instead of naming a variable `idx`, instead name it `index`
-- However, if the name is very long, then you can abbreviate it.
--]]
--[[
-- Use trailing commas on tables. This helps you comment and uncomment things from tables.
--]]
--[[
-- Ensure the types of variables in functions using the `type` function.
--]]
--[[
-- When calling something that returns a value that you want to ignore, assign it to _.
--]]