138 == Event handlers == |
138 == Event handlers == |
139 Lua scripts are supposed to _define_ these functions to do something. The functions are then _called_ by Hedgewars when a certain even has occoured. |
139 Lua scripts are supposed to _define_ these functions to do something. The functions are then _called_ by Hedgewars when a certain even has occoured. |
140 |
140 |
141 === <tt>onGameInit()</tt> === |
141 === <tt>onGameInit()</tt> === |
142 This function is called before the game loads its resources. One can modify various game variables here: |
142 This function is called before the game loads its resources. One can modify various game variables here: |
143 * <tt>Seed = 0</tt> - sets the seed of the random number generator |
143 * <tt>Seed = 0</tt> - seed of the random number generator |
144 * <tt>!GameFlags</tt> - all !GameFlags combined as a bitmask. See [LuaAPI#GameFlags_functions] for easier manipulation of !GameFlags |
144 * <tt>!GameFlags</tt> - all !GameFlags combined as a bitmask. See [LuaAPI#GameFlags_functions] for easier manipulation of !GameFlags |
145 * <tt>Ready = 5000</tt> - the ready timer at the start of the round (in milliseconds) |
145 * <tt>Ready = 5000</tt> - the ready timer at the start of the round (in milliseconds) |
146 * <tt>Delay = 0</tt> - delay between each round in ms |
146 * <tt>Delay = 0</tt> - delay between each round in ms |
147 * <tt>!GetAwayTime = 100</tt> set the retreat time in percent |
147 * <tt>!GetAwayTime = 100</tt> set the retreat time in percent |
148 * <tt>!TurnTime = 60000</tt> - set the turn time in ms |
148 * <tt>!TurnTime = 60000</tt> - set the turn time in ms |
149 * <tt>!CaseFreq = 0</tt> - frequency of crate drops |
149 * <tt>!CaseFreq = 0</tt> - frequency of crate drops |
150 * <tt>!HealthCaseProb = 35</tt> - chance of receiving a health crate |
150 * <tt>!HealthCaseProb = 35</tt> - chance of receiving a health crate |
151 * <tt>!HealthCaseAmount = 25</tt> - amount of health in a health crate |
151 * <tt>!HealthCaseAmount = 25</tt> - amount of health in a health crate |
152 * <tt>!DamagePercent = 100</tt> - percent of damage to inforce |
152 * <tt>!DamagePercent = 100</tt> - percent of damage to inforce |
|
153 * <tt>!RopePercent = 100</tt> - rope length in percent |
153 * <tt>!MinesNum = 0</tt> - number of mines being placed (before 0.9.14 !LandAdds) |
154 * <tt>!MinesNum = 0</tt> - number of mines being placed (before 0.9.14 !LandAdds) |
154 * <tt>!MinesTime = 3000</tt> - time for a mine to explode from activated (in milliseconds), -1000 for random |
155 * <tt>!MinesTime = 3000</tt> - time for a mine to explode from activated (in milliseconds), -1000 for random |
155 * <tt>!MineDudPercent = 0</tt> - chance of mine being a dud |
156 * <tt>!MineDudPercent = 0</tt> - chance of mine being a dud |
156 * <tt>Explosives = 0</tt> - number of explosives being placed |
157 * <tt>Explosives = 0</tt> - number of explosives being placed |
157 * <tt>!SuddenDeathTurns = 30</tt> - turns until sudden death begins |
158 * <tt>!SuddenDeathTurns = 30</tt> - turns until sudden death begins |
162 * <tt>!MapGen</tt> - type of map generator. One of `mgRandom`, `mgMaze`, `mgPerlin`, `mgDrawn`. |
163 * <tt>!MapGen</tt> - type of map generator. One of `mgRandom`, `mgMaze`, `mgPerlin`, `mgDrawn`. |
163 * <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. |
164 * <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. |
164 * <tt>!TemplateFilter</tt> - _unknown meaning_ |
165 * <tt>!TemplateFilter</tt> - _unknown meaning_ |
165 * <tt>!TemplateNumber</tt> - _unknown meaning_ |
166 * <tt>!TemplateNumber</tt> - _unknown meaning_ |
166 * <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). |
167 * <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). |
|
168 * <tt>!ScreenWidth</tt> - width of the Hedgewars window |
|
169 * <tt>!ScreenHeight</tt> - heigtht of the Hedgewars window |
167 |
170 |
168 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. |
171 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. |
169 |
172 |
170 === <tt>onGameStart()</tt> === |
173 === <tt>onGameStart()</tt> === |
171 This function is called when the first round starts. |
174 This function is called when the first round starts. |