LuaGuide.wiki
changeset 899 011ca6031678
parent 898 159bbbd0ab0a
child 900 f8887a49ad91
equal deleted inserted replaced
898:159bbbd0ab0a 899:011ca6031678
    97 
    97 
    98 The hogs are gears, too and when you shoot with bazooka the bazooka shell will be created and explode when it hits the ground. When the shell is created the `onGearAdd` event is called and the `gear` parameter will be the bazooka.
    98 The hogs are gears, too and when you shoot with bazooka the bazooka shell will be created and explode when it hits the ground. When the shell is created the `onGearAdd` event is called and the `gear` parameter will be the bazooka.
    99 And when it hits the ground, before the gear has been deleted, `onGearDelete` is invoked with the shell as parameter, after that it is removed.
    99 And when it hits the ground, before the gear has been deleted, `onGearDelete` is invoked with the shell as parameter, after that it is removed.
   100 
   100 
   101 Each gear has a [GearTypes gear type], for instance, a bazooka shell has the gear type of `gtShell`, a grenade has a gear type of `gtGrenade`, and so on. You will almost always need to check for the gear type with `GetGearType` in the `onGearAdd` function in order to do anything meaningful.
   101 Each gear has a [GearTypes gear type], for instance, a bazooka shell has the gear type of `gtShell`, a grenade has a gear type of `gtGrenade`, and so on. You will almost always need to check for the gear type with `GetGearType` in the `onGearAdd` function in order to do anything meaningful.
   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 
   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 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. 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.
       
   104 
       
   105 To learn all the gory detaily about gears, see [GearTypes].
   104 
   106 
   105 == Other important event handlers ==
   107 == Other important event handlers ==
   106 
   108 
   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.
   109 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 
   110