Difference between revisions of "Begin"
Jump to navigation
Jump to search
imported>GreyWanderer (added section "note on operators") |
|||
Line 148: | Line 148: | ||
; Note that the unparameterized OnAdd block will ALSO be run in this case. | ; Note that the unparameterized OnAdd block will ALSO be run in this case. | ||
end | end | ||
==Note on operators== | |||
Also note that when using valid block types you are also allowed to use operators as part of the Begin command. Whether it makes sense or not depends on the particular situation. | |||
begin OnDrop || OnSell | |||
; some script | |||
; this will run if the calling object is either being dropped or sold. | |||
; for the case the item has been removed by removeallitems with target container ref you | |||
; have to store the ref of the target in a ref var and check against it within an OnAdd block | |||
end | |||
begin OnHit player && OnHitWith SpecialWeapon | |||
; some script | |||
; this will run if the calling object is hit by the player with SpecialWeapon | |||
end | |||
begin OnAdd && OnAdd player != 1 | |||
; some script | |||
; this will be run if the calling object is added to the inventory of anyone but the player | |||
end | |||
[[Category: Commands]] | [[Category: Commands]] |
Revision as of 19:03, 16 April 2006
All script commands, except for variable declarations, must be inside a begin-end block. Each time the script runs, each block will be evaluated to see if it is valid. If not, the script inside the block will not be run.
Example:
begin GameMode
Blocktype | Parameters | Description |
---|---|---|
GameMode | This will be run every frame while the game is in non-menu mode. Most scripts will use this block type exclusively. | |
MenuMode | MenuType (optional) | Run every frame while the game is in menu mode. |
OnActivate | Run once when object is activated. | |
OnActorEquip | ObjectID | Run once when the scripted actor equips the specified object. |
OnActorUnequip | ObjectID | Run once when the scripted actor unequips the specified object. |
OnAdd | ContainerRefID (optional) | Run once when object is added to Container's inventory. |
OnAlarm | CrimeType, Criminal (optional) | Run once when the actor receives an alarm for the specified crime committed by Criminal (actor). |
OnAlarmVictim | CrimeType, Victim (optional) | Run once when the actor receives an alarm for the specified crime committed against Victim (actor). |
OnDeath | ActorID (optional) | Run once when actor is killed by ActorID |
OnDrop | ContainerRefID (optional) | Run once when object is dropped from Container. |
OnEquip | ActorID (optional) | Run once when object is equipped by ActorID. |
OnHit | ActorID (optional) | Run once when actor is hit by ActorID |
OnHitWith | ObjectID (optional) | Run once when actor is hit by weapon ObjectID |
OnKnockout | Run once when actor is knocked out by ActorID | |
OnLoad | Run once when object's 3D is loaded | |
OnMagicEffectHit | EffectID (optional) | Run once when the actor is hit by the specified magic effect |
OnMurder | ActorID (optional) | Run once when actor is murdered by ActorID |
OnPackageChange | PackageID | Run once when actor changes from specified package |
OnPackageDone | PackageID | Run once when actor completes specified package |
OnPackageStart | PackageID | Run once when actor starts specified package |
OnReset | Run once when scripted object's cell is reset | |
OnSell | SellerRefID (optional) | Run once when object is sold by specified seller |
OnStartCombat | TargetActorID (optional) | Run once when actor enters combat with TargetActorID |
OnTrigger | TriggeringRefID (optional) | Run once when object is triggered by colliding object |
OnTriggerActor | TriggeringRefID (optional) | Run once when object is triggered by colliding actor |
OnTriggerMob | TriggeringRefID (optional) | Run once when object is triggered by colliding mobile object (actors, arrows, magic projectiles) |
OnUnequip | ContainerRefID (optional) | Run once when object is unequipped by ActorID. |
ScriptEffectStart | Special block type used only by Magic Effect scripts | |
ScriptEffectFinish | Special block type used only by Magic Effect scripts | |
ScriptEffectUpdate | Special block type used only by Magic Effect scripts |
Note that for parameterized blocks, you can have several of the same block type using different parameters. For example, this script is valid:
begin OnAdd ; some script ; this will run every time this object is added to someone's inventory end begin OnAdd player ; some script ; this will run every time this object is added to the player's inventory. ; Note that the unparameterized OnAdd block will ALSO be run in this case. end begin OnAdd MysteriousChest ; some script ; this will run every time this object is added to the MysteriousChest's inventory. ; Note that the unparameterized OnAdd block will ALSO be run in this case. end
Note on operators
Also note that when using valid block types you are also allowed to use operators as part of the Begin command. Whether it makes sense or not depends on the particular situation.
begin OnDrop || OnSell ; some script ; this will run if the calling object is either being dropped or sold. ; for the case the item has been removed by removeallitems with target container ref you ; have to store the ref of the target in a ref var and check against it within an OnAdd block end begin OnHit player && OnHitWith SpecialWeapon ; some script ; this will run if the calling object is hit by the player with SpecialWeapon end begin OnAdd && OnAdd player != 1 ; some script ; this will be run if the calling object is added to the inventory of anyone but the player end