This is an old revision of the document!
Salet unit
The SaletUnit class describes game units - portable or fixed in place.
SaletUnit properties
name
The internal name of the unit. It's used for direct calls. Mandatory to have.
order
This property is used to sort the descriptions when examining the room. By default, it's 0
. You can set to any number.
visible
This property indicates whether the unit is visible when viewed from the room. By default it's true
- the unit's description in printed on ext.
takeable
This property indicates whether the unit can be taken by player. By default it's false
.
If it's true
, then when this unit's link is clicked *Salet* would not call the act
function. It would call the take
one instead and move this unit to the player's inventory.
display
The name of the unit that can be seen by the player. Can be a function that returns a string, or a string.
take
A reaction when this unit is moved to the player's inventory.
Can be a function that returns a string, or a string.
act
A reaction when when this unit's link is clicked, if the unit is not portable (takeable = false
).
Can be a function that returns a string, or a string.
dsc
Description of the item that is displayed each time the room (in which the unit is located) is examined.
If the description has something like this: link
i.e. a text in curly braces, it would be transformed into a unit link. When this link is clicked, Salet would call act
or take
callback, depending on takeable
property.
Can be a function that returns a string, or a string.
inv
A description of the unit in the character's inventory after it was picked up by the player.
Can be a function that returns a string, or a string.
location
The name
of the room where this unit is located. Always a string.
SaletUnit functions
put
The put(location)
function puts this unit in a location
room and sets the location
property to the name of that room.
If the room does not exist, there would appear an error in the browser's developer console.
Argument: room name. Mandatory argument.
delete
The delete(location)
function removes this unit from a location
room. If the argument is omitted, it's current room.
Argument: room name, current room by default. Optional argument.