This is an old revision of the document!
Table of Contents
Text Functions
Special text codes are used to get the names of things associated with the current script context, these are:
%PLAYER% : Name of the player
%BUILDINGOWNER% : Name of the owner of the building in context (where applicable)
%KILLER% : Name of the player who killed the player (Applicable in “PlayerKilled” and “RobocrowKilled” events)
%TARGET% : Name of the target of an event (e.g. “BarterRequest”, “MenuOption” and 'Battle'events. Also sometimes valid in “UseItem” if the targeting system is active).
Other system functions allow you to get the names and text representations of different aspects of your world, and convert from a text name to an ID number and vice versa:
sysGetPlayerName
Format | sysGetPlayerName( [PlayerID] ) |
---|---|
Description | Returns the name of the specified player |
Parameters | Player ID |
Returns | Player Name |
Example:
Event( "UseItem", "Potion" ) { $targetName = sysGetPlayerName( $gTargetID ) *msg %PLAYER% You used the potion while targeting $targetName }
sysGetItemName
Example : $var = sysGetItemName ($itemNum))
TBD
sysGetSkillName
Example : $var = sysGetSkillName($skillNum))
TBD
sysGetItemNum
Format | sysGetItemNum( [Item Name] ) |
---|---|
Description | Gets an item number from a name |
Parameters | Item Name |
Returns | Item number |
Example:
Event( "UseItem", "Potion" ) { $itemNum = sysGetItemNum( "Potion" ) *msg %PLAYER% The item number is $itemNum }
sysGetSkillNum
TBD
sysGetPriceText
Format | sysGetPriceText ( [Price] ) |
---|---|
Description | Returns a text string displaying the price value expressed in a short format - e.g 2s 3d |
Parameters | Price value (in denari) |
Returns | Price text |
Example:
Event( "UseItem", "Potion" ) { $price = 20 if ( $gPlayerCash < $price ) { $priceText = sysGetPriceText( $price ) *alert %PLAYER% You need at least $priceText to use the potion CancelTransaction() } else { *grantcash %PLAYER% -$price } }
sysGetDateText
Format | sysGetDateText( [Unix Time] ) |
---|---|
Description | Returns a text string displaying the date and time |
Parameters | Unix time (Number of seconds since 1 Jan 1970) |
Returns | Text of the date and time (e.g. “31st December 2014 18:00” ) |
Example:
Event( "UseItem", "Potion" ) { $nextUsePotionTime = $gServerTimeVar[0] $currTime = sysGetRealTime( "UnixTime" ) if ( $currTime < $nextUsePotionTime ) { $useDateText = sysGetDateText( $nextUsePotionTime ) *msg %PLAYER% You cannot use the potion until $useDateText CancelTransaction() } else { // Set server variable to store the next time the potion can be used - one hour from now $kOneHourInSeconds = 60 * 60 $gServerTimeVar[0] = $currTime + $kOneHourInSeconds } }
sysGetTimeText
TBD
sysGetRealTimeTextForDays
Format | sysGetRealTimeTextForDays ( [Number of game days] ) |
---|---|
Description | Returns a text description of the time that will pass for the specified number of game days |
Parameters | Number of game days |
Returns | Time text |
Example:
Event( "UseItem", "Magic Potion" ) { $daysSinceLastUsed = $gGameDay - $gPlayerKey[LastUsedPotionDay] if ( $daysSinceLastUsed < 10 ) { $daysUntilCanUse = 10 - $daysSinceLastUsed $timeText = sysGetRealTimeTextForDays( $daysUntilCanUse ) *say You must wait $timeText until you can use the Magic Potion again } else { *effect %PLAYER% 10 $gPlayerKey[LastUsedPotionDay] = $gGameDay } }