User Tools

Site Tools


scripting:reference:system_functions

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:reference:system_functions [2020/01/29 04:42] mitscripting:reference:system_functions [2020/02/17 19:10] (current) mit
Line 14: Line 14:
 [[Scripting:Reference:system_functions:PlayerBuildingOwnershipFunctions|Building Ownership]] \\ [[Scripting:Reference:system_functions:PlayerBuildingOwnershipFunctions|Building Ownership]] \\
 [[Scripting:Reference:system_functions:TownFunctions|Town information and control]] \\ [[Scripting:Reference:system_functions:TownFunctions|Town information and control]] \\
 +[[Scripting:Reference:system_functions:MathsFunctions|Maths Functions]] \\
 +[[Scripting:Reference:system_functions:EntityFunctions|Entity Functions]] \\
 [[Scripting:Reference:system_functions:MiscFunctions|Misc. other functions]] \\ [[Scripting:Reference:system_functions:MiscFunctions|Misc. other functions]] \\
  
 +For a full(ish) alphabetical list of script functions : [[Scripting:Reference:system_functions:FullFunctionList|Alphabetical Function List]]
  
 +[[Scripting:Reference:system_functions:TextFunctions|Text Functions]]\\ For providing names of items, players, skills etc; converting names to IDs and vice versa  \\
 +[[Scripting:Reference:system_functions:PlayerStatusFunctions|Player Information]]\\ Get information about the player ; what skills, inventory, health they have etc \\
 +[[Scripting:Reference:system_functions:PlayerInventoryAndWealthFunctions|Inventory and Wealth manipulation]] \\
 +Add items and wealth to the player \\
 +[[Scripting:Reference:system_functions:BuildingInformationFunctions|Building Information]]: Provides information about a building and its contents (and functions to change the building UI) \\
 +[[Scripting:Reference:system_functions:WorldMapFunctions|World map functions]]: Get map coordinates for items in the world, convert map to world coordinates and vice versa \\
 +[[Scripting:Reference:system_functions:ConstructionFunctions]]\\
 +For construction of buildings and other permanent or transient items on the world \\
 +[[Scripting:Reference:system_functions:SubgameFunctions|Scripted Subgames]]\\
 +System for creating and controlling subgames which groups of players can participate in \\
 +[[Scripting:Reference:system_functions:PlayerBuildingOwnershipFunctions|Building Ownership]]\\
 +Querying and controlling the ownership status of buildings \\
 +[[Scripting:Reference:system_functions:TownFunctions|Town information and control]]\\
 +Info about towns and functions to modify the status of town buildings \\
 +[[Scripting:Reference:system_functions:MathsFunctions|Maths Functions]]\\
 +Maths functions such as rand, sin, cos etc \\
 +[[Scripting:Reference:system_functions:EntityFunctions|Entity Functions]]\\
 +System for creating 'entities' in the world - these are models/objects that you can control from script, including the ability to set off standard behaviours such as 'attack the player'
 +[[Scripting:Reference:system_functions:MiscFunctions|Misc. other functions]]\\
 +General other uncategorised bits
  
-===== Text Functions ===== 
  
-==== sysGetPlayerName ==== 
-^ Format | sysGetPlayerName( [PlayerID] )| 
-^ Description | Returns the name of the specified player| 
-^ Parameters | Player ID | 
-^ Returns | Player Name | 
-//Example//: <note> 
-<code>Event( "UseItem", "Potion" ) 
-{ 
-    $targetName = sysGetPlayerName( $gTargetID ) 
-    *msg %PLAYER% You used the potion while targeting $targetName 
-} 
-</code> 
-</note> 
- 
-==== 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//: <note> 
-<code>Event( "UseItem", "Potion" ) 
-{ 
-    $itemNum = sysGetItemNum( "Potion" ) 
-    *msg %PLAYER% The item number is $itemNum 
-} 
-</code> 
-</note> 
- 
-==== 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//: <note> 
-<code>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 
-    } 
-} 
-</code> 
-</note> 
-==== 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//: <note> 
-<code>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     
-    } 
-} 
-</code> 
-</note> 
- 
-==== 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//: <note> 
-<code>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 
-    } 
-} 
-</code> 
-</note> 
-===== Battle game Functions ===== 
- 
-==== BattleSetPreludeTime ==== 
- 
-==== BattleSetNumRounds ==== 
- 
-==== BattleSetRoundTime ==== 
- 
-==== BattleSetRoundScore ==== 
- 
-==== BattleSendChallenge ==== 
- 
- 
-===== Maths Functions ===== 
- 
-==== sysRand ==== 
-^ Format | sysRand ( [MAX_NUM] )| 
-^ Description | Returns a random number between 1 and the value specified | 
-^ Example | ''**$var = Rand(500)**'' | 
- 
-==== sysSin ==== 
-^ Format | sysSin ( [ANGLE], [SCALE] )| 
-^ Description | Returns a sine value| 
-^ Parameters | Angle - 0 to 360 degrees | 
-^  | Scale - Scale applied to the result from the sine function (which normally returns a value from -1 to 1 | 
-^ Returns | Scaled sine value | 
-//Example//: <note> 
-<code>Event( "Custom", "TreeCircle" ) 
-{ 
-    $angle = 0 
-    while ( $angle < 360 ) 
-    { 
-        $posX = sysSin( $angle, 100 ) 
-        $posY = sysCos( $angle, 100 ) 
-        $posX += $gPlayerWorldX 
-        $posY += $gPlayerWorldY 
-        *addtree 1,$posX,$posY 
-        $angle += 36         
-    } 
-} 
-</code> 
-</note> 
- 
-==== sysCos ==== 
-^ Format | sysCos ( [ANGLE], [SCALE] )| 
-^ Description | Returns a cosine value| 
-^ Parameters | Angle - 0 to 360 degrees | 
-^  | Scale - Scale applied to the result from the cosine function (which normally returns a value from -1 to 1 | 
-^ Returns | Scaled cosine value | 
-//Example//: See sysSin above \\ 
-\\ 
- 
-==== sysGetDist ==== 
-^ Format | sysGetDist ( [X1], [Y1], [X2], [Y2] )| 
-^ Description | Calculates the distance between two points| 
-^ Parameters | Point 1 X,Y | 
-^  | Point 2 X,Y | 
-^ Returns | Distance | 
-//Example//: <note> 
-<code>Event( "AccessBuilding", "1" ) 
-{ 
-    $dist = sysGetDist( $gPlayerWorldX, $gPlayerWorldY, $gBuildingWorldX, $gBuildingWorldY ) 
-    *msg %PLAYER% You accessed the building from $dist cm away 
-} 
-</code> 
-</note> 
- 
-===== 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 | 
-//Example//: <note> 
-<code>Event( "UseItem", "Tea" ) 
-{ 
-   $hour = sysRealTime( "Hour" ) 
-   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! 
-    } 
-} 
-</code> 
-</note> 
- 
-==== sysRaceIsActive ==== 
-TBD \\ 
-\\ 
scripting/reference/system_functions.1580294540.txt.gz · Last modified: 2020/01/29 04:42 by mit

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