74 |
74 |
75 === General variables and constants === |
75 === General variables and constants === |
76 Here are some unsorted variables or constants which are available in Lua. You shouldn’t write to most of them. |
76 Here are some unsorted variables or constants which are available in Lua. You shouldn’t write to most of them. |
77 |
77 |
78 || *Identifier* || *Description* || |
78 || *Identifier* || *Description* || |
79 || `LAND_WIDTH` || The width of the landscape in pixels || |
|
80 || `LAND_HEIGHT` || The height of the landscape in pixels || |
|
81 || `LOCALE` || Current locale identifier (e.g. “de” for German) || |
79 || `LOCALE` || Current locale identifier (e.g. “de” for German) || |
82 || `LeftX` || X coordinate of the leftmost point of the landscape || |
80 || `LAND_WIDTH` || The width of the landscape in pixels. Not available before `onGameStart` || |
83 || `RightX` || X coordinate of the rightmost point of the landscape || |
81 || `LAND_HEIGHT` || The height of the landscape in pixels. Not available before `onGameStart` || |
84 || `TopY` || Y coordinate of the topmost point of the landscape || |
82 || `LeftX` || X coordinate of the leftmost point of the landscape. Not available before `onGameStart` || |
|
83 || `RightX` || X coordinate of the rightmost point of the landscape. Not available before `onGameStart` || |
|
84 || `TopY` || Y coordinate of the topmost point of the landscape. Not available before `onGameStart` || |
85 || `CursorX` || The X position of the cursor if the player is choosing a target. Otherwise, this is `-2147483648` || |
85 || `CursorX` || The X position of the cursor if the player is choosing a target. Otherwise, this is `-2147483648` || |
86 || `CursorY` || The Y position of the cursor if the player is choosing a target. Otherwise, this is `-2147483648` || |
86 || `CursorY` || The Y position of the cursor if the player is choosing a target. Otherwise, this is `-2147483648` || |
87 || `WaterLine` || The y position of the water, used to determine at which position stuff drowns. Use `SetWaterLine` to change. || |
87 || `WaterLine` || The y position of the water, used to determine at which position stuff drowns. Use `SetWaterLine` to change. || |
88 || `ClansCount` || Number of clans, including defeated ones (a clan is a group of teams with same color) || |
88 || `ClansCount` || Number of clans, including defeated ones (a clan is a group of teams with same color) || |
89 || `TeamsCount` || Number of teams, including defeated ones || |
89 || `TeamsCount` || Number of teams, including defeated ones || |
195 === <tt>onGameStart()</tt> === |
195 === <tt>onGameStart()</tt> === |
196 This function is called when the first round starts. |
196 This function is called when the first round starts. |
197 |
197 |
198 Can be used to show the mission and for more setup, for example initial target spawning. |
198 Can be used to show the mission and for more setup, for example initial target spawning. |
199 |
199 |
|
200 At this stage, the global variables `LeftX`, `RightX`, `TopY`, `LAND_WIDTH` and `LAND_HEIGHT` become available. |
|
201 |
200 === <tt>onPreviewInit()</tt> === |
202 === <tt>onPreviewInit()</tt> === |
201 This function is called when the map preview in the frontend is initialized. This happens when the script is selected or you change a map generator parameter. |
203 This function is called when the map preview in the frontend is initialized. This happens when the script is selected or you change a map generator parameter. |
202 |
204 |
203 It is useful for scripts which create their own maps (see `AddPoint` and `FlushPoints`). If you create a map in this function, a preview will be generated from this map and is exposed to the frontend. |
205 It is useful for scripts which create their own maps (see `AddPoint` and `FlushPoints`). If you create a map in this function, a preview will be generated from this map and is exposed to the frontend. |
204 |
|
205 Note the variables `LeftX`, `RightX`, `TopY`, `LAND_WIDTH` and `LAND_HEIGHT` are *not* yet available at this stage! |
|
206 |
206 |
207 === <tt>onParameters()</tt> === |
207 === <tt>onParameters()</tt> === |
208 This function is called when the script parameters (as specified in the game scheme) become available. The script parameter string is stored in the global variable `ScriptParam`. |
208 This function is called when the script parameters (as specified in the game scheme) become available. The script parameter string is stored in the global variable `ScriptParam`. |
209 |
209 |
210 Please note that it is normally not safe to call many of the other functions inside this function, this function is called very early in the game, only use this to initialize variables and other internal stuff like that. |
210 Please note that it is normally not safe to call many of the other functions inside this function, this function is called very early in the game, only use this to initialize variables and other internal stuff like that. |