# HG changeset patch
# User Wuzzy
# Date 1460054380 -3600
# Node ID a7ddaecf54f3adc75a0a584bc754bdd5ba878576
# Parent 16f26a7c87d9e41ff3ecbcb19f9df12e86907c55
LuaAPI: Put onGameInit variables into neat table
diff -r 16f26a7c87d9 -r a7ddaecf54f3 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.
=== onGameInit() ===
-This function is called before the game loads its resources. One can modify various game variables here:
- * Seed = 0 - seed of the random number generator
- * !GameFlags - all !GameFlags combined as a bitmask. See [LuaAPI#GameFlags_functions] for easier manipulation of !GameFlags
- * Ready = 5000 - the ready timer at the start of the round (in milliseconds)
- * Delay = 0 - delay between each round in ms
- * !GetAwayTime = 100 set the retreat time in percent
- * !TurnTime = 60000 - set the turn time in ms
- * !CaseFreq = 0 - frequency of crate drops
- * !HealthCaseProb = 35 - chance of receiving a health crate
- * !HealthCaseAmount = 25 - amount of health in a health crate
- * !DamagePercent = 100 - percent of damage to inforce
- * !RopePercent = 100 - rope length in percent
- * !MinesNum = 0 - number of mines being placed (before 0.9.14 !LandAdds)
- * !MinesTime = 3000 - time for a mine to explode from activated (in milliseconds), -1000 for random
- * !MineDudPercent = 0 - chance of mine being a dud
- * Explosives = 0 - number of explosives being placed
- * !SuddenDeathTurns = 30 - turns until sudden death begins
- * !WaterRise = 47 - height of water rise at sudden death in pixels
- * !HealthDecrease = 5 - amount of health decreased on sudden death
- * Map = "Bamboo" - the map being played
- * Theme = "Bamboo" - the theme to be used
- * !MapGen - type of map generator. One of `mgRandom`, `mgMaze`, `mgPerlin`, `mgDrawn`.
- * Goals = "Jumping is disabled" - 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.
- * !TemplateFilter - _unknown meaning_
- * !TemplateNumber - _unknown meaning_
- * !MapFeatureSize - 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).
- * !ScreenWidth - width of the Hedgewars window
- * !ScreenHeight - 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.
=== onGameStart() ===
This function is called when the first round starts.