# HG changeset patch # User Wuzzy # Date 1535998112 -3600 # Node ID 94030dc69d1ea354a1ee8f36bdaafdb402dfc810 # Parent 9a4773488054051b54a3cca7e24b66cb0820f789 LuaAPI: Explain map variables that they are set when onGameStart is called diff -r 9a4773488054 -r 94030dc69d1e LuaAPI.wiki --- a/LuaAPI.wiki Mon Sep 03 18:54:06 2018 +0100 +++ b/LuaAPI.wiki Mon Sep 03 19:08:32 2018 +0100 @@ -76,12 +76,12 @@ Here are some unsorted variables or constants which are available in Lua. You shouldn’t write to most of them. || *Identifier* || *Description* || -|| `LAND_WIDTH` || The width of the landscape in pixels || -|| `LAND_HEIGHT` || The height of the landscape in pixels || || `LOCALE` || Current locale identifier (e.g. “de” for German) || -|| `LeftX` || X coordinate of the leftmost point of the landscape || -|| `RightX` || X coordinate of the rightmost point of the landscape || -|| `TopY` || Y coordinate of the topmost point of the landscape || +|| `LAND_WIDTH` || The width of the landscape in pixels. Not available before `onGameStart` || +|| `LAND_HEIGHT` || The height of the landscape in pixels. Not available before `onGameStart` || +|| `LeftX` || X coordinate of the leftmost point of the landscape. Not available before `onGameStart` || +|| `RightX` || X coordinate of the rightmost point of the landscape. Not available before `onGameStart` || +|| `TopY` || Y coordinate of the topmost point of the landscape. Not available before `onGameStart` || || `CursorX` || The X position of the cursor if the player is choosing a target. Otherwise, this is `-2147483648` || || `CursorY` || The Y position of the cursor if the player is choosing a target. Otherwise, this is `-2147483648` || || `WaterLine` || The y position of the water, used to determine at which position stuff drowns. Use `SetWaterLine` to change. || @@ -197,13 +197,13 @@ Can be used to show the mission and for more setup, for example initial target spawning. +At this stage, the global variables `LeftX`, `RightX`, `TopY`, `LAND_WIDTH` and `LAND_HEIGHT` become available. + === onPreviewInit() === 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. 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. -Note the variables `LeftX`, `RightX`, `TopY`, `LAND_WIDTH` and `LAND_HEIGHT` are *not* yet available at this stage! - === onParameters() === 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`.