Crystal Space 3D
 Revision as of 15:03, 15 November 2008 (edit) (→Annex 2: Escape characters)← Previous diff Current revision (15:05, 15 November 2008) (edit) (undo) (→Examples) (2 intermediate revisions not shown.) Line 105: Line 105: * =if(mousex()<10,'left','right') <- returns left or right according to mousex position * =if(mousex()<10,'left','right') <- returns left or right according to mousex position + * =if(property(pc(tools.config.json),propid(index))==0,10,-1) <- returns 10 o -1 according to index property. * =property(pc(pc2d.billboard),propid(text)) <- returns the value of the "text" property from the "pc2d.billboard" pc in current entity. * =property(pc(pc2d.billboard),propid(text)) <- returns the value of the "text" property from the "pc2d.billboard" pc in current entity. * =enemy+?i -> returns something like enemy13 (if i pcproperty was 13 at the moment) * =enemy+?i -> returns something like enemy13 (if i pcproperty was 13 at the moment) Line 133: Line 134: * < : "&#60;" * < : "&#60;" * & : "&#38;" * & : "&#38;" + + example: 1<2 becomes 1&#60;2 == Annex 3: unusable functions == == Annex 3: unusable functions ==

## Quest Expressions

Only supported for rewards.

example:

``` =2*@par
```

### Syntax

``` * @par -> dynamic parameter (see annex 1 below)
* ?prop -> property from pcproperties
* ?entname.prop -> property from some entity pcproperties
* * -> multiply
* - -> substract
* / -> divide
* % -> modulo
* ~ -> bitnot
* ^ -> bitxor
* == -> equality
* != -> inequality
* <= -> lesser or equal
* >= -> greater or equal
* < -> lesser
* > -> greater
* funcname(par1,par2...) -> run a function
```

### values

``` * false -> boolean false
* true -> boolean true
```

### functions

parameters inside [] are optional

``` * pc([ent],name)
* pctag([ent],name, tag)
* param
* property([pc],propid)
* id
* parid
* actid
* propid
* rgb(r,g,b) -> color code
* abs(number)
* min(n1,n2) -> min
* max(n1,n2) -> max
* config
* mousex() -> mousex
* mousey() -> mousey
* normalize(vector) --> normalized vector
* bb_mousex
* bb_mousey
* cos(number) -> cos
* sin(number)
* tan(number)
* acos(number)
* asin(number)
* atan(number)
* sign(number)
* sqrt(number)
* sqdist(vec1,vec2)
* hasclass
* intpol(a,b,c)
* int(something)
* float(something)
* bool(something)
* rand(number)
* bb_testcollide
* if(expr, trueexpr, falseexpr)
* entname() -> entity name
* ent() -> entity, ent(entityname) -> entity
* sound
* sound_paused
* strlen
* strsub
* stridx
* scr_width()
* scr_height()
* testvar(name) -> test existance
* chdirauto(dir,file) -> change to dir if file is present
* writefile
* getyrot(dx,dy) -> angle
* vecx(vec) -> vec.x
* vecy(vec) -> vec.y
* vecz(vec) -> vec.z
* colred(col) -> col.red
* colgreen(col) -> col.red
* colblue(col) -> col.red
* getmsg(msg) -> translated message
* key_node(sector,node,key,[value])
* key_meshobj(meshobj,key,[value])
* key_sector(sector,key,[value])
* key_meshfact(meshfact,key,[value])
* key_texture(texture,key,[value])
* key_material(material,key,[value])
* key_light(light,key,[value])
```

### Examples

``` * =if(mousex()<10,'left','right') <- returns left or right according to mousex position
* =if(property(pc(tools.config.json),propid(index))==0,10,-1) <- returns 10 o -1 according to index property.
* =property(pc(pc2d.billboard),propid(text)) <- returns the value of the "text" property from the "pc2d.billboard" pc in current entity.
* =enemy+?i -> returns something like enemy13 (if i pcproperty was 13 at the moment)
* =[1,2,3] -> returns a vector3 with contents x=1 y=2 z=3
```

## Annex 1: Dynamic parameters

If you use @par (instead of the already existing \$par notation) you can get dynamic parameters from triggers. As opposed to static (\$par) parameters these parameters can change every time the reward is fired. Currently there are the following limitations:

``` * @par notation does not work in triggers (that will stay).
* @par notation does not work in sequences.
```

### Dynamic parameters each trigger sends

``` * message --> forwards all message parameters
* inventory --> @child (name of added or removed entity)
* meshsel --> @entity (name of the selected entity)
* trigger --> @entity (name of the entity triggering)
```

## Annex 2: Escape characters

``` * some characters need to be escaped when they live in xml attributes:
* < : "&#60;"
* & : "&#38;"
```

example: 1<2 becomes 1&#60;2

## Annex 3: unusable functions

functions which aren't useful due to some missing features from blxml

``` * inventory_get
* inventory_count
* inventory_in
* inventory_find
* inventory_inname
* inventory_findname
* actionname{par1=XXX,par2=XXX,par3=XXX...}
```

## Annex 4: undocumented tokens

not sure what these are for... do not read (only here for internal documentation purpose

``` * property
* action
* bb_movelayer
* bb_move
* bb_tofront
* bb_toback
* bb_up
* bb_down
* par
* var
* lvar
* expr
* while
* if
* for
* print
* call
* case
* mount
* hitbeam
* inherit
* destroyentity
* createentity
* createpropclass
* destroypropclass
* default
* inventory
* inventory_rem
* chdir
* sound
* sound_stop
* sound_pause
* sound_unpause
* sound_restart
* sound_volume
* sound_speed
* config_rem
* config_set
* config_save
* class_rem
* super
* switch
* strsplit
* return
* reporterror
* variables
* traceon
* traceoff
* callstack
* selectentity
* stop
* randomize
* quit
* hidemouse
* showmouse