scripting:reference:system_functions
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| scripting:reference:system_functions [2015/02/20 14:06] – mit | scripting:reference:system_functions [2025/05/28 16:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| The scripting engine provides a set of ' | The scripting engine provides a set of ' | ||
| - | ===== Special Scripting Language Functions ===== | + | (Note also the list of [[Scripting:Reference: |
| - | + | ||
| - | ==== Sleep ==== | + | |
| - | ^ Format : | Sleep( [time] ) | | + | |
| - | ^ Description : | Pauses | + | |
| - | ^ Parameters: | [time] - Sleep time in 1/10ths of a second | | + | |
| - | //Example//:< | + | |
| - | < | + | |
| - | { | + | |
| - | *effect %PLAYER% 1 | + | |
| - | Sleep(10) | + | |
| - | *effect %PLAYER% 1 | + | |
| - | } | + | |
| - | </ | + | |
| - | </ | + | |
| - | + | ||
| - | ==== sysSetTimer ==== | + | |
| - | ^ Format | + | |
| - | ^ Description | After the specified period of time a ' | + | |
| - | ^ Parameters | **[interval]** - Number of seconds to pass before the timer event is triggered | | + | |
| - | ^ | **[eventname]** - Name of the timer event to be triggered | | + | |
| - | ^ | **[eventparams]** - Parameter values to be passed in to the timer event | | + | |
| - | ^ Returns | **[TimerID]** - ID number of the timer which can be used with ***killtimer [ID]** to cancel a timer | | + | |
| - | ^ Notes | The context in the subsequent Timer event will be the same as the event that activated the timer. | | + | |
| - | // | + | |
| - | < | + | |
| - | { | + | |
| - | sysSetTimer( 10, " | + | |
| - | } | + | |
| - | + | ||
| - | Event( " | + | |
| - | { | + | |
| - | *msg %PLAYER% Your alarm clock started ringing 10 seconds later | + | |
| - | } | + | |
| - | </ | + | |
| - | </ | + | |
| - | + | ||
| - | ==== CancelTransaction ==== | + | |
| - | ^ Format | CancelTransaction () | | + | |
| - | ^ Description | This is a special | + | |
| - | // | + | |
| - | < | + | |
| - | { | + | |
| - | $hasKeys = sysPlayerInventory( " | + | |
| - | if ( $hasKeys == 0 ) | + | |
| - | { | + | |
| - | *msg %PLAYER% You cannot access this building without keys | + | |
| - | CancelTransaction() | + | |
| - | } | + | |
| - | } | + | |
| - | </ | + | |
| - | </ | + | |
| ===== Player-status Functions ===== | ===== Player-status Functions ===== | ||
| Line 84: | Line 33: | ||
| ^ Parameters | **[index]** - Inventory slot number | | ^ Parameters | **[index]** - Inventory slot number | | ||
| ^ Returns | **[ItemNum]** - The item number in the specified inventory slot (or 0 if the slot is empty) | | ^ Returns | **[ItemNum]** - The item number in the specified inventory slot (or 0 if the slot is empty) | | ||
| - | ^ Notes | Players currently have 16 inventory slots. | | + | ^ Notes | Players currently have up to 64 inventory slots. | |
| // | // | ||
| < | < | ||
| { | { | ||
| $loop = 0 | $loop = 0 | ||
| - | while( $loop < 16 ) | + | while( $loop < 64 ) |
| { | { | ||
| | | ||
| Line 97: | Line 46: | ||
| } | } | ||
| } | } | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ==== sysGetNearestPlayer ==== | ||
| + | ^ Format | sysGetNearestPlayer( [WorldX], [WorldY] )| | ||
| + | ^ Description | Returns the ID of the player closest to the specified world coordinate | | ||
| + | ^ Parameters | World Coordinate X,Y | | ||
| + | ^ Returns | Player ID | | ||
| + | // | ||
| + | < | ||
| + | $kSpecialBuildingRecordNum = 10 | ||
| + | |||
| + | Event( " | ||
| + | { | ||
| + | SetBuildingContext( $kSpecialBuildingRecordNum ) | ||
| + | $posX = $gBuildingWorldX | ||
| + | $posY = $gBuildingWorldY | ||
| + | | ||
| + | $targetPlayerID = sysGetNearestPlayer( $posX, $posY ) | ||
| + | $targetPlayerName = sysGetPlayerName( $targetPlayerID ) | ||
| + | *say %PLAYER% used the plunger. The person closest to the special building was $targetPlayerName | ||
| + | *explodebuilding $kSpecialBuildingRecordNum | ||
| } | } | ||
| </ | </ | ||
| Line 124: | Line 96: | ||
| ==== sysIsPlayerIDOnline ==== | ==== sysIsPlayerIDOnline ==== | ||
| - | Example : '' | + | ^ Format | sysIsPlayerIDOnline( |
| - | Returns 1 if the specified player | + | ^ Description | Used to determine |
| + | ^ Parameters | Player ID | | ||
| + | ^ Returns | **1** if the player is connected, **0** if not | | ||
| + | ^ Example | '' | ||
| ==== sysIsInSpawnZone ==== | ==== sysIsInSpawnZone ==== | ||
| - | Example : '' | + | ^ Format | sysIsInSpawnZone( |
| - | Returns 1 if the current player is in the specified spawn zone, 0 if not \\ | + | ^ Description | Used to determine |
| + | ^ Parameters | SpawnZone Type/ID | | ||
| + | ^ Returns | **1** if the player is in the region, **0** if not | | ||
| + | ^ Example | '' | ||
| ==== sysIsInTown ==== | ==== sysIsInTown ==== | ||
| Line 158: | Line 136: | ||
| ==== sysPlayerSkillLevel ==== | ==== sysPlayerSkillLevel ==== | ||
| - | Example : '' | + | Example : '' |
| - | Returns the current player' | + | Returns the current player' |
| + | |||
| + | ==== sysPlayerIsLearningSkill ==== | ||
| + | Example : '' | ||
| + | Returns **1** if the player is currently learning the specified skill, **0** if not. \\ | ||
| ===== Player Building Ownership Functions ===== | ===== Player Building Ownership Functions ===== | ||
| Line 232: | Line 214: | ||
| ==== sysAmountInStocks ==== | ==== sysAmountInStocks ==== | ||
| - | Example | + | ^ Format | sysAmountInStocks( [Item_Name or Num] )| |
| - | Returns the amount of the item named currently in the player' | + | ^ Description | Returns the amount of the item currently in the building' |
| + | ^ Parameters | Item Name or number | | ||
| + | ^ Example | ||
| ==== sysGetBuyPrice ==== | ==== sysGetBuyPrice ==== | ||
| Line 254: | Line 238: | ||
| </ | </ | ||
| - | ==== sysGetSellPrice==== | + | ==== sysGetSellPrice ==== |
| - | Example : '' | + | ^ Format | sysGetSellPrice( [Item_Name or Num] )| |
| - | TBD\\ | + | ^ Description | Returns the price that the item is currently set for sale at (Or 0 if it is not currently for sale) | |
| + | ^ Parameters | Item Name or number | | ||
| + | //Example//: | ||
| + | < | ||
| + | < | ||
| + | { | ||
| + | osdcreate( OSDBUILDING, | ||
| + | | ||
| + | if ( $woodSellPrice == 0 ) | ||
| + | { | ||
| + | osdaddat( TEXT, 100, 100, 400, 0, "", | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | $woodSellPriceText = sysGetPriceText( $woodSellPrice ) | ||
| + | osdaddat( TEXT, 100, 100, 400, 0, "", | ||
| + | } | ||
| + | osdactivate() | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| ==== sysGetEmployeeID ==== | ==== sysGetEmployeeID ==== | ||
| ^ Format | sysGetEmployeeID( [Index] ) | | ^ Format | sysGetEmployeeID( [Index] ) | | ||
| Line 264: | Line 267: | ||
| ^ Returns | PlayerID of the employee or 0 if none is set for this index | | ^ Returns | PlayerID of the employee or 0 if none is set for this index | | ||
| // | // | ||
| - | < | + | < |
| { | { | ||
| osdcreate( OSDBUILDING, | osdcreate( OSDBUILDING, | ||
| Line 277: | Line 280: | ||
| osdaddat( TEXT, 100, 100, 400, 0, "", | osdaddat( TEXT, 100, 100, 400, 0, "", | ||
| } | } | ||
| - | | + | |
| } | } | ||
| </ | </ | ||
| Line 325: | Line 328: | ||
| ==== sysAddBuilding ==== | ==== sysAddBuilding ==== | ||
| - | TBD\\ | + | ^ Format | sysAddBuilding ( [Building Type], [Owner ID], [MapX], [MapY], [ [Building_Name], |
| + | ^ Description | Used to add a new building to your world | | ||
| + | ^ Parameters | Building Type number | | ||
| + | ^ | Owner player ID | | ||
| + | ^ | Map Coordinate X | | ||
| + | ^ | Map Coordinate Y | | ||
| + | ^ | (Optional) Building Name | | ||
| + | ^ | (Optional) Construction Amount 1 | | ||
| + | ^ | (Optional) Construction Amount 2 | | ||
| + | ^ Returns | 1 if the building was added to the world, 0 if not | | ||
| + | // | ||
| + | < | ||
| + | { | ||
| + | $nBuildingType = $gParam[1] | ||
| + | |||
| + | $valid = sysIsBuildingPositionValid( $nBuildingType ) | ||
| + | if ( $valid = 1 ) | ||
| + | { | ||
| + | $buildingName = sysGetTextEntry() | ||
| + | $didAdd = sysAddBuilding( nBuildingType, | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| ==== sysAddBuildingWorld ==== | ==== sysAddBuildingWorld ==== | ||
| TBD\\ | TBD\\ | ||
| + | ==== sysGetBuildingTypeName ==== | ||
| + | TBD // | ||
| + | // | ||
| + | ==== sysGetConstructionMaterialsAmount ==== | ||
| + | TBD // | ||
| + | // | ||
| ==== sysAddLocalBackgroundModel ==== | ==== sysAddLocalBackgroundModel ==== | ||
| TBD\\ | TBD\\ | ||
| Line 522: | Line 555: | ||
| </ | </ | ||
| + | ==== sysGetTimeText ==== | ||
| + | TBD // | ||
| + | // | ||
| - | ===== Context Functions ===== | + | ==== sysGetRealTimeTextForDays |
| - | + | ^ Format | sysGetRealTimeTextForDays | |
| - | ==== SetContext | + | ^ Description | Returns a text description of the time that will pass for the specified |
| - | ^ Format | SetContext( [Player ID] )| | + | ^ Parameters | Number of game days | |
| - | ^ Description | Changes | + | ^ Returns | Time text | |
| - | ^ Parameters | Player ID | | + | |
| - | ^ Returns | None | | + | |
| - | ^ Notes | Use **RestoreContext** to set the context back to the original player | + | |
| // | // | ||
| - | < | + | < |
| { | { | ||
| - | | + | $daysSinceLastUsed = $gGameDay - $gPlayerKey[LastUsedPotionDay] |
| - | | + | if ( $daysSinceLastUsed < 10 ) |
| - | RestoreContext() | + | |
| - | | + | |
| - | if ( $targetHasShield > 0 ) | + | |
| { | { | ||
| - | *msg %PLAYER% | + | |
| - | | + | $timeText = sysGetRealTimeTextForDays( $daysUntilCanUse ) |
| + | | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | *effect | ||
| + | | ||
| } | } | ||
| } | } | ||
| </ | </ | ||
| </ | </ | ||
| - | |||
| - | ==== RestoreContext ==== | ||
| - | |||
| - | ==== SetBuildingContext ==== | ||
| - | |||
| ===== Battle game Functions ===== | ===== Battle game Functions ===== | ||
| Line 564: | Line 595: | ||
| - | ===== Misc other functions | + | ===== Maths Functions |
| ==== sysRand ==== | ==== sysRand ==== | ||
| - | Example : '' | + | ^ Format | sysRand |
| - | | + | ^ Description | Returns |
| - | + | ^ Example | |
| - | ==== sysRealTime ==== | + | |
| - | ^ Format | sysRealTime | + | |
| - | ^ Description | Returns | + | |
| - | ^ Parameters | Type field specifying the date or time to fetch | | + | |
| - | ^ Returns | Depending on the type field: | | + | |
| - | ^ | **Year** - returns the current year (e.g. 2014) | | + | |
| - | ^ | **Month** - returns the current month number | + | |
| - | ^ | **Day** - returns | + | |
| - | ^ | **Hour** - returns the current hour (0 to 23) | | + | |
| - | ^ | **Minute** - returns the current minute (0 to 59) | | + | |
| - | ^ | **Second** - returns the current second (0 to 59) | | + | |
| - | ^ | **UnixTime** - number of seconds passed since 1st Jan, 1970 | | + | |
| - | // | + | |
| - | < | + | |
| - | { | + | |
| - | $hour = sysRealTime( " | + | |
| - | if ( $hour < 18 ) | + | |
| - | { | + | |
| - | | + | |
| - | } | + | |
| - | else if ( $hour >= 20 ) | + | |
| - | { | + | |
| - | | + | |
| - | } | + | |
| - | else | + | |
| - | { | + | |
| - | *notifylarge %PLAYER% Tea-time! | + | |
| - | } | + | |
| - | } | + | |
| - | </ | + | |
| - | </ | + | |
| - | ==== sysGetDist ==== | + | |
| - | ^ Format | + | |
| - | ^ Description | Calculates the distance between two points| | + | |
| - | ^ Parameters | Point 1 X,Y | | + | |
| - | ^ | Point 2 X,Y | | + | |
| - | ^ Returns | Distance | | + | |
| - | // | + | |
| - | < | + | |
| - | { | + | |
| - | $dist = sysGetDist( $gPlayerWorldX, | + | |
| - | *msg %PLAYER% You accessed the building from $dist cm away | + | |
| - | } | + | |
| - | </ | + | |
| - | </ | + | |
| ==== sysSin ==== | ==== sysSin ==== | ||
| Line 648: | Line 634: | ||
| \\ | \\ | ||
| - | ==== PlayerTaskStartSetTime | + | ==== sysGetDist |
| - | TBD \\ | + | ^ Format | sysGetDist ( [X1], [Y1], [X2], [Y2] )| |
| - | \\ | + | ^ Description | Calculates the distance between two points| |
| + | ^ Parameters | Point 1 X,Y | | ||
| + | ^ | Point 2 X,Y | | ||
| + | ^ Returns | Distance | | ||
| + | // | ||
| + | < | ||
| + | { | ||
| + | $dist = sysGetDist( $gPlayerWorldX, | ||
| + | *msg %PLAYER% You accessed the building from $dist cm away | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ===== Misc other functions ===== | ||
| + | |||
| + | ==== sysRealTime ==== | ||
| + | ^ Format | sysRealTime ( [Type] )| | ||
| + | ^ Description | Returns details of the current real time (according to the server clock)| | ||
| + | ^ Parameters | Type field specifying the date or time to fetch | | ||
| + | ^ Returns | Depending on the type field: | | ||
| + | ^ | **Year** - returns the current year (e.g. 2014) | | ||
| + | ^ | **Month** - returns the current month number (1 to 12) | | ||
| + | ^ | **Day** - returns the current day number (1 to 31) | | ||
| + | ^ | **Hour** - returns the current hour (0 to 23) | | ||
| + | ^ | **Minute** - returns the current minute (0 to 59) | | ||
| + | ^ | **Second** - returns the current second (0 to 59) | | ||
| + | ^ | **UnixTime** - number of seconds passed since 1st Jan, 1970 | | ||
| + | // | ||
| + | < | ||
| + | { | ||
| + | $hour = sysRealTime( " | ||
| + | if ( $hour < 18 ) | ||
| + | { | ||
| + | *msg %PLAYER% Tea can only be used at tea-time (6pm - 8pm) | ||
| + | } | ||
| + | else if ( $hour >= 20 ) | ||
| + | { | ||
| + | *msg %PLAYER% Tea can only be used at tea-time (6pm - 8pm) | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | *notifylarge %PLAYER% Tea-time! | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| - | ==== CustomEvent | + | ==== sysRaceIsActive |
| - | Triggers a custom event | + | |
| TBD \\ | TBD \\ | ||
| \\ | \\ | ||
scripting/reference/system_functions.1424441186.txt.gz · Last modified: (external edit)
