LuaRules.wiki
author Wuzzy <almikes@aol.com>
Mon, 12 Oct 2020 02:07:56 +0200
changeset 2189 b2f75d4bf715
child 2191 aade57b7b63e
permissions -rw-r--r--
Add LuaRules.wiki
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2189
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     1
## Scripting Rules
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     2
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     3
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
     4
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     5
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
     6
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     7
* Only integer numbers are allowed; floating-point numbers are forbidden
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     8
* If you divide, divide by powers of 2 if you can
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     9
* If you want to divide by a different integer value, use the `div` function for integer division
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    10
* Keep your numbers within (+/-) 2<sup>53</sup>
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    11
* Avoid `math.floor` and `math.ceil`
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    12
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    13
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
    14
b2f75d4bf715 Add LuaRules.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    15
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.