Skip to main content

Expressions

Discworld concept help

Expressions

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

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

Shop Counter Expressions

Bank 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

Variables for Players

Variables for Players
levelThe guild level of the player
guildThe guild of the player (assassins, priests, thieves, warriors, witches, wizards)
deityThe deity the player worships
familyThe family the player is in
orderThe house, specialisation, priesthood or order of the player
playerkillerWhether the player is a playerkiller
playernameThe name of the player

Variables for Shops

Variables for Shops
objectsThe object or objects being sold
salecategoryThe category the object(s) are being sold in
salecostThe money amount each object is being sold for
salenameThe name the object(s) are being sold as

Functions

Functions

General Functions

General Functions
sizeof(collection)The size of the collection.

Functions for Players

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

Functions for Shops
inventorynumber(name)The number of items in inventory that have the specified name.

Functions for Objects and Groups of Objects

Functions for Objects and Groups of Objects
objectenchantThe 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.
objectvalueThe value of an object or lowest value of a group of objects, taking object condition in to account.
objectbasevalueThe value of an object or lowest value of a group of objects, not taking object condition in to account.
objectconditionThe condition of an object or lowest condition of a group of objects, expressed as a % from 0 (no condition) to 100 (maximum condition).
objecttypeThe 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".
objectwardedGiven one or more objects, return the ones which are warded.
objectstolenGiven one or more objects, return the ones which are stolen.
percentchargedThe percentage charged of an artifact or the lowest percentage charged of all artifacts in a group of objects.
chargesThe 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.
contentsReturns the contents of an object.

String comparisons are always lower case.

Conditions

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.