LuaAPI: Put onGameInit variables into neat table
authorWuzzy
Thu, 07 Apr 2016 19:39:40 +0100
changeset 860 a7ddaecf54f3
parent 859 16f26a7c87d9
child 861 ccbc115e68ad
LuaAPI: Put onGameInit variables into neat table
LuaAPI.wiki
--- a/LuaAPI.wiki	Wed Apr 06 17:59:36 2016 +0100
+++ b/LuaAPI.wiki	Thu Apr 07 19:39:40 2016 +0100
@@ -139,36 +139,40 @@
 Lua scripts are supposed to _define_ these functions to do something. The functions are then _called_ by Hedgewars when a certain even has occoured.
 
 === <tt>onGameInit()</tt> ===
-This function is called before the game loads its resources. One can modify various game variables here:
- * <tt>Seed = 0</tt> - seed of the random number generator
- * <tt>!GameFlags</tt> - all !GameFlags combined as a bitmask. See [LuaAPI#GameFlags_functions] for easier manipulation of !GameFlags
- * <tt>Ready = 5000</tt> - the ready timer at the start of the round (in milliseconds)
- * <tt>Delay = 0</tt> - delay between each round in ms
- * <tt>!GetAwayTime = 100</tt> set the retreat time in percent
- * <tt>!TurnTime = 60000</tt> - set the turn time in ms
- * <tt>!CaseFreq = 0</tt> - frequency of crate drops
- * <tt>!HealthCaseProb = 35</tt> - chance of receiving a health crate
- * <tt>!HealthCaseAmount = 25</tt> - amount of health in a health crate
- * <tt>!DamagePercent = 100</tt> - percent of damage to inforce
- * <tt>!RopePercent = 100</tt> - rope length in percent
- * <tt>!MinesNum = 0</tt> - number of mines being placed (before 0.9.14 !LandAdds)
- * <tt>!MinesTime = 3000</tt> - time for a mine to explode from activated (in milliseconds), -1000 for random
- * <tt>!MineDudPercent = 0</tt> - chance of mine being a dud
- * <tt>Explosives = 0</tt> - number of explosives being placed
- * <tt>!SuddenDeathTurns = 30</tt> - turns until sudden death begins
- * <tt>!WaterRise = 47</tt> - height of water rise at sudden death in pixels
- * <tt>!HealthDecrease = 5</tt> - amount of health decreased on sudden death
- * <tt>Map = "Bamboo"</tt> - the map being played
- * <tt>Theme = "Bamboo"</tt> - the theme to be used
- * <tt>!MapGen</tt> - type of map generator. One of `mgRandom`, `mgMaze`, `mgPerlin`, `mgDrawn`.
- * <tt>Goals = "Jumping is disabled"</tt> - Use this to add additional text to the goal text popup shown at the beginning and when using the quit or pause keys. The text is added to the default text which usually explains the game modifiers and does not replace it. Use `|` for line breaks. Also, all text before and including a `:` in a line will be highlighted. See also !ShowMission.
- * <tt>!TemplateFilter</tt> - _unknown meaning_
- * <tt>!TemplateNumber</tt> - _unknown meaning_
- * <tt>!MapFeatureSize</tt> - Used by random maps to determine its “curvyness” or complexity. This value can be set by the user with the slider under the random map preview in the game setup screen. The user-set value ranges from 1 (leftmost position) to 25 (rightmost position).
- * <tt>!ScreenWidth</tt> - width of the Hedgewars window
- * <tt>!ScreenHeight</tt> - heigtht of the Hedgewars window
+This function is called before the game loads its resources. One can read and modify various game variables here. These variables will become globally available after `onGameInit` has been invoked, but changing them has only an effect in `onGameInit`.
+Most variables are optional, but for missions, `Theme` must be set by the scripter if you want to use a random map, rather than an image map. All other variables do not need to be set by the scripter and have default values.
 
-If you want to add teams or hogs manually you have to do it here. If you want to draw your own map using `AddPoint` and `FlushPoints`, you have to do this within this function as well.
+List of game variables:
+|| *Variable name* || *Default* || *Description ||
+|| `Theme` || _depends_ || The theme to be used. When `Map` is set, a default value is used. For missions which don't use an image map, `Theme` *must* be set explicitly ||
+|| `Map` || `""` || The image map being played or `""` if no image map is used ||
+|| `Seed` || `0` || Seed of the random number generator ||
+|| `MapGen` || `mgRandom` || Type of map generator. One of `mgRandom`, `mgMaze`, `mgPerlin`, `mgDrawn`. ||
+|| `TemplateFilter` || `0` || _unknown meaning_ ||
+|| `TemplateNumber` || `0` || _unknown meaning_ ||
+|| `MapFeatureSize` || `50` || Used by random maps to determine its “curvyness” or complexity. This value can be set by the user with the slider under the random map preview in the game setup screen. The user-set value ranges from 1 (leftmost position) to 25 (rightmost position). ||
+|| `GameFlags` || `0` || All `GameFlags` combined as a bitmask. See [LuaAPI#GameFlags_functions] for easier manipulation of `GameFlags` ||
+|| `Ready` || `5000` || Ready timer at the start of the turn (in milliseconds) ||
+|| `Delay` || `100` || Delay between each turn in milliseconds ||
+|| `TurnTime` || `45000` || Turn time in milliseconds ||
+|| `GetAwayTime` || `100` || Retreat time in percent ||
+|| `CaseFreq` || `5` || Probability that a crate drops in a turn. 0: never, >0: probability = `1/CaseFreq` ||
+|| `HealthCaseProb` || `35` || Chance that a crate drop is a health crate, in percent (other crates are ammo or utility crates) ||
+|| `HealthCaseAmount` || `25` || Amount of health in a health crate ||
+|| `DamagePercent` || `100` || Global damage in percent, affects damage and knockback ||
+|| `RopePercent` || `100` || Rope length in percent ||
+|| `MinesNum` || `4` || Number of mines being placed on a medium-sized map ||
+|| `MinesTime` || `3000` || Time for a mine to explode from activated (in milliseconds), `-1000` for random ||
+|| `MineDudPercent` || `0` || Chance of mine being a dud, in percent ||
+|| `Explosives` || `2` || Number of barrels being placed on a medium-sized map ||
+|| `SuddenDeathTurns` || `15` || Turns until Sudden Death begins ||
+|| `WaterRise` || `47` || Height of water rise each turn in Sudden Death, in pixels ||
+|| `HealthDecrease || `5` || Amount of health decreased on each turn in Sudden Death ||
+|| `Goals` || `""` || Use this to add additional text to the goal text popup shown at the beginning and when using the quit or pause keys. The text is added to the default text which usually explains the game modifiers and does not replace it. Use `|` for line breaks. Also, all text before and including a `:` in a line will be highlighted. See also `ShowMission`. ||
+|| `ScreenWidth` || _N/A_ || Width of the Hedgewars window or screen ||
+|| `ScreenHeigth` || _N/A_ || Heigth of the Hedgewars window or screen ||
+
+If you want to add teams or hogs manually, you have to do it here. If you want to draw your own map using `AddPoint` and `FlushPoints`, you have to do this within this function as well.
 
 === <tt>onGameStart()</tt> ===
 This function is called when the first round starts.