Expressions |
Discworld concept help |
Expressions |
Expressions
The premises owner and other allowed players in a commercial player house (i.e. shop) may use expressions to control various features of the room or the room furniture.
Expressions may combine tests of various conditions which may be variables or functions, and may return a numeric, string or boolean (true or false) result. The type of result which is expected will depend on the expression that being set.
Room Expressions
set use expression <expression>
This expression determines whether a player can use the shop. If it evaluates to false, the player can not use any commercial features.
set use expression for <type> as <expression>
This expression determines whether a player can use a shop feature. If it evaluates to false, the player can not use that feature. The feature is usually associated with a piece of shop equipment, such as a shop or bank counter, pickler, poll, money changer etc.
Shop Counter Expressions
Bank Counter Expressions
set percentage on <bank counter> as <number expression>
Set the percentage fee on deposits.
Example: set percentage on bank counter as 4
Example: set percentage on bank counter as if (guild = "thieves") then 3 else 4 endif
set account cost on <bank counter> as <money expression>
Set the cost of opening an account.
Example: set account cost on bank counter as $1 dollar$
Example: set account cost on bank counter as if (level < 51) then $1 penny$ else $5 dollars$ endif
Variables
Variables for Players
level | The guild level of the player | |
guild | The guild of the player (assassins, priests, thieves, warriors, witches, wizards) | |
deity | The deity the player worships | |
family | The family the player is in | |
order | The house, specialisation, priesthood or order of the player | |
playerkiller | Whether the player is a playerkiller | |
playername | The name of the player |
Variables for Shops
objects | The object or objects being sold | |
salecategory | The category the object(s) are being sold in | |
salecost | The money amount each object is being sold for | |
salename | The name the object(s) are being sold as |
Functions
General Functions
sizeof(collection) | The size of the collection. |
Functions for Players
clubmember(club) | Whether the player is a member of a specific club. | |
citizenof(place) | Whether the player holds a specific citizenship. |
Functions for Shops
inventorynumber(name) | The number of items in inventory that have the specified name. |
Functions for Objects and Groups of Objects
objectenchant | The enchantment of an object or lowest enchantment of a group of objects, expressed as a % from 0 (no enchantment) to 100 (maximum enchantment), only valid if at least one of the shop owners can see enchantment. | |
objectvalue | The value of an object or lowest value of a group of objects, taking object condition in to account. | |
objectbasevalue | The value of an object or lowest value of a group of objects, not taking object condition in to account. | |
objectcondition | The condition of an object or lowest condition of a group of objects, expressed as a % from 0 (no condition) to 100 (maximum condition). | |
objecttype | The type of an object or group of objects. If a single object or all of the objects in a group are of the same type, then the returned value will be one of the strings "misc", "weapon", "clothing" or "armour". If a group of objects contains more than one type, the return value will be "mixed". | |
objectwarded | Given one or more objects, return the ones which are warded. | |
objectstolen | Given one or more objects, return the ones which are stolen. | |
percentcharged | The percentage charged of an artifact or the lowest percentage charged of all artifacts in a group of objects. | |
charges | The number of charges in an artifact, or total number of charges in a group of artifacts. | |
containsspell(spell) | The object or objects from a group of objects which contains a specified spell, only valid if at least one of the shop owners can see spells. | |
faithimbue(ritual) | True if the object is or any of the members of a group of objects are imbued with a specified ritual. | |
faithimpress(ritual) | True if the object is or any of the members of a group of objects are impressed with a specified ritual. | |
faithimprint(ritual) | True if the object is or any of the members of a group of objects are imprinted with a specified ritual. | |
percentageliquid(liquid) | The amount of the specified liquid in the object, or the minimum amount of the specified liquid in any of the objects. | |
objectmatch(identifier) | Returns the object or group of objects that match a specified identifier. | |
objectshort(short) | Returns the object or group of objects whose short descriptions match the given short. | |
contents | Returns the contents of an object. |
String comparisons are always lower case.
Conditions
if (<condition>) then <result1> else <result2> endif
If the <condition> evaluates as true, the expression returns result1, else it returns result2. Conditions may be nested.
Example: set percentage on bank counter as if (guild = "thieves") then 3 else if (guild = "assassins") then 5 else 4 endif endif
This would set the deposit rate on a bank counter to 3% for thiefs, 5% for assassins and 4% for everyone else.