102 Gears also have a lot of various values to track their position, state, etc. These can be accessed and written to with several “getter” and “setter” functions like `GetPos`, `GetHealth`, `SetTag`, etc. See [LuaAPI] for a full list. |
102 Gears also have a lot of various values to track their position, state, etc. These can be accessed and written to with several “getter” and “setter” functions like `GetPos`, `GetHealth`, `SetTag`, etc. See [LuaAPI] for a full list. |
103 In Hedgewars, the gear values and some variable names do not always really mean what they seem to be, their concrete meaning often depends on the actual gear type. For instance, using `GetHealth(h)` on a hedgehog gear (gear type: `gtHedgehog`) will return its health (obviously). Less obviously, using `GetHealth` on a flying saucer gear (gear type: `gtJetpack`) will return its amount of fuel. To learn all the gory detaily about all those gears, see [GearTypes. |
103 In Hedgewars, the gear values and some variable names do not always really mean what they seem to be, their concrete meaning often depends on the actual gear type. For instance, using `GetHealth(h)` on a hedgehog gear (gear type: `gtHedgehog`) will return its health (obviously). Less obviously, using `GetHealth` on a flying saucer gear (gear type: `gtJetpack`) will return its amount of fuel. To learn all the gory detaily about all those gears, see [GearTypes. |
104 |
104 |
105 == Other important event handlers == |
105 == Other important event handlers == |
106 |
106 |
107 The last very important event handlers are `onGameTick` and `onGameTick20`. `onGameTick` is called every game tick, that is every millisecond which is a thousand times a second. `onGameTick20` is called every 20 game ticks, that is, every 20 milliseconds. These functions are very important for specifying actions which need to happen regularily. It is important to know when to use `onGameTick`, and when to use `onGameTick20`. You can usually get away with just using `onGameTick` but must make sure any code inserted here must be efficient and fast, as this function is called very often. Complex code which takes more time to execute should go into `onGameTick20` instead. |
107 The last important event handlers are `onGameTick` and `onGameTick20`. `onGameTick` is called every game tick, that is every millisecond which is a thousand times a second. `onGameTick20` is called every 20 game ticks, that is, every 20 milliseconds. |
|
108 |
|
109 These functions are very important for specifying actions which need to happen regularily. It is important to know when to use `onGameTick`, and when to use `onGameTick20`. You can usually get away with just using `onGameTick` but must make sure any code inserted here must be efficient and fast, as this function is called very often. Complex code which takes more time to execute should go into `onGameTick20` instead. |
|
110 |
108 If you need a different interval other than 1 or 20 milliseconds, you can use modulo on the `GameTicks` variable which holds the total number of game ticks since the beginning of the game. |
111 If you need a different interval other than 1 or 20 milliseconds, you can use modulo on the `GameTicks` variable which holds the total number of game ticks since the beginning of the game. |
109 |
112 |
110 == Getting started … for real == |
113 == Getting started … for real == |
111 |
114 |
112 This was just a simplistic introduction which didn't cover everything. If you want to l |
115 This was just a simplistic introduction which didn't cover everything. If you want to l |