User Tools

Site Tools


scripting:system_values_functions_overview

System Values

'System Values' are special read-only, global variables that provide information about the state of the current player and the world. e.g. $gPlayerAge tells you the age of the current player. Here's a quick example of how you might use that

  $myvar = $gPlayerAge + 1
  *say Next birthday, %PLAYER% will be $myvar years old

For a full list of the system values available, see the System Values Reference.

System Functions

System Functions are used to query the state of a particular aspect of your world where parameters are required to obtain the result. System Functions usually start with sys.

For example, to find out how much of a particular item the current player has :

  $numInInv = sysPlayerInventory( "Wood" )
  *say %PLAYER% is currently carrying $numInInv Wood

The reference section contains a full list of System Functions.

System Variables

Systems Variables are persistent key/value pairs that you can set and retrieve. There are 3 types :

  • Server Variables ( $gServerKey[<KEY_NAME>] )
  • Building Variables ( $gBuildingKey[<KEY_NAME>] )
  • Player Variables ( $gPlayerKey[<KEY_NAME>] )

Server system variables are global (there are one set of values for your world), each constructed building has its own set of Building system variables and each player has their own set of Player variables.

The <KEY_NAME> is a case-insensitive, unique identifier for each variable and can be whatever you like. System variables can be set to integer values or text strings, and are referenced using the Key Name as shown : For example:

  $gServerKey[Hello] = "Your personalised random number is "
  $gPlayerKey[1] = sysRand( 100 )
  *say Hi %PLAYER%. $gServerKey[Hello] $gPlayerKey[1].

.. this would print Hi [Player_Name]. Your personalised random number is [1-100].

Each script event is run in a particular context which determines the building and player variables the script is currently accessing - i.e. When an 'AccessBuilding' event is triggered, the $gBuildingKeys refer to the values set for the particular building being accessed. In some events (e.g. PlayerLogin, UseItem) Building keys are not applicable.

For advanced scripting, you can access building and player system variables by changing the event context using SetContext and SetBuildingContext.

scripting/system_values_functions_overview.txt · Last modified: 2020/01/28 18:02 by 51.148.136.100

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki