LuaRules.wiki
author Wuzzy
Fri, 27 Nov 2020 13:41:20 +0100
changeset 2198 8fdee09037a9
parent 2195 f9dc7606394c
child 2265 5d951acf9b54
permissions -rw-r--r--
Translations: Add conventions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2191
aade57b7b63e LuaRules: cleanup
Wuzzy
parents: 2189
diff changeset
     1
#summary List of development rules for scripts
aade57b7b63e LuaRules: cleanup
Wuzzy
parents: 2189
diff changeset
     2
aade57b7b63e LuaRules: cleanup
Wuzzy
parents: 2189
diff changeset
     3
= Scripting Rules =
2189
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     4
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     5
For scripts, there are some basic but important development rules that all scripts need to follow to ensure the scripts are compatible across multiple systems.
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     6
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     7
For behavior in your script that affects actual gameplay, there are restrictions of what you can do with numbers. These are the rules:
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     8
2192
edf132b3d2b8 LuaRules: fix bullet
Wuzzy
parents: 2191
diff changeset
     9
 * Only integer numbers are allowed; floating-point numbers are forbidden
edf132b3d2b8 LuaRules: fix bullet
Wuzzy
parents: 2191
diff changeset
    10
 * If you divide, divide by powers of 2 if you can
edf132b3d2b8 LuaRules: fix bullet
Wuzzy
parents: 2191
diff changeset
    11
 * If you want to divide by a different integer value, use the `div` function for integer division
2195
f9dc7606394c LuaRules: plusminus
Wuzzy
parents: 2192
diff changeset
    12
 * Keep your numbers within ±2<sup>53</sup>
2192
edf132b3d2b8 LuaRules: fix bullet
Wuzzy
parents: 2191
diff changeset
    13
 * Avoid `math.floor` and `math.ceil`
2189
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    14
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    15
These restrictions on numbers don't apply to numbers that you don't use for gameplay but for stuff like harmless eye candy.
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    16
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    17
Failing to follow these rules might lead your script to behave differently on different systems, leading to desynchronization bugs, which means they will not work online.