User Tools

Site Tools


scripting:system_values_functions_overview

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
scripting:system_values_functions_overview [2015/02/23 13:17] – [System Variables] mitscripting:system_values_functions_overview [2025/05/28 16:34] (current) – external edit 127.0.0.1
Line 27: Line 27:
 ===== System Variables ===== ===== System Variables =====
  
-The scripting system has a range of persistent System Variables that you can set and retrieve. There are 3 types :+Systems Variables are persistent key/value pairs that you can set and retrieve. There are 3 types :
   * **Server Variables** ( ''$gServerKey[<KEY_NAME>]'' )   * **Server Variables** ( ''$gServerKey[<KEY_NAME>]'' )
   * **Building Variables** ( ''$gBuildingKey[<KEY_NAME>]'' )   * **Building Variables** ( ''$gBuildingKey[<KEY_NAME>]'' )
   * **Player Variables** ( ''$gPlayerKey[<KEY_NAME>]'' )   * **Player Variables** ( ''$gPlayerKey[<KEY_NAME>]'' )
  
-**Server** system variables are global there are one set of values for your world each building added world has its own set of **Building** system variables and each player has their own set of **Player** variables.+**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 : 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 :
Line 40: Line 40:
   $gServerKey[Hello] = "Your personalised random number is "   $gServerKey[Hello] = "Your personalised random number is "
   $gPlayerKey[1] = sysRand( 100 )   $gPlayerKey[1] = sysRand( 100 )
-  *say Hello %PLAYER%. $gServerKey[Hello] $gPlayerKey[1].+  *say Hi %PLAYER%. $gServerKey[Hello] $gPlayerKey[1].
 </codedoc> </codedoc>
-.. this would print ''Hello [Player_Name]. Your personalised random number is [1-100]''+.. 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 variables the script is currently accessing - i.e. When an 'AccessBuilding' event is triggered, the ''$gBuildingKey''s refer to the values set for the particular building being accessed. +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 ''$gBuildingKey''s 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''. 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.1424697469.txt.gz · Last modified: (external edit)