Animation-LuaCallins: Difference between revisions
weapon stuff |
removed unitID, changed notices for MoveRate/setSFXOccupy |
||
| Line 15: | Line 15: | ||
== Generic == | == Generic == | ||
'''Create''' ( | '''Create''' ( ) -> nil | ||
This is called just after the unit script has been created. | This is called just after the unit script has been created. | ||
'''StartMoving''' ( | '''StartMoving''' ( ) -> nil<br> | ||
'''StopMoving''' ( | '''StopMoving''' ( ) -> nil | ||
These are called whenever the unit starts or stops moving. Typical use for them is to trigger wheels to start spinning, animate treads, or start/stop a walking animation. | These are called whenever the unit starts or stops moving. Typical use for them is to trigger wheels to start spinning, animate treads, or start/stop a walking animation. | ||
'''Killed''' ( | '''Killed''' ( number recentDamage, number maxHealth ) -> number corpseType | ||
This is called when the unit is killed. The severity of the kill may be calculated as severity=recentDamage/maxHealth. Typically, this function would play a death animation for the unit, and finally return a corpse type. | This is called when the unit is killed. The severity of the kill may be calculated as severity=recentDamage/maxHealth. Typically, this function would play a death animation for the unit, and finally return a corpse type. | ||
'''WindChanged''' ( | '''WindChanged''' ( number heading, number strength ) -> nil | ||
This is called for wind generators whenever the wind direction or strength changes. | This is called for wind generators whenever the wind direction or strength changes. | ||
'''ExtractionRateChanged''' ( | '''ExtractionRateChanged''' ( number rate ) -> nil | ||
Called for metal extractors each time their extraction rate (metal per second) changes. | Called for metal extractors each time their extraction rate (metal per second) changes. | ||
| Line 43: | Line 43: | ||
'''setSFXoccupy''' ( number curTerrainType ) -> nil | '''setSFXoccupy''' ( number curTerrainType ) -> nil | ||
Called when terrain type changes. Terrain type is calculated with the following rules (in this order): | |||
* If unit is being transported -> curTerrainType = 0 | * If unit is being transported -> curTerrainType = 0 | ||
| Line 53: | Line 53: | ||
Where is curTerrainType = 3 ? :-) | Where is curTerrainType = 3 ? :-) | ||
Candidate to be changed to something saner later on. | |||
'''MoveRate0''' ( | |||
'''MoveRate1''' ( | '''MoveRate0''' ( ) -> nil<br> | ||
'''MoveRate2''' ( | '''MoveRate1''' ( ) -> nil<br> | ||
'''MoveRate3''' ( | '''MoveRate2''' ( ) -> nil<br> | ||
'''MoveRate3''' ( ) -> nil | |||
Another pointless set of call-ins. I'll probably remove this from Spring at some point. Called only for certain types of aircraft (those which use ''CTAAirMoveType''.) The move rate is determined by the following rules (in this order): | Another pointless set of call-ins. I'll probably remove this from Spring at some point. Called only for certain types of aircraft (those which use ''CTAAirMoveType''.) The move rate is determined by the following rules (in this order): | ||
| Line 65: | Line 67: | ||
It follows from this that MoveRate3 is not even called, ever. | It follows from this that MoveRate3 is not even called, ever. | ||
Candidate to be changed to something saner later on. | |||
'''QueryLandingPad''' ( | '''QueryLandingPad''' ( ) -> { number piece1, number piece2, ... } | ||
Called one time for units with landing pads. Should return a table with pieces which should be used as landing pads. The number of pieces returned also determines the number of pads, so for Lua unit scripts there is no QueryLandingPadCount. | Called one time for units with landing pads. Should return a table with pieces which should be used as landing pads. The number of pieces returned also determines the number of pads, so for Lua unit scripts there is no QueryLandingPadCount. | ||
'''Activate''' ( | '''Activate''' ( ) -> nil<br> | ||
'''Deactivate''' ( | '''Deactivate''' ( ) -> nil | ||
Exact situation these are called depends a lot on the unit type. Factories are activated when they open their yard and deactivated when they close it. Aircraft are activated when they take off and deactivated when the land. Any unit that can be turned on or off is activated when it's turned on and deactivated when it's turned off. On ''SetUnitValue(COB.ACTIVATION, ...)'' one of these call-ins may be called too. | Exact situation these are called depends a lot on the unit type. Factories are activated when they open their yard and deactivated when they close it. Aircraft are activated when they take off and deactivated when the land. Any unit that can be turned on or off is activated when it's turned on and deactivated when it's turned off. On ''SetUnitValue(COB.ACTIVATION, ...)'' one of these call-ins may be called too. | ||
| Line 81: | Line 85: | ||
Weapon functions come in two variants. | Weapon functions come in two variants. | ||
* Separate function with numeric weapon number suffix. (e.g. ''AimWeapon'''1'''( | * Separate function with numeric weapon number suffix. (e.g. ''AimWeapon'''1'''(heading, pitch)'') | ||
* Combined function which gets weapon number as second argument. (e.g. ''AimWeapon( | * Combined function which gets weapon number as second argument. (e.g. ''AimWeapon(weaponNum, heading, pitch)'') | ||
Only the first variant is listed here, so whenever you see a function whose name ends with a numeric one ("1"), you should either replace it with the actual weapon number, or you can write a single combined function that takes a ''weaponNum'' argument. For each script, all functions should use the same variant. Either all using name suffix, or all using combined functions. | Only the first variant is listed here, so whenever you see a function whose name ends with a numeric one ("1"), you should either replace it with the actual weapon number, or you can write a single combined function that takes a ''weaponNum'' argument. For each script, all functions should use the same variant. Either all using name suffix, or all using combined functions. | ||
'''QueryWeapon1''' ( | '''QueryWeapon1''' ( ) -> number piece<br> | ||
'''AimFromWeapon1''' ( | '''AimFromWeapon1''' ( ) -> number piece<br> | ||
'''AimWeapon1''' ( | '''AimWeapon1''' ( heading, pitch ) -> boolean<br> | ||
'''AimShield1''' ( | '''AimShield1''' ( ) -> boolean | ||
Weapon support. The return value of QueryWeapon and AimFromWeapon determines the pieces which will be used for aiming: typically e.g. the barrel for QueryWeapon and the turret for AimFromWeapon. AimWeapon is then called to allow the script to turn the weapons in the target direction, which is passed as the heading and pitch argument (in radians). Only if AimWeapon returns true, the weapon is actually fired. | Weapon support. The return value of QueryWeapon and AimFromWeapon determines the pieces which will be used for aiming: typically e.g. the barrel for QueryWeapon and the turret for AimFromWeapon. AimWeapon is then called to allow the script to turn the weapons in the target direction, which is passed as the heading and pitch argument (in radians). Only if AimWeapon returns true, the weapon is actually fired. | ||
| Line 97: | Line 101: | ||
'''FireWeapon1''' ( | '''FireWeapon1''' ( ) -> nil<br> | ||
'''Shot1''' ( | '''Shot1''' ( ) -> nil<br> | ||
'''EndBurst1''' ( | '''EndBurst1''' ( ) -> nil | ||
If after aiming the unit actually fires it's weapon, FireWeapon is called once at the beginning of the salvo. Shot is called just before each projectile is fired. RockUnit (see below) is called just after all projectiles for that frame have been fired. At the end of the salvo, EndBurst is called. | If after aiming the unit actually fires it's weapon, FireWeapon is called once at the beginning of the salvo. Shot is called just before each projectile is fired. RockUnit (see below) is called just after all projectiles for that frame have been fired. At the end of the salvo, EndBurst is called. | ||
| Line 106: | Line 110: | ||
'''BlockShot1''' ( | '''BlockShot1''' ( targetUnitID, boolean userTarget ) -> boolean | ||
Allows you to block a weapon from shooting. TargetUnitID may be nil: in this case the unit has a ground-attack order. | Allows you to block a weapon from shooting. TargetUnitID may be nil: in this case the unit has a ground-attack order. | ||
'''TargetWeight1''' ( | '''TargetWeight1''' ( targetUnitID ) -> number | ||
Allows you to tweak the priority of the target for this particular weapon. The target priority is multiplied by the return value of this function. Lower priority targets are targetted first, so return a value smaller than 1 to prioritize a target, or return a value larger than 1 to avoid a target. | Allows you to tweak the priority of the target for this particular weapon. The target priority is multiplied by the return value of this function. Lower priority targets are targetted first, so return a value smaller than 1 to prioritize a target, or return a value larger than 1 to avoid a target. | ||
| Line 118: | Line 122: | ||
'''RockUnit''' ( | '''RockUnit''' ( x, z ) -> nil | ||
A bit like the weapon-specific FireWeapon function, although this is called after any weapon fires. As argument it gets a two dimensional vector in the direction the unit just fired. This may be used to “rock†the unit as a whole a bit as part of the firing animation. Note though that this vector is in world space, so for a truely realistic rock direction it needs to be rotated according to the unit's current heading. | A bit like the weapon-specific FireWeapon function, although this is called after any weapon fires. As argument it gets a two dimensional vector in the direction the unit just fired. This may be used to “rock†the unit as a whole a bit as part of the firing animation. Note though that this vector is in world space, so for a truely realistic rock direction it needs to be rotated according to the unit's current heading. | ||
'''HitByWeapon''' ( | '''HitByWeapon''' ( x, z ) -> nil | ||
'''HitByWeaponId''' ( | '''HitByWeaponId''' ( x, z, weaponDefID, damage ) -> nil | number newDamage | ||
These are called if a unit has been hit by a weapon. (x, z) is the direction from which the projectile came in world space (the reverse direction of the impulse, to be exact.) | These are called if a unit has been hit by a weapon. (x, z) is the direction from which the projectile came in world space (the reverse direction of the impulse, to be exact.) | ||
| Line 135: | Line 139: | ||
== Builders and factories == | == Builders and factories == | ||
'''StartBuilding''' ( | '''StartBuilding''' ( heading, pitch ) -> nil<br> | ||
'''StartBuilding''' ( | '''StartBuilding''' ( ) -> nil<br> | ||
'''StopBuilding''' ( | '''StopBuilding''' ( ) -> nil | ||
These notify the script when a builder or factory starts or stops building. | These notify the script when a builder or factory starts or stops building. | ||
| Line 144: | Line 148: | ||
'''QueryBuildInfo''' ( | '''QueryBuildInfo''' ( ) -> number piece | ||
For factories only. Should return the piece to which the unit which is going to be build will be attached while it's being build. | For factories only. Should return the piece to which the unit which is going to be build will be attached while it's being build. | ||
'''QueryNanopiece''' ( | '''QueryNanopiece''' ( ) -> number piece | ||
Called each time a nano particle is to be created. Should return the piece at which the particle will be spawned. This may be used to iterate through a few pieces, to simulate the factory/builder having multiple nanolathes. | Called each time a nano particle is to be created. Should return the piece at which the particle will be spawned. This may be used to iterate through a few pieces, to simulate the factory/builder having multiple nanolathes. | ||
| Line 193: | Line 197: | ||
=== Air transports === | === Air transports === | ||
'''BeginTransport''' ( | '''BeginTransport''' ( passengerID ) -> nil<br> | ||
'''QueryTransport''' ( | '''QueryTransport''' ( passengerID ) -> number piece | ||
For an air transport, if any one unit is picked up, these two are called in succession and the passenger is attached to the piece returned by the second one. | For an air transport, if any one unit is picked up, these two are called in succession and the passenger is attached to the piece returned by the second one. | ||
'''StartUnload''' ( | '''StartUnload''' ( ) -> nil | ||
Only called in UnloadLandFlood behavior. Signals the start of an unload cycle. | Only called in UnloadLandFlood behavior. Signals the start of an unload cycle. | ||
'''TransportDrop''' ( | '''TransportDrop''' ( passengerID, x, y, z ) -> nil | ||
Only called in UnloadLandFlood behavior. Called when a passenger will be unloaded. Contrary to ground transports, Spring will detach the passenger after the call. | Only called in UnloadLandFlood behavior. Called when a passenger will be unloaded. Contrary to ground transports, Spring will detach the passenger after the call. | ||
'''EndTransport''' ( | '''EndTransport''' ( ) -> nil | ||
In UnloadLand and UnloadLandFlood behaviors, these are called one time after all units are unloaded. (The transport is empty.) For the UnloadDrop behavior, this is called for every unit that is unloaded. | In UnloadLand and UnloadLandFlood behaviors, these are called one time after all units are unloaded. (The transport is empty.) For the UnloadDrop behavior, this is called for every unit that is unloaded. | ||
| Line 216: | Line 220: | ||
=== Ground transports === | === Ground transports === | ||
'''TransportPickup''' ( | '''TransportPickup''' ( passengerID ) -> nil | ||
Called when a passenger should be loaded into the transport. This should eventually call AttachUnit to actually attach the unit. Assuming the transport is in range of the next passenger, this will be called again for the next passenger 16 frames later, ''unless'' the script enters the BUSY state: then Spring will not move on to the next passenger until the script leaves the BUSY state. | Called when a passenger should be loaded into the transport. This should eventually call AttachUnit to actually attach the unit. Assuming the transport is in range of the next passenger, this will be called again for the next passenger 16 frames later, ''unless'' the script enters the BUSY state: then Spring will not move on to the next passenger until the script leaves the BUSY state. | ||
'''TransportDrop''' ( | '''TransportDrop''' ( passengerID, x, y, z ) -> nil | ||
Called when a passenger should be unloaded. This should eventually call DetachUnit to actually detach the unit, ''unless'' the used unload method is UnloadLandFlood, in which case Spring will actually detach the unit after the call. | Called when a passenger should be unloaded. This should eventually call DetachUnit to actually detach the unit, ''unless'' the used unload method is UnloadLandFlood, in which case Spring will actually detach the unit after the call. | ||
'''EndTransport''' ( | '''EndTransport''' ( ) -> nil | ||
Only called in UnloadLandFlood behavior, after the last unit has been unloaded. | Only called in UnloadLandFlood behavior, after the last unit has been unloaded. | ||
| Line 233: | Line 237: | ||
=== Passenger === | === Passenger === | ||
'''Falling''' ( | '''Falling''' ( ) -> nil | ||
For a unit dropped from an UnloadDrop transport, this is called every frame to inform the script the unit is still falling. It may be used to show a parachute for example. | For a unit dropped from an UnloadDrop transport, this is called every frame to inform the script the unit is still falling. It may be used to show a parachute for example. | ||
'''Landed''' ( | '''Landed''' ( ) -> nil | ||
This is called one time after the unit reached the ground. May be used to hide a parachute for example. | This is called one time after the unit reached the ground. May be used to hide a parachute for example. | ||
| Line 248: | Line 252: | ||
'''MoveFinished''' ( | '''MoveFinished''' ( piece, axis ) -> nil<br> | ||
'''TurnFinished''' ( | '''TurnFinished''' ( piece, axis ) -> nil | ||
Called when a move or turn finished. The framework gadget uses this to resume the coroutines which are waiting for the particular move or turn to be finished. | Called when a move or turn finished. The framework gadget uses this to resume the coroutines which are waiting for the particular move or turn to be finished. | ||
'''Destroy''' ( | '''Destroy''' ( ) -> nil | ||
Called right before the unit's script is destroyed. This may happen if the unit is being destroyed, but also if the unit's script is being replaced by another script. The framework gadget uses this to stop all threads and remove the unit from some internal data structures. | Called right before the unit's script is destroyed. This may happen if the unit is being destroyed, but also if the unit's script is being replaced by another script. The framework gadget uses this to stop all threads and remove the unit from some internal data structures. | ||
Revision as of 13:11, 13 September 2009
Introduction
Call-ins are calls from the engine, into the unit script. In other words, these functions are called, if they are defined, when a particular “event†happens.
For Lua unit scripts, a new callin mechanism has been implemented, which is faster than the regular callin mechanism which is used for widgets and gadgets.
Types for arguments are only shown where they're ambiguous. For a number of (common) arguments, the types are:
- unitID: number
- piece: number
- axis: number (1 = x axis, 2 = y axis, 3 = z axis)
- heading/pitch: number (radians)
Generic
Create ( ) -> nil
This is called just after the unit script has been created.
StartMoving ( ) -> nil
StopMoving ( ) -> nil
These are called whenever the unit starts or stops moving. Typical use for them is to trigger wheels to start spinning, animate treads, or start/stop a walking animation.
Killed ( number recentDamage, number maxHealth ) -> number corpseType
This is called when the unit is killed. The severity of the kill may be calculated as severity=recentDamage/maxHealth. Typically, this function would play a death animation for the unit, and finally return a corpse type.
WindChanged ( number heading, number strength ) -> nil
This is called for wind generators whenever the wind direction or strength changes.
ExtractionRateChanged ( number rate ) -> nil
Called for metal extractors each time their extraction rate (metal per second) changes.
setSFXoccupy ( number curTerrainType ) -> nil
Called when terrain type changes. Terrain type is calculated with the following rules (in this order):
- If unit is being transported -> curTerrainType = 0
- If ground height < -5 and unit is always upright -> curTerrainType = 2
- If ground height < -5 and unit is not always upright -> curTerrainType = 1
- If ground height < 0 and unit is always upright -> curTerrainType = 1
- Otherwise -> curTerrainType = 4
Where is curTerrainType = 3 ? :-)
Candidate to be changed to something saner later on.
MoveRate0 ( ) -> nil
MoveRate1 ( ) -> nil
MoveRate2 ( ) -> nil
MoveRate3 ( ) -> nil
Another pointless set of call-ins. I'll probably remove this from Spring at some point. Called only for certain types of aircraft (those which use CTAAirMoveType.) The move rate is determined by the following rules (in this order):
- If the aircraft is landing or taking off -> curRate = 1
- Otherwise -> curRate = floor(curSpeed / maxSpeed * 3), clamped to be in the range [0, 2]
It follows from this that MoveRate3 is not even called, ever.
Candidate to be changed to something saner later on.
QueryLandingPad ( ) -> { number piece1, number piece2, ... }
Called one time for units with landing pads. Should return a table with pieces which should be used as landing pads. The number of pieces returned also determines the number of pads, so for Lua unit scripts there is no QueryLandingPadCount.
Activate ( ) -> nil
Deactivate ( ) -> nil
Exact situation these are called depends a lot on the unit type. Factories are activated when they open their yard and deactivated when they close it. Aircraft are activated when they take off and deactivated when the land. Any unit that can be turned on or off is activated when it's turned on and deactivated when it's turned off. On SetUnitValue(COB.ACTIVATION, ...) one of these call-ins may be called too.
Weapons
Weapon functions come in two variants.
- Separate function with numeric weapon number suffix. (e.g. AimWeapon1(heading, pitch))
- Combined function which gets weapon number as second argument. (e.g. AimWeapon(weaponNum, heading, pitch))
Only the first variant is listed here, so whenever you see a function whose name ends with a numeric one ("1"), you should either replace it with the actual weapon number, or you can write a single combined function that takes a weaponNum argument. For each script, all functions should use the same variant. Either all using name suffix, or all using combined functions.
QueryWeapon1 ( ) -> number piece
AimFromWeapon1 ( ) -> number piece
AimWeapon1 ( heading, pitch ) -> boolean
AimShield1 ( ) -> boolean
Weapon support. The return value of QueryWeapon and AimFromWeapon determines the pieces which will be used for aiming: typically e.g. the barrel for QueryWeapon and the turret for AimFromWeapon. AimWeapon is then called to allow the script to turn the weapons in the target direction, which is passed as the heading and pitch argument (in radians). Only if AimWeapon returns true, the weapon is actually fired.
TODO: better explanation (?), note about AimWeapon being called very often etc.
FireWeapon1 ( ) -> nil
Shot1 ( ) -> nil
EndBurst1 ( ) -> nil
If after aiming the unit actually fires it's weapon, FireWeapon is called once at the beginning of the salvo. Shot is called just before each projectile is fired. RockUnit (see below) is called just after all projectiles for that frame have been fired. At the end of the salvo, EndBurst is called.
Of these call-ins, FireWeapon is the more generic one and Shot and EndBurst are more specialized. FireWeapon is usually used to play a recoil animation or emit some smoke near the weapon's barrel using EmitSfx.
BlockShot1 ( targetUnitID, boolean userTarget ) -> boolean
Allows you to block a weapon from shooting. TargetUnitID may be nil: in this case the unit has a ground-attack order.
TargetWeight1 ( targetUnitID ) -> number
Allows you to tweak the priority of the target for this particular weapon. The target priority is multiplied by the return value of this function. Lower priority targets are targetted first, so return a value smaller than 1 to prioritize a target, or return a value larger than 1 to avoid a target.
The exact behavior of specific values shouldn't be relied upon.
RockUnit ( x, z ) -> nil
A bit like the weapon-specific FireWeapon function, although this is called after any weapon fires. As argument it gets a two dimensional vector in the direction the unit just fired. This may be used to “rock†the unit as a whole a bit as part of the firing animation. Note though that this vector is in world space, so for a truely realistic rock direction it needs to be rotated according to the unit's current heading.
HitByWeapon ( x, z ) -> nil
HitByWeaponId ( x, z, weaponDefID, damage ) -> nil | number newDamage
These are called if a unit has been hit by a weapon. (x, z) is the direction from which the projectile came in world space (the reverse direction of the impulse, to be exact.)
In addition, HitByWeaponId also gets the weaponDefID of the weapon which is dealing the damage, and the amount of damage. If HitByWeaponId returns a number, this number will replace the damage value calculated by the engine.
Note: these call-ins run just before the LuaRules UnitPreDamaged callin (see also LuaCallinReturn). If HitByWeaponId overrides the damage, UnitPreDamaged will see the new damage value, and may override again the damage value.
Builders and factories
StartBuilding ( heading, pitch ) -> nil
StartBuilding ( ) -> nil
StopBuilding ( ) -> nil
These notify the script when a builder or factory starts or stops building.
The first variant (with heading and pitch arguments) is called for builders. For factories, the second variant is used. In this case the heading and pitch are not necessary, because the factory script specifies the build location itself using QueryBuildInfo.
QueryBuildInfo ( ) -> number piece
For factories only. Should return the piece to which the unit which is going to be build will be attached while it's being build.
QueryNanopiece ( ) -> number piece
Called each time a nano particle is to be created. Should return the piece at which the particle will be spawned. This may be used to iterate through a few pieces, to simulate the factory/builder having multiple nanolathes.
Transports
There are some different code paths inside Spring related to transports, each (unfortunately) also associated with a different set of unit script call-ins.
This table shows for the three different transportUnloadMethods for both air transports and ground transports which callins are used and roughly when and how often they are called. Refer to the documentation below for a description of the call-ins.
The entire behavior around transports should be considered subject to change; it is obvious it is far from a perfect design currently.
| Load | UnloadLand (0) | UnloadDrop (1) | UnloadLandFlood (2) | |
|---|---|---|---|---|
| default unload | fly over and drop unit | land, then release all units at once | ||
| air | BeginTransport (each) QueryTransport (each) |
EndTransport (last) | EndTransport (each) | StartUnload (first) TransportDrop (each) EndTransport (last) |
| ground | TransportPickup (each) | TransportDrop (each) | TransportDrop (each) | TransportDrop (each) EndTransport (last) |
Air transports
BeginTransport ( passengerID ) -> nil
QueryTransport ( passengerID ) -> number piece
For an air transport, if any one unit is picked up, these two are called in succession and the passenger is attached to the piece returned by the second one.
StartUnload ( ) -> nil
Only called in UnloadLandFlood behavior. Signals the start of an unload cycle.
TransportDrop ( passengerID, x, y, z ) -> nil
Only called in UnloadLandFlood behavior. Called when a passenger will be unloaded. Contrary to ground transports, Spring will detach the passenger after the call.
EndTransport ( ) -> nil
In UnloadLand and UnloadLandFlood behaviors, these are called one time after all units are unloaded. (The transport is empty.) For the UnloadDrop behavior, this is called for every unit that is unloaded.
Ground transports
TransportPickup ( passengerID ) -> nil
Called when a passenger should be loaded into the transport. This should eventually call AttachUnit to actually attach the unit. Assuming the transport is in range of the next passenger, this will be called again for the next passenger 16 frames later, unless the script enters the BUSY state: then Spring will not move on to the next passenger until the script leaves the BUSY state.
TransportDrop ( passengerID, x, y, z ) -> nil
Called when a passenger should be unloaded. This should eventually call DetachUnit to actually detach the unit, unless the used unload method is UnloadLandFlood, in which case Spring will actually detach the unit after the call.
EndTransport ( ) -> nil
Only called in UnloadLandFlood behavior, after the last unit has been unloaded.
Passenger
Falling ( ) -> nil
For a unit dropped from an UnloadDrop transport, this is called every frame to inform the script the unit is still falling. It may be used to show a parachute for example.
Landed ( ) -> nil
This is called one time after the unit reached the ground. May be used to hide a parachute for example.
Internal
These call-ins are NOT available to Lua unit scripts. They are called by the engine however, but always 'intercepted' by the framework gadget. For completeness (or if you are poking at the gadget), they are listed here anyway.
MoveFinished ( piece, axis ) -> nil
TurnFinished ( piece, axis ) -> nil
Called when a move or turn finished. The framework gadget uses this to resume the coroutines which are waiting for the particular move or turn to be finished.
Destroy ( ) -> nil
Called right before the unit's script is destroyed. This may happen if the unit is being destroyed, but also if the unit's script is being replaced by another script. The framework gadget uses this to stop all threads and remove the unit from some internal data structures.