### OnCreateScript Example for New Character Setup Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/scripttypes.html This script executes when a new player character is created. It's useful for tasks like assigning starting equipment. It runs with critical priority and may require included utility scripts. ```ecl use uo; include "include/startEqp"; program oncreate( character ) CreateStartingEquipment(character, skillids); endprogram ``` -------------------------------- ### Server Startup Script Example (UO) Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/scripttypes.html This script runs once when the server starts. It's defined as inline code outside any function scope in the start.src file, typically used for initialization tasks or starting background processes. ```uo use uo; print("my package starting.."); //etc, your startup code! I'm so bad at examples. ``` -------------------------------- ### Start Script with Arguments (Dynamic Array) Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/098/Distro/docs/pol/escriptguide.html Illustrates starting a script by dynamically building an array of arguments before passing it. This approach is flexible for scenarios where arguments are determined at runtime. ```POL Server Script var parms := array; parms[1] := who; parms[2] := target1; parms[3] := target2; start_script("testscript" , parms); ``` -------------------------------- ### Start Script with Parameters (POL Script) Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/escriptguide.html Demonstrates two methods for starting a POL script with parameters: directly passing an array or constructing and passing an array. The script then shows how the target script can interpret these parameters as either an array or a scalar. ```POL Script start_script("testscript" , array{who, target1, target2}); // or, var parms := array; parms[1] := who; parms[2] := target1; parms[3] := target2; start_script("testscript" , parms); ``` ```POL Script program testscript(parms) if ( parms[2] ) //tests if it got passed an array char := parms[1]; firsttarget := parms[2]; secondtarget := parms[3]; else char := parms; endif // do stuff endprogram ``` -------------------------------- ### ECompile Configuration File Example Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/grouped-core-changes095.txt Shows an example of how to include other script files using the include directive and provides an example configuration file (ecompile.cfg.example) with various options. ```text usage: include ":pkgname:filebase"; New ecompile.cfg options: GenerateListing [0,1] GenerateDebugInfo [0,1] GenerateDebugTextInfo [0,1] ``` -------------------------------- ### View Script Profiles Example Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/performance.html An example eScript program that iterates through script profiles obtained from `polcore().script_profiles()`. It identifies and displays scripts that have run more than 5% of the total instructions on the shard. ```eScript program view_script_profiles(who) SendSysMessage(who, "Scripts that run a lot:"); var vscript_profiles := polcore().script_profiles; foreach script in vscript_profiles if (script.instr_percent > 5) SendSysMessage(who, script.name + " has run " + script.instr + " (" + script.instr_percent + "%) instructions, " + script.instr_per_invok + " at a time"); end if endforeach endprogram ``` -------------------------------- ### View Script Status Example Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/performance.html An eScript example that displays the status of all loaded scripts using `polcore().all_scripts()`. It iterates through the script information and sends messages to the specified recipient, showing PID, name, and various performance metrics. ```eScript program view_script_status(who) SendSysMessage(who, "Loaded scripts:"); var vall_script := polcore().all_scripts; foreach script in vall_scripts SendSysMessage(who, scripts.pid + ": " + script.name + " has run " + script.instr_cycles + " (" + script.consec_cycles + ", " + script.call_depth + ", " + script.num_globals + ")"); endforeach endprogram ``` -------------------------------- ### Start Script Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/094-Distro-RC/docs/commands.txt Starts a specified script. ```APIDOC ## .startscript [script name] ### Description Starts the specified script. ### Method Not Applicable (Script Command) ### Endpoint Not Applicable (Script Command) ### Parameters #### Path Parameters - **script name** (string) - The name of the script to start. #### Query Parameters None #### Request Body None ### Request Example `.startscript my_script` ### Response #### Success Response (200) No specific response documented, the script is initiated. #### Response Example None ``` -------------------------------- ### Logon Script Example Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/scripttypes.html Runs code when a player logs into the game server, typically used for welcome messages or initial setup. This script runs with critical priority, so code execution should be efficient. It's automatically called if the compiled file exists. ```ecl use uo; program logon( character ) SendSysmessage(character, "Welcome to POL."); Broadcast( character.name + " has entered the world."); endprogram ``` -------------------------------- ### Install Auction System Files Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/099/Distro/pkg/npcs/auction/readme.txt This section outlines the initial file copying steps for installing the auction system. It involves creating a specific directory and then copying the relevant system files into it. ```text create a directory \pol\pkg\opt\auction\ copy the files to that directory ``` -------------------------------- ### Installing the Party System Package Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/pkg/packetHooks/PartySystem/docs/readme.txt Instructions for installing the party system package involve copying the files to the packages directory and compiling them. The text also provides context on OSI's party system features and how to handle corpse looting checks. ```bash # Copy the files over to your packages directory and compile. # Example: cp -r /path/to/legacy_scripts/party_system /polserver/packages/ # Then compile the package within the POL server environment. ``` -------------------------------- ### POLScript Array Sorting - Example 2 Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/escriptguide.html Presents another example of array sorting, highlighting how gaps or uninitialized elements can affect the sorting outcome. ```POLScript a := array a[1] := 4 a[2] := 7 a[3] := "show" a[5] := "tunes" a.sort() ``` -------------------------------- ### Define Fishing Skill Constants Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/091-Distro/pkg/std/fishing/readme.txt Manually add these constants to `POL\scripts\include\objtype.inc` to define the start and end object types for shoes, which are relevant to the fishing skill. ```python const UOBJ_SHOE_START := 0x16f8; const UOBJ_SHOE_END := 0x1712; ``` -------------------------------- ### Startup Output Shortening Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/094.1-Distro/core-changes.txt The startup output for start.src will now be shorter, providing a more concise log during server initialization. ```plaintext # Server startup log update: # start.src output is now more concise. ``` -------------------------------- ### POL Configuration File Structure Example Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/098/Distro/docs/pol/configfiles.html Illustrates the general structure and syntax used in POL configuration files for defining elements and their properties. It shows how to denote required and optional fields, arbitrary values, and default values using specific punctuation. This is a descriptive example, not executable code. ```plaintext OnMount { [(int normal animation) (int mounted animation)]... } ArmorZone { Name (string zone name) Chance (int chance to hit) [Layer (int UO client layer)]... } [ArmorZone...] Attribute (Attribute_Name) { [Alias (Alias_Name)]... [GetIntrinsicModFunction (script_name:exported_func_name)] [Delay (Skill Delay for skills with buttons on Skill Window)] [Unhides (Unhides on skill use (0/1)] [Script (Location of script for skills with buttons on Skill Window)] } [Attribute...] ``` -------------------------------- ### S Member Command Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/094.1-Distro/docs/commands.txt Returns the value of a specified member of the targeted item or character. For example, to get the weight of an item. ```APIDOC ## SMember ### Description Returns the value of the specified member of the targeted item or character. ### Syntax `.smember [member name]` ### Example `.smember weight` ``` -------------------------------- ### Starting Scripts with Parameters in POL Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/escriptguide.html Demonstrates two methods for initiating a script named 'testscript' with parameters from another script. It shows direct parameter passing and passing parameters via an array. The script can handle receiving parameters as a scalar or an array. ```POL Script start_script( "testscript" , {who, target1, target2} ); ``` ```POL Script var parms := array; parms[1] := who; parms[2] := target1; parms[3] := target2; start_script( "testscript" , parms ); ``` ```POL Script program testscript( parms ) if (parms[2]) // tests if it got passed an array char := parms[1]; firsttarget := parms[2]; secondtarget := parms[3]; else char := parms; endif // do stuff endprogram ``` -------------------------------- ### Initializing and Manipulating Arrays in POLServer Scripts Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/escriptguide.html Covers the preferred method for initializing empty arrays and utilizes built-in array methods for manipulation. These methods include getting the size, inserting elements at specific indices, erasing elements, shrinking the array, appending elements, reversing, and sorting the array. The example illustrates how array indices and size are handled, including uninitialized gaps. ```polserver var a := array; // Equivalent to: var a := {}; ``` ```polserver var colours := array; colours[1] := "green"; colours[2] := "blue"; var csize := colours.Size(); colours[5] := "shiny"; csize := colours.Size(); ``` ```polserver colours.Insert(3, "bronze"); csize := colours.Size(); ``` -------------------------------- ### File Access Configuration Example Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/core-changes.txt Example configuration for `config/fileaccess.cfg`, demonstrating how to grant file access rights to packages based on read, write, append, and remote access permissions. ```config FileAccess { AllowRead 1 AllowRemote 1 Package testfileaccess Extension .cfg Extension .src } FileAccess { AllowWrite 1 AllowRemote 0 Package testfileaccess Extension .txt } FileAccess { AllowAppend 1 Package * Extension .log } ``` -------------------------------- ### POL/eScript Compile-Time Error Examples Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/escriptguide.html Illustrates common syntax errors detected by the eScript compiler (ecompile), such as unexpected tokens, incorrect assignments, missing keywords, and unmatched parentheses. These examples help identify issues before runtime. ```escript Error compiling statement at D:\\pd\\pol\\scripts\\items\\torch.src, Line 4 // This error was from a missing semicolon in an if-block on line 5 ``` ```escript Warning: Equals test result ignored. Did you mean := for assign? near: item.graphic = 0xa12; File: D:\\pd\\pol\\scripts\\items\\torch.src, Line 5 // ecompile guesses right here: we used an equals test when we wanted an assign statement ``` ```escript Warning! possible incorrect assignment. Near: if(item.graphic := 0x0f64) // ecompile catches this too, normally you wouldn't want to do an assignment in an if-condition. It is not an illegal statement, so ecompile completes the compile but warns you about it. ``` ```escript Unhandled reserved word: 'endprogram' Error compiling statement at D:\\pd\\pol\\scripts\\items\\torch.src, Line 7 Error in IF statement starting at File: D:\\pd\\pol\\scripts\\items\\torch.src, Line 4 // This error was we forgot an 'endif' keyword. The compile ran into the 'endprogram' keyword before 'endif', which is a syntax error. ``` ```escript Token 'item' cannot follow token ')' Error compiling statement at D:\\pd\\pol\\scripts\\items\\torch.src, Line 2 // This error was from an unmatched open-parenthesis in an if statement (on line 4) ``` ```escript Error compiling statement at D:\\pd\\pol\\scripts\\items\\torch.src, Line 2 Error detected in program body. // This is a nasty one, because it does not give you any idea what is wrong. I've only come across this error when a variable is declared with the same name as a keyword, in this case, 'for'. ``` -------------------------------- ### Tip System Implementation Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/core-changes-old.txt Support for a tip system has been added. Tips are implemented by creating .TXT files in the TIPS/ directory. These files are likely parsed and displayed to users through some in-game mechanism. ```plaintext # Create .TXT files in the TIPS/ directory for tips. ``` -------------------------------- ### Define Starting Locations in startloc.cfg Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/098/Distro/docs/pol/configfiles.html This configuration file defines the initial spawn points for new characters in a specific order matching the UO client's character creation screen: Yew, Minoc, Britain, Moonglow, Trinsic, Magincia, Jhelom, Skara Brae, Vesper. Each location includes a city name, description (max 30 chars), and X, Y, Z coordinates. ```ecl StartingLocation { City (string CityName) Description (string Description) Coordinate (int x),(int y),(int z) } [StartingLocation...] ``` -------------------------------- ### Lag Script Example Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/performance.html An eScript example demonstrating the use of `set_priority()` and `set_script_option()`. This program sets a high priority and disables runaway script warnings before entering nested loops, intended to simulate a script that consumes significant resources. ```eScript program lag_scripts(who) SendSysMessage(who, "That was not a good idea..."); var i,i2; set_priority(200); set_script_option(SCRIPTOPT_NO_RUNAWAY); for (i := 0; i < 100000; i := i + 1) for (i2 := 0; i2 < 100; i2 := i2 + 1) i2 := 122 + i2 + 12 * 12 - 22 + (5 * 5) - 25; endfor endfor SendSysMessage(who, "Phew..."); endprogram ``` -------------------------------- ### Auction System Startup Script in UO Source: https://context7.com/polserver/legacy_scripts/llms.txt A background service script designed to launch persistent game systems, specifically the auction list management. It utilizes UO and OS modules. ```c // start.src - Auction system startup Use uo; Use os; // Launch auction list management script start_script(":auction:auctionlist"); ``` -------------------------------- ### POL Console Log - Runaway Script Example Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/performance.html This snippet shows an example of a runaway script log message from the POL console. It includes the script's process ID, filename, and the number of cycles consumed, along with the execution line. ```log [01/12 21:47:36 script.log] Runaway script[3034]: scripts/textcmd/test/runawaysquare.ecl (160000 cycles) [01/12 21:47:36 script.log] 25: := [01/12 21:47:36 script.log] 26: # [01/12 21:47:37 script.log] 27: local #4 [01/12 21:47:37 script.log] 28: local #2 [01/12 21:47:37 script.log] 29: < [01/12 21:47:37 script.log] >30: if false goto 42 [01/12 21:47:37 script.log] 31: local #5 [01/12 21:47:38 script.log] 32: 1L [01/12 21:47:38 script.log] 33: + [01/12 21:47:38 script.log] 34: local5 := [01/12 21:47:38 script.log] 35: local #4 ``` -------------------------------- ### Server Configuration and Startup Options Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/094.1-Distro/core-changes.txt Information on new configuration file options and startup behaviors for the POL server. ```APIDOC ## Server Configuration and Startup ### Description This section outlines new settings in configuration files (`pol.cfg`, `config/servspecopt.cfg`) and changes to server startup behavior, including error handling and log file management. ### Method N/A (Configuration Settings) ### Endpoint N/A ### Parameters #### Configuration File: `pol.cfg` - **`MaxCallDepth`** (integer) - Optional - Specifies the maximum call depth allowed for scripts. Defaults to 100. - **`IgnoreLoadErrors`** (integer) - Optional - If set to `1`, the server will ignore most load errors and attempt to start. #### Configuration File: `config/servspecopt.cfg` - **`DefaultDoubleclickRange`** (integer) - Optional - Sets the default range for double-clicking objects if not specified in `itemdesc.cfg`. The default value is 2. ### Request Example ```ini # pol.cfg MaxCallDepth=200 IgnoreLoadErrors=1 # config/servspecopt.cfg DefaultDoubleclickRange=3 ``` ### Response #### Success Response (N/A) - **Startup Logging**: Error messages and other startup output are now logged to `start.log`. - **System Load Time**: Decreased system load time (users are advised to back up datafiles). #### Response Example N/A ``` -------------------------------- ### ExportedVitalsFunction - Vital Calculation Example Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/scripttypes.html This showcases an exported function used for calculating vital statistics for a character. Specifically, this example defines a function to get the maximum life value for a character. These functions are defined in vitals.cfg and typically include RegenRateFunction and MaximumFunction for each vital. ```uo //In a .src file, like regen.src: //vitals.cfg defines MaximumFunction regen:GetLifeMaximumValueExported , etc. //Life vital funcs: use uo; exported function GetLifeMaximumValueExported(mob) ``` -------------------------------- ### Method Script Example (itemdesc.cfg and .ecl/.src) Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/094-Distro-RC/core-changes.txt Demonstrates how to use 'MethodScript' in itemdesc.cfg to override or extend existing object methods with custom scripts. Includes examples for a door item and its corresponding script. ```cfg Door 0x0675 { xmod -1 ymod +1 script door doortype metal MethodScript cdoor.ecl } ``` ```ecl exported function open( door ) print( "cdoor::open(" + door.serial + ")" ); return door._open(); endfunction program install() print( "installing cdoor" ); return 1; endprogram ``` -------------------------------- ### eScript If-Statement Examples Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/escriptguide.html Illustrates various ways to form true expressions for if-statements in eScript, including comparison operators and logical operators. ```eScript var var1 := 10; var var2 := 5; if ( var1 > var2 ) //TRUE if ((var1 – 5) == var2) //TRUE if (var2 < var1) //TRUE if ((var2+5) >= var2) //TRUE if (var1 != var2) //TRUE ``` -------------------------------- ### Attribute and Vital Value Conversion Examples (Lua) Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/094.1-Distro/core-docs.txt Illustrates how older script syntax for accessing attributes and vitals can be converted to the new function-based system. Shows examples for getting attributes, setting temporary modifiers, and handling raw skill conversions. Assumes a Lua environment. ```lua -- GetSkill( mob, SKILLID_MINING ) -> GetAttribute( mob, "Mining" ) -- mob.strength -> GetAttribute( mob, "Strength" ) -- mob.strength_mod := 5 -> SetAttributeTemporaryMod( mob, "Strength", 50 ) -- SetRawSkill( mob, SKILLID_ALCHEMY, rawpoints ) -> SetAttributeBaseValue( mob, "alchemy", RawSkillToBaseSkill(rawpoints) ) -- GetRawSkill( mob, SKILLID_ALCHEMY ) -> BaseSkillToRawSkill( GetAttributeBaseValue, "Alchemy" ) ``` -------------------------------- ### MethodScript Example: Define custom method discombobulate Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/098/Distro/docs/pol/scripttypes.html This example shows how to define a new custom method 'discombobulate' for a 'widget' item. The method takes two parameters and returns 1 if the first parameter is greater than 3 and a message is printed. The 'install()' program must return 1 to enable exported functions. ```ecl // pkg/.../mypkg/widget_methods.src: program install() print("installing widget"); return 1; endprogram exported function discombobulate(flag1, message) //pass by reference here is ok too! if(flag1 > 3) print(message); return 1; endif return 0; endfunction // So now, in another script, if 'widget' is a reference to // item 0xE000, call like this: // widget.discombobulate(4,"Meaningless message"); ``` -------------------------------- ### eScript Function Call Example with Default Parameters Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/escriptguide.html Demonstrates calling a custom eScript function 'MyFunction' with various arguments, including calls where parameters are omitted, allowing default values to be used. The output shows how arguments are mapped and default values are applied. ```eScript program Main() var var1 = "dudes"; var var2 = "oingo"; var var3 = "boingo"; var var4 = "let's"; var var5 = 42; MyFunction( var1, var4 ); MyFunction( var2, var3 ); Myfunction( var5, var1 ); MyFunction( var3 ); MyFunction(); endprogram function MyFunction( a := "Yo yo", b := "hey hey" ) print( a + " " + b ); endfunction ``` -------------------------------- ### New Character Starting Clothing Configuration Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_POL_source/POL_2008/src/doc/core-changes-old.txt Notes that new characters will now automatically receive clothing that matches the display of the new client, simplifying initial character setup. ```Game Logic New characters will start with clothing that matches what the new client displays. ``` -------------------------------- ### Array Initialization and Assignment in POLScript Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/escriptguide.html Demonstrates initializing an array with values and assigning a specific value to an index. It also shows how to declare the size of an array. ```POLScript colours[1] = "green" colours[2] = "blue" colours[3] = "bronze" colours[4] = colours[5] = colours[6] = "shiny" csize = 6 ``` -------------------------------- ### POL Server Startup Error Handling (pol.cfg) Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_POL_source/POL_2008/src/doc/core-changes.txt This snippet illustrates the behavior change in pol.cfg when IgnoreLoadErrors is enabled (set to 1). Instead of halting startup, errors related to item placement or undefined object types are handled differently. Items that cannot be placed in containers or on characters will be destroyed, and items with undefined objtypes greater than 0x3FFF will not be loaded. ```cfg IgnoreLoadErrors=1 ``` -------------------------------- ### Get Item and Mobile Counts Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/performance.html Retrieves the total count of items and mobiles currently on the server. This can be used to monitor if item counts are increasing too rapidly or if the number of mobiles remains relatively stable. ```eScript polcore().itemcount() polcore().mobilecount() ``` -------------------------------- ### POL Server Configuration for Debugger Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_POL_source/POL_2008/src/doc/core-changes.txt No description ```text pol.cfg: DebugPort=port, DebugPassword=string, DebugLocalOnly=0/1 Only enabled if DebugPort if specified as non-zero. ``` -------------------------------- ### eScript Arithmetic Operations Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/escriptguide.html Illustrates the use of arithmetic operators (+, -, *, /, %, >>, <<) for calculations in eScript. It highlights the order of operations (parentheses first, then left-to-right) and provides examples of incrementing a variable and calculating remaining items. ```escript var pies_used := pies_used + 1; // Increment 'pies_used' by 1 var pies_left := number_of_trays * (pies_in_tray – pies_used); ``` -------------------------------- ### Start Script with Arguments (Array Literal) Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/098/Distro/docs/pol/escriptguide.html Demonstrates initiating a script named 'testscript' by passing arguments directly as an array literal. This method is suitable for a fixed number of known arguments. ```POL Server Script start_script("testscript" , array{who, target1, target2}); ``` -------------------------------- ### Spawnnet Startup Code (Commented) Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/092-Distro/pkg/std/spawnnet/notes...txt Provides a code snippet showing how to enable the new, untested startup code in Spawnnet. Users can enable this by commenting out the old startup code and uncommenting the new one in the source files. ```text #The new start-up code is not tested, but it's commented on the source, soo ig you want to give it a try just comment the old and uncomment the new one :-) ``` -------------------------------- ### Get Per-Minute Execution Counts Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/performance.html Provides the number of instructions, events, combat operations, and skill checks executed on the shard within the last minute. While these values can fluctuate, monitoring them can offer insights into server activity. ```eScript polcore().instr_per_min polcore().events_per_min polcore().combat_operations_per_min polcore().skill_checks_per_min ``` -------------------------------- ### Loop Control: Break and Continue Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/escriptguide.html Demonstrates the use of `break` to exit a loop prematurely and `continue` to skip the rest of the current iteration and proceed to the next. This example shows conditional `break` and `continue` within a `while` loop. ```eScript while ( condition != 0 ) if ( condition == 42 ) //oh geez! breakout! break; elseif ( condition == 13 ) //don't do the code below the if-block continue; endif condition := condition * something; endwhile ``` -------------------------------- ### Dictionary Initialization in POLScript Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/escriptguide.html Demonstrates the syntax for creating an empty dictionary variable in POLScript. ```POLScript var thing := dictionary ``` -------------------------------- ### Arena Configuration Example Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/090-Distro/pkg/opt/arena/readme.txt This snippet demonstrates the configuration structure for the arena object, defining its boundaries, potential spawn locations, and monster types with their respective levels and types. It's crucial to ensure the arena object is not located within the arena itself. ```cfg arenavendor arena { TopX 1385 TopY 3729 TopZ -21 BottX 1414 BottY 3758 Bottz -21 DestX 1407 DestY 3733 DestZ -21 DestX 1390 DestY 3751 DestZ -21 DestX 1388 DestY 3731 DestZ -21 Monster orc2 Level 2 Type 1 Monster liche Level 5 Type 1 Monster lizardman1 Level 2 Type 1 } ``` -------------------------------- ### eScript CASE Statement Syntax and Examples Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/098/Distro/docs/pol/escriptguide.html Illustrates the eScript CASE statement for handling multiple equality-based conditions efficiently. It contrasts the CASE statement with a lengthy IF-ELSEIF chain and shows its structure with comparison values and a default case. ```eScript const BLUE := 1; const YELLOW := 2; const RED := 3; const MAUVE := 4; // Ugly if-elseif way: function FunctionOne() var answer := WhatIsYourFavoriteColor(); if ( answer == BLUE ) // do stuff elseif ( answer == YELLOW ) // do stuff elseif ( answer == RED ) // do stuff elseif ( answer == MAUVE ) // do stuff else // do something else endif endfunction // Clean case Way: function FunctionTwo() var answer := WhatIsYourFavoriteColor(); case ( answer ) BLUE: //do stuff YELLOW: //do stuff RED: //do stuff MAUVE: //do stuff default: //do something else endcase endfunction // Example with fall-through (empty case): function FunctionThree() var answer := WhatIsYourFavoriteColor(); case ( answer ) BLUE: YELLOW: //do stuff for BLUE or YELLOW RED: //do stuff for RED endcase endfunction ``` -------------------------------- ### Get System Load Percentage and Severity Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/performance.html Retrieves the system load as a percentage (0-100) or a raw severity value. It's recommended to check this periodically to identify significant system issues. The percentage value is generally more interpretable than the raw number. ```eScript polcore().sysload() ``` -------------------------------- ### Door Methods and Properties Documentation Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/escriptguide.html Details the methods and properties for doors. Methods like open(), close(), and toggle() are provided, though noted as somewhat deprecated. The 'isopen' property indicates the door's state, with a workaround provided for accurate checking. ```N/A Methods: door.open() //Opens the door, even if it is locked door.close() //Closes the door door.toggle() //If the door is closed, opens it (even if it is locked), and vice versa Properties: isopen: 1=door is open, integer, read-only Note: if (door.graphic != door.objtype) // door is open ``` -------------------------------- ### Startup Output Reduction Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/core-changes.txt The startup output generated by `start.src` has been shortened to provide a more concise initialization log. ```C++ // Startup output for start.src will be shorter ``` -------------------------------- ### Pass by Value Function Call Example (POL Script) Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/escriptguide.html Illustrates the 'pass by value' mechanism in POL Server scripting. Variables passed to a function are copies, and modifications within the function do not affect the original variables outside its scope. ```POL Script var first := "one"; var second := 2; FallFunction(first ,second); function CallFunction (this, that) print(this); // will print "one" print(that); // will print "2" this := "green"; endfunction ``` -------------------------------- ### Custom Account Property Management in POL Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/097/Distro/docs/pol/escriptguide.html This snippet illustrates how to manage custom properties associated directly with player accounts, rather than specific characters. It shows the syntax for setting and getting these properties using `SetProp` and `GetProp` methods. ```POL Script account.SetProp("PropName",value); account.GetProp("PropName"); ``` -------------------------------- ### Get Bytes Sent and Received Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/performance.html Returns the total number of bytes sent and received. This information can be useful for monitoring bandwidth usage. By storing previous values, differences can be calculated over time to track network activity or detect potential bandwidth flooding. ```eScript polcore().bytes_sent() polcore().bytes_received() ``` -------------------------------- ### Start_Script() Function Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/osem.html Starts a new script running. It can optionally pass a single parameter to the new script. ```APIDOC ## Start_Script() ### Description Starts a new script running. You can pass an optional parameter to the script. **Tip**: Design your scripts to expect a struct or array as their only parameter, allowing you to pass multiple pieces of data. ### Method Start_Script ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **script_name** (String) - The name and path of the script to run. - **param** (Object) - An optional object to pass to the script. Only one parameter can be passed. ### Request Example ```json { "script_name": "path/to/your/script.ext", "param": { "key": "value" } } ``` ### Response #### Success Response - Returns a **Script** object for the started script on success. #### Response Example ```json { "scriptObject": { "id": "12345", "name": "path/to/your/script.ext" } } ``` #### Errors - "Error in script name" - "Script X does not exist." - "Unable to start script" - "Invalid parameter type" ``` -------------------------------- ### Array Initialization and Modification Example Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_POL_source/oldPOL2_2007/src/doc/core-changes.txt This example demonstrates the creation and modification of an array. It shows how to initialize an array with values and how assigning a value to a non-existent index automatically resizes the array. It also highlights the importance of checking array bounds before retrieval. ```js var arr := {1,2}; // create array with arr[1] and arr[2] arr[4] := "test"; // auto-enlarges to 4 indices (arr[3] is uninitialized) ``` -------------------------------- ### String Manipulation: Removing Characters in EScript Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/098/Distro/docs/pol/gumps.html This EScript example illustrates how to remove a specific number of characters from a string starting at a given position. This technique is used in the textentry_gump script to extract user input by removing an identifier prefix. ```escript var mystring := "I ate a hotdog"; mystring[9, 3] := ""; Now mystring contains: "I ate a dog". ``` -------------------------------- ### Configuration Handling Speedup Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_POL_source/POL_2008/src/doc/core-changes.txt Includes several optimizations to speed up system load times. This involves changes to how configuration files (e.g., spells.cfg, menus.cfg) are handled, including removing dependency on xlate.cfg and preloading certain scripts. ```config # Example of preloading scripts (internal change, no direct syntax shown) # equiptest and unequiptest scripts are now preloaded. ``` -------------------------------- ### Mount Creation from uoconvert.cfg Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_POL_source/POL_2008/src/doc/core-changes.txt Ensures that mounts listed in uoconvert.cfg are created even if they lack a tiledata.mul entry, fixing issues with mounts like 0x3ea2. ```escript Changed: Mounts listed in uoconvert.cfg that are not found to have tiledata.mul entries will now be created regardless. Should fix problems related to 0x3ea2 mount(perhaps others too), which has no tiledata.mul entry, yet is a valid mount graphic. ``` -------------------------------- ### Get Operations Per Minute Counts Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/095/Distro/docs/performance.html Returns the counts of various operations performed on the shard within the last minute, including instructions, events, combat operations, and skill checks. While these values can fluctuate significantly, monitoring them can provide insights into server activity. ```eScript polcore().instr_per_min() polcore().events_per_min() polcore().combat_operations_per_min() polcore().skill_checks_per_min() ``` -------------------------------- ### Update Fishing Skill Configuration in skills.cfg Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/090-Distro/pols090/pkg/std/fishing/readme.txt This section provides the updated entry for the Fishing skill (Skill 18) to be used in the POL server's skills configuration file. It replaces the existing entry to ensure correct functionality. ```text 18 Fishing ``` -------------------------------- ### Secure Trading and Startup Logging Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/094.1-Distro/core-changes.txt Introduces secure trading functionality (requires enabling) and stamina costs for movement. All startup output, including errors, will now be logged to 'start.log'. ```plaintext secure trading (but see important note about enabling) stamina costs for movement Startup output -- error messages, etc will be logged to 'start.log'. ``` -------------------------------- ### Configure GM Barter Ban Command Source: https://github.com/polserver/legacy_scripts/blob/master/legacy_Distros/releases/099/Distro/pkg/npcs/auction/readme.txt This section details the setup for a GM command to manage barter bans. By copying 'barterban.src' to the GM text command directory, GMs can toggle barter bans for players using '.barterban' and clicking on a player. ```text copy barterban.src to \pol\scripts\textcmd\gm\ to use type .barterban and click on player it will automatically turn on and off barterban for that player ``` -------------------------------- ### POL Configuration: Cooking Recipes Example Source: https://github.com/polserver/legacy_scripts/blob/master/alternatives/pol-099-core/icrontic/pkg/skills/cooking/notes.txt This example shows how recipes for secondary cooking ingredients are defined in the 'cooking.cfg' file. It specifies the required ingredients, the tool needed (if any), and the skill level required to successfully create the item. This format allows for easy expansion and modification of recipes. ```INI flour + water -> ball of dough | mixing bowl | 10 skill flour + honey -> sweet dough | mixing bowl | 20 skill flour + egg + honey -> cake batter | mixing bowl | 20 skill ```