mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fixed coding-guidelines.md
This commit is contained in:
parent
30828b83d2
commit
508c6de2cb
@ -125,25 +125,25 @@ Every function should have a header of the following format:
|
|||||||
The family of `GVAR` macro's define global variable strings or constants for use within a module. Please use these to make sure we follow naming conventions across all modules and also prevent duplicate/overwriting between variables in different modules. The macro family expands as follows, for the example of the module 'balls':
|
The family of `GVAR` macro's define global variable strings or constants for use within a module. Please use these to make sure we follow naming conventions across all modules and also prevent duplicate/overwriting between variables in different modules. The macro family expands as follows, for the example of the module 'balls':
|
||||||
|
|
||||||
|
|
||||||
| Macros | is the same as |
|
| Macros | Expands to |
|
||||||
| -------|---------|
|
| -------|---------|
|
||||||
| `GVAR(face)` | ace_balls_face |
|
| `GVAR(face)` | ace_balls_face |
|
||||||
|`QGVAR(face)` | ace_balls_face |
|
|`QGVAR(face)` | "ace_balls_face" |
|
||||||
| `EGVAR(balls,face)` | ace_balls_face |
|
| `EGVAR(balls,face)` | ace_balls_face |
|
||||||
| `EGVAR(leg,face)` | ace_leg_face |
|
| `EGVAR(leg,face)` | ace_leg_face |
|
||||||
| `QEGVAR(leg,face)` | ace_leg_face |
|
| `QEGVAR(leg,face)` | "ace_leg_face" |
|
||||||
|
|
||||||
There also exists the FUNC family of Macros:
|
There also exists the FUNC family of Macros:
|
||||||
|
|
||||||
| Macros | is the same as |
|
| Macros | Expands to |
|
||||||
| -------|---------|
|
| -------|---------|
|
||||||
|`FUNC(face)` | ace_balls_fnc_face or the call trace wrapper for that function.|
|
|`FUNC(face)` | ace_balls_fnc_face or the call trace wrapper for that function.|
|
||||||
|`EFUNC(balls,face)` | ace_balls_fnc_face or the call trace wrapper for that function.|
|
|`EFUNC(balls,face)` | ace_balls_fnc_face or the call trace wrapper for that function.|
|
||||||
|`EFUNC(leg,face) `| ace_leg_fnc_face or the call trace wrapper for that function.|
|
|`EFUNC(leg,face) `| ace_leg_fnc_face or the call trace wrapper for that function.|
|
||||||
|`DFUNC(face)` | ace_balls_fnc_face and will ALWAYS be the function global variable.|
|
|`DFUNC(face)` | ace_balls_fnc_face and will ALWAYS be the function global variable.|
|
||||||
|`DEFUNC(leg,face)` | ace_leg_fnc_face and will ALWAYS be the function global variable.|
|
|`DEFUNC(leg,face)` | ace_leg_fnc_face and will ALWAYS be the function global variable.|
|
||||||
|`QFUNC(face)` | ace_balls_fnc_face |
|
|`QFUNC(face)` | "ace_balls_fnc_face" |
|
||||||
|`QEFUNC(leg,face)` |ace_leg_fnc_face|
|
|`QEFUNC(leg,face)` | "ace_leg_fnc_face" |
|
||||||
|
|
||||||
The `FUNC` and `EFUNC` macros should NOT be used inside `QUOTE` macros if the intention is to get the function name or assumed to be the function variable due to call tracing (see below). If you need to 100% always be sure that you are getting the function name or variable use the `DFUNC` or `DEFUNC` macros. For example `QUOTE(FUNC(face)) == "ace_balls_fnc_face"` would be an illegal use of `FUNC` inside `QUOTE`.
|
The `FUNC` and `EFUNC` macros should NOT be used inside `QUOTE` macros if the intention is to get the function name or assumed to be the function variable due to call tracing (see below). If you need to 100% always be sure that you are getting the function name or variable use the `DFUNC` or `DEFUNC` macros. For example `QUOTE(FUNC(face)) == "ace_balls_fnc_face"` would be an illegal use of `FUNC` inside `QUOTE`.
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ These macros will call these functions with the appropriate wrappers and enable
|
|||||||
|
|
||||||
#### 4.2.1 setVariable, getVariable family macros
|
#### 4.2.1 setVariable, getVariable family macros
|
||||||
|
|
||||||
| Macro | is the same as |
|
| Macro | Expands to |
|
||||||
| -------|---------|
|
| -------|---------|
|
||||||
|`GETVAR(player,MyVarName,false)` | player getVariable ["MyVarName", false]|
|
|`GETVAR(player,MyVarName,false)` | player getVariable ["MyVarName", false]|
|
||||||
|`GETMVAR(MyVarName,objNull)` | missionNamespace getVariable ["MyVarName", objNull]|
|
|`GETMVAR(MyVarName,objNull)` | missionNamespace getVariable ["MyVarName", objNull]|
|
||||||
@ -186,7 +186,7 @@ Example:</br>
|
|||||||
|
|
||||||
Script strings:
|
Script strings:
|
||||||
|
|
||||||
| Macro | is the same as |
|
| Macro | Expands to |
|
||||||
| -------|---------|
|
| -------|---------|
|
||||||
| `LSTRING(banana)` | "STR_ACE_balls_banana"|
|
| `LSTRING(banana)` | "STR_ACE_balls_banana"|
|
||||||
| `ELSTRING(balls,banana)` | "STR_ACE_balls_banana"|
|
| `ELSTRING(balls,banana)` | "STR_ACE_balls_banana"|
|
||||||
@ -194,7 +194,7 @@ Script strings:
|
|||||||
|
|
||||||
Config Strings (require `$` as first character):
|
Config Strings (require `$` as first character):
|
||||||
|
|
||||||
| Macro | is the same as |
|
| Macro | Expands to |
|
||||||
| -------|---------|
|
| -------|---------|
|
||||||
| `CSTRING(banana)` | "$STR_ACE_balls_banana" |
|
| `CSTRING(banana)` | "$STR_ACE_balls_banana" |
|
||||||
| `ECSTRING(balls,banana)` | "$STR_ACE_balls_banana" |
|
| `ECSTRING(balls,banana)` | "$STR_ACE_balls_banana" |
|
||||||
@ -206,7 +206,7 @@ Event handlers in ACE3 are implemented through our event system. They should be
|
|||||||
|
|
||||||
The commands are listed below.
|
The commands are listed below.
|
||||||
|
|
||||||
| Even Handler | use |
|
| Even Handler | Use |
|
||||||
| -------|---------|
|
| -------|---------|
|
||||||
|`[eventName, eventCodeBlock] call ace_common_fnc_addEventHandler` | adds an event handler with the event name and returns the event handler id.|
|
|`[eventName, eventCodeBlock] call ace_common_fnc_addEventHandler` | adds an event handler with the event name and returns the event handler id.|
|
||||||
| `[eventName, args] call ace_common_fnc_globalEvent` | calls an event with the listed args on all machines, the local machine, and the server. |
|
| `[eventName, args] call ace_common_fnc_globalEvent` | calls an event with the listed args on all machines, the local machine, and the server. |
|
||||||
@ -216,7 +216,7 @@ The commands are listed below.
|
|||||||
|
|
||||||
Events can be removed or cleared with the following commands.
|
Events can be removed or cleared with the following commands.
|
||||||
|
|
||||||
| Even Handler | use |
|
| Even Handler | Use |
|
||||||
| -------|---------|
|
| -------|---------|
|
||||||
|`[eventName, eventHandlerId] call ace_common_fnc_removeEventHandler` | will remove a specific event handler of the event name, using the ID returned from `ace_common_fnc_addEventHandler`.|
|
|`[eventName, eventHandlerId] call ace_common_fnc_removeEventHandler` | will remove a specific event handler of the event name, using the ID returned from `ace_common_fnc_addEventHandler`.|
|
||||||
|`[eventName] call ace_common_fnc_removeAllEventHandlers` | will remove all event handlers for that type of event.|
|
|`[eventName] call ace_common_fnc_removeAllEventHandlers` | will remove all event handlers for that type of event.|
|
||||||
@ -243,7 +243,7 @@ if(HASH_HASKEY(_hash, "key")) then {
|
|||||||
|
|
||||||
A description of the above macros is below.
|
A description of the above macros is below.
|
||||||
|
|
||||||
| Macro | use |
|
| Macro | Use |
|
||||||
| -------|---------|
|
| -------|---------|
|
||||||
|`HASHCREATE` | used to create an empty hash.|
|
|`HASHCREATE` | used to create an empty hash.|
|
||||||
| `HASH_SET(hash, key, val)` | will set the hash key to that value, a key can be anything, even objects. |
|
| `HASH_SET(hash, key, val)` | will set the hash key to that value, a key can be anything, even objects. |
|
||||||
@ -285,7 +285,7 @@ HASH_SET(_anotherHash, "anotherKey", "another value");
|
|||||||
As you can see above working with hashlists are fairly simple, a more in depth explanation of the macros is below.
|
As you can see above working with hashlists are fairly simple, a more in depth explanation of the macros is below.
|
||||||
|
|
||||||
|
|
||||||
| Macro | use |
|
| Macro | Use |
|
||||||
| -------|---------|
|
| -------|---------|
|
||||||
|`HASHLIST_CREATELIST(keys)` | creates a new hashlist with the default keys, pass [] for no default keys.|
|
|`HASHLIST_CREATELIST(keys)` | creates a new hashlist with the default keys, pass [] for no default keys.|
|
||||||
|`HASHLIST_CREATEHASH(hashlist)` | returns a blank hash template from a hashlist.|
|
|`HASHLIST_CREATEHASH(hashlist)` | returns a blank hash template from a hashlist.|
|
||||||
|
Loading…
Reference in New Issue
Block a user