File Constants:
// set_script_option constants
const SCRIPTOPT_NO_INTERRUPT := 1; // if 1, script runs until it sleeps
const SCRIPTOPT_DEBUG := 2; // if 1, prints any debug info included
const SCRIPTOPT_NO_RUNAWAY := 3; // if 1, doesn't warn about runaway conditions
const SCRIPTOPT_CAN_ACCESS_OFFLINE_MOBILES := 4;
const SCRIPTOPT_AUXSVC_ASSUME_STRING := 5;
Functions:
- Clear_Event_Queue
- Create_Debug_Context
- Debugger
- Events_Waiting
- GetPid
- GetProcess
- HTTPRequest
- Is_Critical
- OpenConnection
- OpenURL
- PerformanceMeasure
- Run_Script
- Run_Script_To_Completion
- Set_Critical
- Set_Debug
- Set_Event_Queue_Size
- Set_Priority
- Set_Script_Option
- Sleep
- Sleepms
- Start_Script
- Start_Skill_Script
- SysLog
- System_RPM
- Unload_Scripts
- Wait_For_Event
Modules:
-
[+] Attribute
- AlterAttributeTemporaryMod
- BaseSkillToRawSkill
- CheckSkill
- GetAttribute
- GetAttributeBaseValue
- GetAttributeCap
- GetAttributeDefaultCap
- GetAttributeIntrinsicMod
- GetAttributeLock
- GetAttributeName
- GetAttributeTemporaryMod
- RawSkillToBaseSkill
- SetAttributeBaseValue
- SetAttributeCap
- SetAttributeLock
- SetAttributeTemporaryMod
- [+] Basic
- [+] BasicIO
- [+] Boat
- [+] CfgFile
- [+] CliLoc
- [+] DataFile
- [+] File
- [+] Guild
- [+] Http
- [+] Math
-
[+] Npc
- CanMove
- Face
- GetProperty
- IsLegalMove
- MakeBoundingBox
- Move
- RunAwayFrom
- RunAwayFromLocation
- RunToward
- RunTowardLocation
- Say
- SayUC
- Self
- SetAnchor
- SetOpponent
- SetProperty
- SetWarMode
- TurnAwayFrom
- TurnAwayFromLocation
- TurnToward
- TurnTowardLocation
- WalkAwayFrom
- WalkAwayFromLocation
- WalkToward
- WalkTowardLocation
- Wander
-
[+] OS
- Clear_Event_Queue
- Create_Debug_Context
- Debugger
- Events_Waiting
- GetPid
- GetProcess
- HTTPRequest
- Is_Critical
- OpenConnection
- OpenURL
- PerformanceMeasure
- Run_Script
- Run_Script_To_Completion
- Set_Critical
- Set_Debug
- Set_Event_Queue_Size
- Set_Priority
- Set_Script_Option
- Sleep
- Sleepms
- Start_Script
- Start_Skill_Script
- SysLog
- System_RPM
- Unload_Scripts
- Wait_For_Event
- [+] Party
- [+] PolSys
- [+] Storage
- [+] MySQL
- [+] Unicode
-
[+] UO
- Accessible
- AddAmount
- AddMenuItem
- ApplyConstraint
- AssignRectToWeatherRegion
- Attach
- Broadcast
- CanWalk
- CancelTarget
- CheckLineOfSight
- CheckLosAt
- CheckLosBetween
- CloseGump
- CloseTradeWindow
- CloseWindow
- ConsumeReagents
- ConsumeSubstance
- CoordinateDistance
- CoordinateDistanceEuclidean
- CreateAccount
- CreateItemAtLocation
- CreateItemCopyAtLocation
- CreateItemInBackpack
- CreateItemInContainer
- CreateItemInInventory
- CreateMenu
- CreateMultiAtLocation
- CreateNpcFromTemplate
- DestroyItem
- DestroyMulti
- Detach
- DisableEvents
- DisconnectClient
- Distance
- DistanceEuclidean
- EnableEvents
- EnumerateItemsInContainer
- EnumerateOnlineCharacters
- EquipFromTemplate
- EquipItem
- EraseGlobalProperty
- EraseObjProperty
- FindAccount
- FindObjtypeInContainer
- FindPath
- FindSubstance
- GetAmount
- GetCommandHelp
- GetCoordsInLine
- GetEquipmentByLayer
- GetFacing
- GetGlobalProperty
- GetGlobalPropertyNames
- GetHarvestDifficulty
- GetMapInfo
- GetMenuObjTypes
- GetMidpointCircleCoords
- GetMultiDimensions
- GetObjProperty
- GetObjPropertyNames
- GetObjType
- GetObjTypeByName
- GetRegionLightLevelAtLocation
- GetRegionName
- GetRegionNameAtLocation
- GetRegionString
- GetSpellDifficulty
- GetStandingHeight
- GetStandingLayers
- GetWorldHeight
- GrantPrivilege
- HarvestResource
- IsStackable
- ListAccounts
- ListEquippedItems
- ListGhostsNearLocation
- ListHostiles
- ListItemsAtLocation
- ListItemsNearLocation
- ListItemsNearLocationOfType
- ListItemsNearLocationWithFlag
- ListMobilesInBox
- ListMobilesInLineOfSight
- ListMobilesNearLocation
- ListMobilesNearLocationEx
- ListMultisInBox
- ListObjectsInBox
- ListOfflineMobilesInRealm
- ListStaticsAtLocation
- ListStaticsInBox
- ListStaticsNearLocation
- MoveItemToContainer
- MoveItemToSecureTradeWin
- MoveObjectToLocation
- OpenPaperdoll
- POLCore
- PerformAction
- PlayLightningBoltEffect
- PlayMovingEffect
- PlayMovingEffectEx
- PlayMovingEffectXYZ
- PlayMovingEffectXYZEx
- PlayMusic
- PlayObjectCenteredEffect
- PlayObjectCenteredEffectEx
- PlaySoundEffect
- PlaySoundEffectPrivate
- PlaySoundEffectXYZ
- PlayStationaryEffect
- PlayStationaryEffectEx
- PrintTextAbove
- PrintTextAbovePrivate
- ReadGameClock
- RegisterForSpeechEvents
- ReleaseItem
- RequestInput
- ReserveItem
- RestartScript
- Resurrect
- RevokePrivilege
- SaveWorldState
- SecureTradeWin
- SelectColor
- SelectMenuItem2
- SendBuyWindow
- SendCharProfile
- SendCharacterRaceChanger
- SendDialogGump
- SendEvent
- SendHousingTool
- SendInstaResDialog
- SendOpenBook
- SendOpenSpecialContainer
- SendOverallSeason
- SendPacket
- SendPopUpMenu
- SendQuestArrow
- SendSellWindow
- SendSkillWindow
- SendStatus
- SendStringAsTipWindow
- SendSysMessage
- SendTextEntryGump
- SendViewContainer
- SetGlobalProperty
- SetName
- SetObjProperty
- SetRegionLightLevel
- SetRegionWeatherLevel
- SetScriptController
- Shutdown
- SingleClick
- SpeakPowerWords
- StartSpellEffect
- SubtractAmount
- SystemFindObjectBySerial
- Target
- TargetCoordinates
- TargetMultiPlacement
- UpdateItem
- UpdateMobile
- UseItem
- [+] Util
- [+] Vitals
Clear_Event_Queue() | |
---|---|
Explanation | |
Empties the current script's event queue | |
Return values | |
1 on success |
Create_Debug_Context() | |
---|---|
Explanation | |
TBD | |
Return values | |
TBD |
Debugger() | |
---|---|
Explanation | |
puts the script in debug state | |
Return values | |
1 on success |
Events_Waiting() | |
---|---|
Explanation | |
Returns the number of events waiting in the event queue for this script. | |
Return values | |
Integer number of events waiting |
GetProcess(pid := 0) | |
---|---|
Parameters: | |
Name | Type |
pid | Integer process ID of a script (optional) |
Explanation | |
Gets a script process object for the given script's PID. | |
If no PID is supplied uses PID of parent script. | |
Return values | |
A Script object | |
Errors | |
"Process not found" | |
"Invalid parameter type" | |
Related | |
Script |
HTTPRequest(url, method := "GET", options := struct{}) | |
---|---|
Parameters: | |
Name | Type |
url | URL |
method | HTTP Method to use for request (eg. GET, POST) |
options | A struct containing options for the request. Available options are: 'data', a string representing the POST data; 'headers', a struct containing headers to send, where the key is the header's name and value is the header's value |
Explanation | |
Creates an HTTP request, and returns the returned data as a string. | |
Return values | |
Response data as a string. |
Is_Critical() | |
---|---|
Explanation | |
Returns true if the script is critical (by using set_critical()) | |
Return values | |
1 if critical, else 0. |
OpenConnection( host, port, scriptdef, params ) | |
---|---|
Parameters: | |
Name | Type |
host | Target host |
port | Target port |
scriptdef | Name of the script to be started when the connection is established |
params | A struct of parameters to be sent to the script |
assume_string | Integer if set to 1 all communication from connection will be sent/received as raw strings. |
Explanation | |
Creates an outgoing TCP/IP connection to the host/port, once connection is open the scriptdef is run and | |
any params defined in the struct will be passed to that script. The script type should be in the form of an Auxilry Script. | |
Return values | |
1 on success |
OpenURL( character, url ) | |
---|---|
Parameters: | |
Name | Type |
character | Player Character Ref |
url | String |
Explanation | |
Sends an Open URL packet to the client, to open the url in their Default Browser. | |
Return values | |
1 on success | |
Errors | |
"No client attached" |
PerformanceMeasure(delta_seconds := 10, max_scripts := 100) | |
---|---|
Parameters: | |
Name | Type |
delta_seconds | seconds to observe |
max_scripts | maximum number of scripts to be returned |
Explanation | |
Monitors for given number of seconds the instructions of all scripts. | |
Returns struct with the following members: | |
total_number_observed : number of scripts alive in the timespan | |
total_instructions : sum of all instructions of the observed scripts | |
scripts : array of structs (max number is given max_scripts param) sorted by instructions amount | |
each scripts entry has the following members: | |
name : script name, if attached with name/npctemplate | |
instructions : number of executed instructions | |
pid : PID of the script | |
percent : percent of the total instruction amount | |
Return values | |
see above |
Run_Script( script_name, param := 0 ) | |
---|---|
Parameters: | |
Name | Type |
script_name | String name and path of script to run |
param | object to pass to the script. Only one param may be passed. (optional) |
Explanation | |
Starts a new NON-CRITICAL script. Runs until the script exits, returns the return value of the started script. | |
Tip: write your script to expect a struct or array as its only parameter, so you may pass multiple pieces of data through the struct or array. | |
Return values | |
The return value of the started script, or 1 if no value was returned | |
Errors | |
"Unable to read script" | |
"Script exited with an error condition" | |
"Script does not exist" | |
"Script descriptor error" |
Run_Script_To_Completion( script_name, param := 0 ) | |
---|---|
Parameters: | |
Name | Type |
script_name | String name and path of script to run |
param | object to pass to the script. Only one param may be passed. (optional) |
Explanation | |
Starts a new CRITICAL script. Runs until the script exits, returns the return value of the started script. | |
Tip: write your script to expect a struct or array as its only parameter, so you may pass multiple pieces of data through the struct or array. | |
Every 1000 instructions, "Script X running.." is printed to the console | |
Return values | |
The return value of the started script, or 1 if no value was returned | |
Errors | |
"Unable to read script" | |
"Script exited with an error condition" | |
"Script does not exist" | |
"Script descriptor error" |
Set_Critical( critical ) | |
---|---|
Parameters: | |
Name | Type |
critical | Boolean (0/1) |
Explanation | |
critical scripts run if they are not blocked, without interruption. | |
An infinite loop in a critical script will hang the server | |
Use this in blocks by setting 'critical' to 1 before the critical code and to 0 after it. | |
Use this function sparingly, only in parts of code that must execute without interruption | |
Return values | |
1 on success | |
Errors | |
"Invalid parameter type" |
Set_Debug( debug ) | |
---|---|
Parameters: | |
Name | Type |
debug | Boolean (0/1) |
Explanation | |
if debug=1, and the script was compiled with 'ecompile -i [script].src', each script source line will be printed as it is executed. | |
if debug=0, disables this output. | |
Return values | |
1 on success | |
Errors | |
"Invalid parameter type" |
Set_Event_Queue_Size(size) | |
---|---|
Parameters: | |
Name | Type |
size | Integer new size |
Explanation | |
Changes the maximum number of events the current script will keep in the queue (additional events will be discarded). | |
If not called, the default size is 20 events. | |
Return values | |
Integer old queue size. | |
Errors | |
"Invalid parameter type" |
Set_Priority( priority ) | |
---|---|
Parameters: | |
Name | Type |
priority | Integer 1..255 |
Explanation | |
the priority of a script is how many instructions it executes before switching to another script. | |
default script priority is 1. | |
Return values | |
Integer previous priority | |
Errors | |
"Invalid parameter type" |
Set_Script_Option( optnum, optval ) | |
---|---|
Parameters: | |
Name | Type |
optnum | Integer constant |
optval | boolean (0/1) |
Explanation | |
Sets one or more options on or off for this script | |
Constants for this function: | |
const SCRIPTOPT_NO_INTERRUPT := 1; // if 1, script runs until it sleeps const SCRIPTOPT_DEBUG := 2; // if 1, prints any debug info included const SCRIPTOPT_NO_RUNAWAY := 3; // if 1, doesn't warn about runaway conditions const SCRIPTOPT_CAN_ACCESS_OFFLINE_MOBILES := 4; | |
set_script_option(SCRIPTOPT_NO_INTERRUPT,1) is the same as set_critical(1) | |
set_script_option(SCRIPTOPT_DEBUG,1) is the same as set_debug(1) | |
Return values | |
previous value | |
Errors | |
"Unknown Script Option" | |
"Invalid parameter type" |
Sleep( num_seconds ) | |
---|---|
Parameters: | |
Name | Type |
num_seconds | Integer |
Explanation | |
Puts the current script to sleep for num_seconds. No further instructions in this script will be processed in this script until the time expires. | |
DO NOT USE IN A CRITICAL BLOCK! Your server will freeze for the duration! | |
If this script is attached to a character (like a UseScript), calling detach() before the sleep will allow other scripts to run while this script sleeps. | |
Return values | |
0 after sleep |
Sleepms( num_milliseconds ) | |
---|---|
Parameters: | |
Name | Type |
num_milliseconds | Integer |
Explanation | |
Puts the current script to sleep for num_milliseconds. No further instructions in this script will be processed in this script until the time expires. | |
DO NOT USE IN A CRITICAL BLOCK! Your server will freeze for the duration! | |
If this script is attached to a character (like a UseScript), calling detach() before the sleep will allow other scripts to run while this script sleeps. | |
You're not likely to get any faster resolution than 10ms | |
Return values | |
0 after sleep |
Start_Script( script_name, param := 0 ) | |
---|---|
Parameters: | |
Name | Type |
script_name | String name and path of script to run |
param | object to pass to the script. Only one param may be passed. (optional) |
Explanation | |
Starts a new script running. | |
Tip: write your script to expect a struct or array as its only parameter, so you may pass multiple pieces of data through the struct or array. | |
Return values | |
A Script object for the started script on success. | |
Errors | |
"Error in script name" | |
"Script X does not exist." | |
"Unable to start script" | |
"Invalid parameter type" | |
Related | |
Script |
Start_Skill_Script( chr, attr_name, script_name := 0, param := 0 ) | |
---|---|
Parameters: | |
Name | Type |
chr | Character to start the script for |
attr_name | AttributeID to start the script for |
script_name | If given, starts this script instead of the default one |
param | object to pass to the script. Only one param may be passed. (optional) |
Explanation | |
starts for given chr and attr_name definied script (overrideable with param script_name) | |
param is any UObject given to skill script as second param (first is chr) | |
performs the same checks like normal skillusage (death,frozen,skilldelay,...) | |
Tip: write your script to expect a struct or array as its only parameter, so you may pass multiple pieces of data through the struct or array. | |
Return values | |
A Script object for the started script on success. | |
Related | |
Script |
SysLog( text ) | |
---|---|
Parameters: | |
Name | Type |
text | String |
Explanation | |
write text to the console, and to the log file includes context (calling script name) | |
Return values | |
1 on success |
System_RPM() | |
---|---|
Explanation | |
returns the system RPM, which is the number of "game loop rotations" completed in the last minute. | |
Return values | |
Last System RPM integer |
Unload_Scripts(scriptname := "") | |
---|---|
Parameters: | |
Name | Type |
scriptname | String filename of script without extension (optional) |
Explanation | |
unload scripts from the script cache (they will be reloaded from disk on demand) currently running scripts will continue as normal. | |
Passing "" will unload all scripts. | |
Return values | |
Number of scripts unloaded | |
Errors | |
"Invalid parameter type" | |
Related | |
Script |
Wait_For_Event( num_seconds_timeout ) | |
---|---|
Parameters: | |
Name | Type |
num_seconds_timeout | Integer |
Explanation | |
The primary access to a script's event queue. If there is an event waiting, the function immediately returns with the event (could be a string, int, struct, etc). | |
If no event is waiting, the script sleeps for num_seconds_timeout or until a new event arrives. If the timeout is reached, the function returns 0. | |
if timeout is 0, returns immediately | |
Return values | |
object on event recv, 0 on timeout |