Difference between revisions of "TYPEDEF"

From SphereWiki
Jump to: navigation, search
(Created page with '__FORCETOC__ Type definitions are the equivalent of EVENTS that can be attached to items. There are different properties that can be used to attach a type block to ...')
 
m
Line 2: Line 2:
 
Type definitions are the equivalent of [[EVENTS]] that can be attached to [[Items|items]]. There are different properties that can be used to attach a type block to an item or set of items:
 
Type definitions are the equivalent of [[EVENTS]] that can be attached to [[Items|items]]. There are different properties that can be used to attach a type block to an item or set of items:
 
* [[ITEMDEF|item definitions]] via their [[TYPE]] and/or [[TEVENTS]] property.
 
* [[ITEMDEF|item definitions]] via their [[TYPE]] and/or [[TEVENTS]] property.
* [[Items|items]] via their [[TYPE]] and/or [[EVENTS]] property.
+
* [[Items|items]] via their [[TYPE]] and/or [[EVENTS (Property)|EVENTS]] property.
  
  

Revision as of 13:49, 20 June 2009

Type definitions are the equivalent of EVENTS that can be attached to items. There are different properties that can be used to attach a type block to an item or set of items:


In addition to handling triggers, type definitions can also be used to define different types of terrain. This can be used to affect the return value of the TYPE property on map points, or for some hardcoded types such as t_rock it can be used to define which terrain IDs Sphere should consider to be rock when the mining skill is used.


Syntax

The syntax for defining a type is:


[TYPEDEF defname]
TERRAIN=id
TERRAIN=start_id, end_id

ON=trigger_name
    script

ON=trigger_name
    script


Any number of triggers can be handled by one TYPEDEF definition, however it is not possible to handle the same trigger twice without using multiple definitions.


The trigger name can be the name of any item trigger. The return value from the script can affect Sphere's hardcoded behaviour in different ways. See the documentation for the trigger to discover what parameters are passed in to each trigger and what the return values do.


Note: If the defname matches any of Sphere's hardcoded types (see 'typedefs' block in sphere_defs.scp), then the TYPEDEF can be used to override the behaviours of items of that type.


Examples

//
// Water definition from default script pack.
//
[TYPEDEF t_water]
TERRAIN = 0a8	0ab
TERRAIN = 0136	0137
//
// Makes an item speak when double clicked.
//
[TYPEDEF t_exampletype]
ON=@DClick
    SAY I have been double clicked!
    RETURN 2