### GlobalEvent onStartup Example Source: https://github.com/otland/forgottenserver/wiki/Revscriptsys Execute custom logic when the server starts. This function should return true if the event was handled. ```lua local globalevent = GlobalEvent("example") function globalevent.onStartup() broadcastMessage("Server started!", MESSAGE_STATUS_DEFAULT) return true end globalevent:register() ``` -------------------------------- ### Install Dependencies Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-FreeBSD Installs Git, CMake, and necessary libraries for The Forgotten Server using pkg. ```bash # pkg install git cmake luajit gmp mysql-connector-c pugixml ``` -------------------------------- ### onStartup Event - Store Towns in Database Source: https://github.com/otland/forgottenserver/wiki/Interface:Global-Events Executes when the server starts up. This example initializes the random seed and stores town data in the database by truncating and re-inserting town information. ```Lua function onStartup() math.randomseed(os.mtime()) -- store towns in database db.query("TRUNCATE TABLE `towns`") for i, town in ipairs(Game.getTowns()) do local position = town:getTemplePosition() db.query("INSERT INTO `towns` (`id`, `name`, `posx`, `posy`, `posz`) VALUES (" .. town:getId() .. ", " .. db.escapeString(town:getName()) .. ", " .. position.x .. ", " .. position.y .. ", " .. position.z .. ")") end end ``` -------------------------------- ### Install Required Software Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Fedora Installs Git, CMake, a C++ compiler, and necessary development libraries for The Forgotten Server on Fedora. ```bash sudo dnf install git cmake gcc-c++ boost-devel community-mysql-devel lua-devel pugixml-devel cryptopp-devel make fmt-devel ``` -------------------------------- ### Configure Build Files with CMake (GUI Example) Source: https://github.com/otland/forgottenserver/wiki/Compiling Example configuration steps for CMake GUI to generate build files. Specify the source and build directories correctly. ```text "Where is the source code: ~/forgottenserver" "Where to build the binaries: ~/forgottenserver/build/" ``` -------------------------------- ### Install Libraries for 64-bit Build Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Windows-(vcpkg) Installs the necessary libraries for a 64-bit build of the project using vcpkg. Ensure vcpkg is in your PATH or run from its directory. ```bash .\vcpkg install --triplet x64-windows boost-iostreams boost-asio boost-system boost-variant boost-lockfree boost-locale boost-beast boost-json luajit libmariadb pugixml openssl fmt zlib ``` -------------------------------- ### Install Required Software and Libraries Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Mac-OS-X Installs Git, CMake, and essential libraries for The Forgotten Server using Homebrew. Git is for downloading source code, and CMake generates build files. ```shell brew install git cmake gmp mysql-client luajit boost pugixml pkg-config fmt ``` -------------------------------- ### Install Required Software Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Debian-GNU-Linux Installs Git, CMake, build tools, and necessary libraries for The Forgotten Server. Use libmysqlclient-dev on Debian 8 and below. ```bash # apt-get install git cmake build-essential libluajit-5.1-dev libmariadb-dev-compat libboost-date-time-dev libboost-system-dev libboost-iostreams-dev libpugixml-dev libcrypto++-dev libfmt-dev zlib1g-dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Gentoo Installs Git, CMake, Boost, MySQL Connector/C++, LuaJIT, and Pugixml using the Gentoo package manager (emerge). ```bash emerge dev-vcs/git dev-util/cmake dev-libs/boost dev-db/mysql-connector-c++ dev-lang/luajit dev-libs/pugixml ``` -------------------------------- ### Type Naming Convention Example Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Provides an example of the recommended naming convention for type names, which start with a capital letter and use CamelCase for subsequent words. ```cpp exa::ChronoTimer fpsTimer; ``` -------------------------------- ### onUse() Event Example (Lua) Source: https://github.com/otland/forgottenserver/wiki/Interface:Actions This is a placeholder for the onUse() event example. The actual implementation is not provided in the source. ```Lua N/A ``` -------------------------------- ### Install Libraries for 32-bit Build Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Windows-(vcpkg) Installs the necessary libraries for a 32-bit (Win32) build of the project using vcpkg. Ensure vcpkg is in your PATH or run from its directory. ```bash .\vcpkg install boost-iostreams boost-asio boost-system boost-variant boost-lockfree boost-locale boost-beast boost-json luajit libmariadb pugixml openssl fmt zlib ``` -------------------------------- ### Start Raid Source: https://github.com/otland/forgottenserver/wiki/Functions Starts a specified raid if it exists. Returns true if the raid was successfully started. ```Lua if Game.startRaid("test") then -- Raid was started. end ``` -------------------------------- ### Install Required Software on Ubuntu Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Ubuntu Installs Git, CMake, a compiler, and necessary libraries for The Forgotten Server. Includes an additional package for Ubuntu 20.04. ```bash sudo apt install git cmake build-essential libluajit-5.1-dev libmysqlclient-dev libboost-system-dev libboost-iostreams-dev libpugixml-dev libcrypto++-dev libfmt-dev ``` ```bash sudo apt install libboost-date-time-dev ``` -------------------------------- ### GlobalEvent.onStartup Source: https://github.com/otland/forgottenserver/wiki/Revscriptsys Callback function triggered when the server starts up. ```APIDOC ## GlobalEvent("name").onStartup ### Description Callback function triggered when the server starts up. ### Returns - boolean: Indicates if the event was handled. ### Example ```lua local globalevent = GlobalEvent("example") function globalevent.onStartup() broadcastMessage("Server started!", MESSAGE_STATUS_DEFAULT) return true end globalevent:register() ``` ``` -------------------------------- ### Install Dependencies on Arch Linux Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Arch-Linux Installs essential development tools and libraries required for compiling The Forgotten Server using pacman. ```bash $ sudo pacman -Syu $ sudo pacman -S base-devel git cmake luajit boost boost-libs libmariadbclient pugixml crypto++ fmt ``` -------------------------------- ### Start Forgotten Server with Docker Compose Source: https://github.com/otland/forgottenserver/wiki/Docker-Compose Starts the Forgotten Server and its associated database in detached mode. ```bash docker-compose up -d ``` -------------------------------- ### Manually Install Crypto++ Library Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Mac-OS-X Installs the Crypto++ library manually as it's no longer available via Homebrew. Ensure you use the latest version. This process involves downloading, unzipping, compiling, and installing the library. ```shell wget https://github.com/weidai11/cryptopp/archive/refs/tags/CRYPTOPP_8_5_0.zip unzip CRYPTOPP_8_5_0.zip && cd cryptopp-CRYPTOPP_8_5_0 make shared all make install ``` -------------------------------- ### Event Callbacks Example Source: https://github.com/otland/forgottenserver/wiki/Changelog-1.4 Shows an example of a Creature event callback. These hooks are located in the 'data/events' folder. ```lua local creatureEvent = CreatureEvent('onHear') function creatureEvent.onHear(speaker, words, type) print('Creature heard: ' .. words) return true end creatureEvent:create() ``` -------------------------------- ### Composition Example Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Shows an example of composition in C++, where a class contains instances of other classes as members. ```cpp Class Manager { // The Manager object is composed as an Employee and a Person. private m_Title; private m_Employee; ... public Manager(Person p, Employee e) { m_Title = e.Title; m_Employee = e; ... } } ``` -------------------------------- ### Inheritance Example Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Demonstrates the syntax for public multiple inheritance in C++. ```cpp class Manager : Person, Employee { // The Manager object is inherited from Employee and Person. ... } ``` -------------------------------- ### Outfit Comparison Example Source: https://github.com/otland/forgottenserver/wiki/Changelog-1.4 Demonstrates how to compare two Outfit objects for equality. ```lua local outfit1 = Outfit(100) local outfit2 = Outfit(100) if outfit1 == outfit2 then print('Outfits are the same.') end ``` -------------------------------- ### onCreatureAppear Event Example Source: https://github.com/otland/forgottenserver/wiki/Interface:NPCs This snippet represents the 'onCreatureAppear' event. The example provided is marked as N/A, indicating no specific code implementation is shown. ```Lua N/A ``` -------------------------------- ### Install Dependencies on CentOS 7 Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-CentOS Installs essential development packages for the Forgotten Server on CentOS 7, including git, cmake, compilers, and various libraries. ```bash $ sudo yum install epel-release # for cmake3 luajit pugixml-devel ``` ```bash $ sudo yum install git boost-devel cmake3 cryptopp-devel gcc-c++ gmp-devel lua-devel luajit mariadb-devel pugixml-devel ``` -------------------------------- ### Game.startRaid Source: https://github.com/otland/forgottenserver/wiki/Functions Starts a specified raid if it exists. ```APIDOC ## Game.startRaid(raidName) ### Description Starts a raid if one with said name exist. ### Parameters #### Path Parameters * **raidName** (string) - Required - Name of the raid. ### Returns true if the raid started, nil otherwise. ### Request Example ```Lua if Game.startRaid("test") then -- Raid was started. end ``` ``` -------------------------------- ### Include Order Example Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Demonstrates the recommended order for including header files in C++ source files. ```cpp #include "otpch.h" // precompiled header #include "signals.h" // header for the current compilation unit #include "actions.h" // other project headers #include "configmanager.h" #include "databasetasks.h" #include // system headers ``` -------------------------------- ### Install Homebrew Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Mac-OS-X Installs Homebrew, a package manager for Mac OS X, which is used to compile software. Run this command in the Terminal. ```shell /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ``` -------------------------------- ### Unscoped Enumerator Example Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Shows an example of an unscoped enumeration with an optional prefix, noting that 'enum class' is preferred. ```cpp enum AlternateUrlTableErrors { OK = 0, OUT_OF_MEMORY = 1, MALFORMED_INPUT = 2, }; // Allowed enum Color { COLOR_RED, COLOR_GREEN, COLOR_BLUE }; ``` -------------------------------- ### Install Dependencies on CentOS 8 Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-CentOS Installs essential development packages for the Forgotten Server on CentOS 8, including git, cmake, compilers, and various libraries. ```bash $ sudo dnf install epel-release # for luajit pugixml-devel cryptopp-devel ``` ```bash $ sudo dnf install git boost-devel make cmake3 cryptopp-devel gcc-c++ gmp-devel lua-devel luajit mariadb-devel pugixml-devel fmt ``` -------------------------------- ### Integrate vcpkg with System Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Linux-&-Mac-OS-X-(vcpkg) Installs vcpkg integration for the system, making it easier to manage packages. ```bash ./vcpkg integrate install ``` -------------------------------- ### Action Script onUse Example with Item Transformation Source: https://github.com/otland/forgottenserver/wiki/Revscriptsys A detailed example of an Action script's onUse function. It checks for a specific item ID, transforms it, makes it decay, and creates a new item. If the condition is not met, it destroys the target item. ```lua local action = Action() function action.onUse(player, item, fromPosition, target, toPosition, isHotkey) if target.itemid == 2739 then target:transform(2737) target:decay() Game.createItem(2694, 1, toPosition) return true end return destroyItem(player, target, toPosition) end action:id(2550) action:register() ``` -------------------------------- ### Get Guild Owner GUID Source: https://github.com/otland/forgottenserver/wiki/Metatable:Guild Retrieves the player GUID of the guild leader. This is useful for verifying leadership. ```Lua local player = Player(...) local guild = player:getGuild() if guild and player:getGUID() == guild:getOwnerGUID() then print("Player: " .. player:getName() .. " is the Guild Leader of: " .. guild:getName()) end ``` -------------------------------- ### sendTutorial(tutorialId) Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Sends a tutorial message or guide to the player. Used for onboarding or explaining game mechanics. ```APIDOC ## sendTutorial(tutorialId) ### Description Sends a tutorial message or guide to the player. ### Method `Player:sendTutorial(tutorialId)` ### Parameters * **tutorialId** - No description ### Response N/A ### Example ```lua local player = Player(...) player:sendTutorial(unknown) ``` ``` -------------------------------- ### onAddItem Event Example Source: https://github.com/otland/forgottenserver/wiki/Interface:Movements Placeholder for the onAddItem event handler. No specific implementation is provided. ```Lua N/A ``` -------------------------------- ### Install vcpkg and Integrate with System Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Windows-(vcpkg) Clones the vcpkg repository, bootstraps it, and integrates it with your system for package management. May require administrator privileges. ```bash git clone https://github.com/Microsoft/vcpkg && cd vcpkg && .\bootstrap-vcpkg.bat && .\vcpkg integrate install ``` -------------------------------- ### Get Player GUID Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Retrieves the unique global identifier (GUID) for the player. This is often used for persistent storage or identification. ```Lua local player = Player(...) player:getGuid() ``` -------------------------------- ### Get House Owner GUID Source: https://github.com/otland/forgottenserver/wiki/Metatable:House Retrieves the unique identifier (GUID) of the player who owns the house. Returns nil if the house is not owned by a player. ```Lua local house = House(...) house:getOwnerGuid() ``` -------------------------------- ### Get Vocation Attack Speed Source: https://github.com/otland/forgottenserver/wiki/Metatable:Vocation Retrieves the attack speed of a vocation. No specific setup or imports are required beyond instantiating the Vocation object. ```Lua local vocation = Vocation(...) vocation:getAttackSpeed() ``` -------------------------------- ### Bootstrap vcpkg Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Linux-&-Mac-OS-X-(vcpkg) Initializes vcpkg for use on the system. ```bash ./bootstrap-vcpkg.sh ``` -------------------------------- ### Get Invitees Source: https://github.com/otland/forgottenserver/wiki/Metatable:Party Retrieves a list of players who are currently invited to the party. ```Lua local party = Party(...) party:getInvitees() ``` -------------------------------- ### Get Top Visible Creature - Lua Source: https://github.com/otland/forgottenserver/wiki/Metatable:Tile Retrieves the topmost visible creature on the tile, starting from a given creature. Useful for targeting or interaction logic. ```Lua local tile = Tile(...) tile:getTopVisibleCreature(some_userdata) ``` -------------------------------- ### Get Top Visible Thing - Lua Source: https://github.com/otland/forgottenserver/wiki/Metatable:Tile Retrieves the topmost visible thing (item or creature) on the tile, starting from a given creature. Useful for visual ordering. ```Lua local tile = Tile(...) tile:getTopVisibleThing(some_userdata) ``` -------------------------------- ### logCommand Function Example Source: https://github.com/otland/forgottenserver/wiki/Changelog-1.4 Logs a player's talkaction command to a file for auditing or debugging purposes. ```lua function onSay(player, words, param) logCommand(player, words, param) player:sendTextMessage(MESSAGE_INFO_DESCR, "Command logged.") return true end ``` -------------------------------- ### Send Tutorial Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Initiates a tutorial sequence for the player, identified by a tutorial ID. ```Lua local player = Player(...) player:sendTutorial(unknown) ``` -------------------------------- ### setOwnerGuid(guid, updateDatabase) Source: https://github.com/otland/forgottenserver/wiki/Metatable:House Sets the owner's GUID for the house. Optionally updates the database. ```APIDOC ## setOwnerGuid(guid, updateDatabase) ### Description Sets the owner's GUID for the house. Optionally updates the database. ### Parameters #### Path Parameters - **guid** (No description) - Required - Description not available - **updateDatabase** (boolean) - Optional - Defaults to true. Description not available. ### Example ```Lua local house = House(...) house:setOwnerGuid(player_guid, false) ``` ``` -------------------------------- ### Get Player Client Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Retrieves the client object associated with the player. ```Lua local player = Player(...) player:getClient() ``` -------------------------------- ### RevScriptSys Example Source: https://github.com/otland/forgottenserver/wiki/Changelog-1.4 Demonstrates how to create and load custom scripts using the RevScriptSys. Scripts are placed in 'data/scripts' and loaded automatically unless commented out. ```lua -- This is a comment, disabling the script local myScript = Action() function myScript.onUse(player, item, fromPosition, target, toPosition, isHotkey) player:sendTextMessage(MESSAGE_INFO_DESCR, "Hello from RevScriptSys!") return true end myScript:create() ``` -------------------------------- ### Configure Build with CMake Preset Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Linux-&-Mac-OS-X-(vcpkg) Uses CMake to configure the build process for The Forgotten Server with the 'vcpkg' preset. ```bash cmake --preset vcpkg ``` -------------------------------- ### Set House Owner GUID Source: https://github.com/otland/forgottenserver/wiki/Metatable:House Sets the owner of the house to a specific player GUID. Optionally updates the database. ```Lua local house = House(...) house:setOwnerGuid(guid, updateDatabase = true) ``` -------------------------------- ### Run Server in GDB and Get Stacktrace Source: https://github.com/otland/forgottenserver/wiki/Compiling-debug-binaries-in-cmake Steps to run the compiled server binary within GDB, and how to display a full stacktrace when a crash occurs. ```bash gdb ``` ```bash file tfs ``` ```bash run ``` ```bash bt full ``` -------------------------------- ### setOwnerGuid(guid[, updateDatabase = true]) Source: https://github.com/otland/forgottenserver/wiki/Metatable:House Sets the owner's GUID for a house object. This method can optionally update the database. ```APIDOC ## setOwnerGuid(guid[, updateDatabase = true]) ### Description Sets the owner's GUID for a house object. This method can optionally update the database. ### Parameters #### Path Parameters - **guid** (unknown) - Required - No description - **updateDatabase** (boolean) - Optional - Defaults to true ### Request Example ```lua local house = House(...) house:setOwnerGuid(unknown, true) ``` ### Returns N/A ``` -------------------------------- ### Create Party Instance Source: https://github.com/otland/forgottenserver/wiki/Metatable:Party Demonstrates two ways to create a Party metatable instance: by player name or by player userdata. ```Lua local party = Party(player name) local party = Party(player userdata) ``` -------------------------------- ### Creating a Spell Instance Source: https://github.com/otland/forgottenserver/wiki/Metatable:Spell Demonstrates how to create a new Spell instance by providing its name. ```Lua local spell = Spell("incantation words") local spell = Spell("spell name") ``` -------------------------------- ### getOwnerGUID() Source: https://github.com/otland/forgottenserver/wiki/Metatable:Guild Retrieves the GUID of the player who is the leader of the guild. This method takes no arguments and returns an integer representing the player's GUID. ```APIDOC ## getOwnerGUID() ### Description Get the player GUID number that is the guild leader of this guild. ### Method `Guild:getOwnerGUID()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```Lua local player = Player(...) local guild = player:getGuild() if guild and player:getGUID() == guild:getOwnerGUID() then print("Player: " .. player:getName() .. " is the Guild Leader of: " .. guild:getName()) end ``` ### Response #### Success Response (200) - **player:guid** (int) - The GUID of the guild leader. ``` -------------------------------- ### Get Monster Target Distance Source: https://github.com/otland/forgottenserver/wiki/Metatable:MonsterType Retrieves the preferred targeting distance for a monster type. This influences how close the monster gets to its target. ```Lua local monstertype = MonsterType(...) monstertype:getTargetDistance() ``` -------------------------------- ### Compile Project in Visual Studio Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Windows-(vcpkg) After opening the project file in Visual Studio and selecting the desired build configuration (e.g., Release & x64), press F7 to initiate the compilation process. ```plaintext F7 ``` -------------------------------- ### Enable PowerTools on CentOS 8 Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-CentOS Enables the PowerTools repository on CentOS 8, which is required for installing lua-devel. ```bash $ sudo sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/CentOS-PowerTools.repo ``` -------------------------------- ### Build The Forgotten Server Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Linux-&-Mac-OS-X-(vcpkg) Builds The Forgotten Server using CMake with the 'vcpkg' preset and the 'RelWithDebInfo' configuration. ```bash cmake --build --preset vcpkg --config RelWithDebInfo ``` -------------------------------- ### Game:getClientVersion Method Example Source: https://github.com/otland/forgottenserver/wiki/Changelog-1.4 Retrieves the minimum, maximum, and string representation of the client version supported by the server. ```lua local versionInfo = Game.getClientVersion() print('Client version: ' .. versionInfo.string .. ' (Min: ' .. versionInfo.min .. ', Max: ' .. versionInfo.max .. ')') ``` -------------------------------- ### getExperience Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Retrieves the player's current experience points. This is a fundamental method for tracking player progression. ```APIDOC ## getExperience() ### Description Retrieves the player's current experience points. ### Parameters None ### Example ```Lua local player = Player(...) player:getExperience() ``` ``` -------------------------------- ### Get Town Temple Position Source: https://github.com/otland/forgottenserver/wiki/Metatable:Town Retrieves the position of the town's temple. Use this to get the coordinates of the town's central point. ```Lua local town = Town(...) town:getTemplePosition() ``` -------------------------------- ### Local Variable Initialization Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Shows the preferred way to declare and initialize local variables. ```cpp void f(){ int i; i = f(); // Bad int j = g(); // Good vector v = {1, 2}; // Good } ``` -------------------------------- ### Get HTTP Request Method Source: https://github.com/otland/forgottenserver/wiki/Metatable:Responder Retrieves the HTTP method (e.g., GET, POST, PUT) used for the incoming request. This is essential for routing or conditional logic. ```Lua local method = responder:getRequestMethod() if (method ~= 'GET') return end ``` -------------------------------- ### Create Creature Instance Source: https://github.com/otland/forgottenserver/wiki/Metatable:Creature Demonstrates two ways to create an instance of the Creature metatable using either a unique ID or a name. ```Lua local creature = Creature(uid) local creature = Creature(name) ``` -------------------------------- ### Download Source Code Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Fedora Clones the The Forgotten Server repository and its submodules using Git. ```bash git clone --recursive https://github.com/otland/forgottenserver.git ``` -------------------------------- ### Get Player Effective Skill Level Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Retrieves the effective skill level for a given skill type. Use this to get the actual skill value a player possesses. ```Lua local player = Player(...) player:getEffectiveSkillLevel(SKILL_FIST) ``` -------------------------------- ### Generate Build Files with CMake Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Arch-Linux Navigates into the cloned repository and generates build files using CMake, preparing the project for compilation. ```bash cd forgottenserver $ cmake . -B build ``` -------------------------------- ### Creature Instantiation Source: https://github.com/otland/forgottenserver/wiki/Metatable:Creature Demonstrates how to create an instance of the Creature metatable using either a unique ID or a name. ```APIDOC ## Creature Instantiation ### Description Creates an instance of the Creature metatable. This can be done using the creature's unique ID (UID) or its name. ### Usage ```lua local creature = Creature(uid) local creature = Creature(name) ``` ### Parameters - `uid` (number): The unique identifier of the creature. - `name` (string): The name of the creature. ``` -------------------------------- ### Generate Build Files with CMake Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Ubuntu Navigates into the source directory, creates a build directory, and generates build files using CMake. ```bash cd forgottenserver mkdir build && cd build cmake .. ``` -------------------------------- ### Game.getWorldType Source: https://github.com/otland/forgottenserver/wiki/Functions Gets the current world type of the server. ```APIDOC ## Game.getWorldType() ### Description Gets the current world type. ### Parameters None ### Returns Current gamestate on the server. ### Request Example ```Lua print(Game.getWorldType()) ``` ``` -------------------------------- ### Generate Build Files Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Fedora Navigates into the project directory, creates a build directory, and generates build files using CMake. ```bash cd forgottenserver $ mkdir build && cd build $ cmake .. ``` -------------------------------- ### Get Game State Source: https://github.com/otland/forgottenserver/wiki/Functions Fetches the current state of the game server. This can be used for monitoring or conditional logic. ```Lua print(Game.getGameState()) ``` -------------------------------- ### Download Source Code Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Debian-GNU-Linux Clones the The Forgotten Server repository recursively to download the source code. ```bash $ git clone --recursive https://github.com/otland/forgottenserver.git ``` -------------------------------- ### Get Guild Name Source: https://github.com/otland/forgottenserver/wiki/Metatable:Guild Retrieves the name of the guild. ```Lua local guild = Guild(...) guild:getName() ``` -------------------------------- ### Generate Build Files with CMake Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Mac-OS-X Navigates into the downloaded source code directory and creates a build directory to generate the necessary build files using CMake. This prepares the project for compilation. ```shell cd forgottenserver mkdir build; cd build cmake .. ``` -------------------------------- ### Get Creature Tile Source: https://github.com/otland/forgottenserver/wiki/Metatable:Creature Retrieves the tile the creature is currently on. ```Lua local creature = Creature(...) creature:getTile() ``` -------------------------------- ### Get Creature Target Source: https://github.com/otland/forgottenserver/wiki/Metatable:Creature Retrieves the current target of the creature. ```Lua local creature = Creature(...) creature:getTarget() ``` -------------------------------- ### Get Creature Speed Source: https://github.com/otland/forgottenserver/wiki/Metatable:Creature Retrieves the current speed of the creature. ```Lua local creature = Creature(...) creature:getSpeed() ``` -------------------------------- ### Get Creature Skull Source: https://github.com/otland/forgottenserver/wiki/Metatable:Creature Retrieves the skull status of the creature. ```Lua local creature = Creature(...) creature:getSkull() ``` -------------------------------- ### Configure Build Files with CMake (Command Line) Source: https://github.com/otland/forgottenserver/wiki/Compiling Use this command in the build directory to generate build files for your compiler. Ensure you are in the 'build' subdirectory. ```bash user@host:~/projects/forgottenserver/build$ cmake .. ``` -------------------------------- ### Get Creature Position Source: https://github.com/otland/forgottenserver/wiki/Metatable:Creature Retrieves the current position of the creature. ```Lua local creature = Creature(...) creature:getPosition() ``` -------------------------------- ### onEquip() Source: https://github.com/otland/forgottenserver/wiki/Interface:Movements This event is triggered when an item is equipped. Currently, its description, parameters, and return values are not specified. ```APIDOC ## onEquip() ### Description N/A ### Parameters N/A ### Accepted return values N/A ### Example ```lua N/A ``` ``` -------------------------------- ### Get Guild ID Source: https://github.com/otland/forgottenserver/wiki/Metatable:Guild Retrieves the unique identifier for the guild. ```Lua local guild = Guild(...) guild:getId() ``` -------------------------------- ### Get Container Capacity Source: https://github.com/otland/forgottenserver/wiki/Metatable:Container Retrieves the total capacity of the container. ```Lua local container = Container(...) container:getCapacity() ``` -------------------------------- ### sendOutfitWindow() Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Opens the outfit selection window for the player. This allows players to change their appearance. ```APIDOC ## sendOutfitWindow() ### Description Opens the outfit selection window for the player. ### Method `Player:sendOutfitWindow()` ### Parameters None ### Response N/A ### Example ```lua local player = Player(...) player:sendOutfitWindow() ``` ``` -------------------------------- ### Get Container ID Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Retrieves the ID of a given container object. ```Lua local player = Player(...) player:getContainerId(some_userdata) ``` -------------------------------- ### Build The Forgotten Server Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Debian-GNU-Linux Compiles The Forgotten Server using the generated build files. ```bash $ make ``` -------------------------------- ### Create and Populate a Table Source: https://github.com/otland/forgottenserver/wiki/Functions Creates a new table with specified array and key lengths, then populates the array part with sequential values. The table is 1-indexed. ```Lua local t = table.create(5, 0) for i = 1, #t do t[i] = i + 1 end ``` -------------------------------- ### Get Player Capacity Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Retrieves the maximum carrying capacity of the player. ```Lua local player = Player(...) player:getCapacity() ``` -------------------------------- ### Get Creature Summons Source: https://github.com/otland/forgottenserver/wiki/Metatable:Creature Retrieves a list of creatures summoned by this creature. ```Lua local creature = Creature(...) creature:getSummons() ``` -------------------------------- ### Download The Forgotten Server Source Code Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Arch-Linux Clones the official The Forgotten Server repository from GitHub using Git. ```bash $ git clone https://github.com/otland/forgottenserver.git ``` -------------------------------- ### Get All Creatures on Tile Source: https://github.com/otland/forgottenserver/wiki/Metatable:Tile Retrieves a list of all creatures currently on the tile. ```lua local tile = Tile(...) tile:getCreatures() ``` -------------------------------- ### Run The Forgotten Server Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Linux-&-Mac-OS-X-(vcpkg) Executes the compiled The Forgotten Server executable. Ensure configuration files are correctly set up beforehand. ```bash ./build/RelWithDebInfo/tfs ``` -------------------------------- ### Get ModalWindow ID Source: https://github.com/otland/forgottenserver/wiki/Metatable:ModalWindow Retrieves the unique identifier of the modal window. ```Lua local modalwindow = ModalWindow(...) modalwindow:getId() ``` -------------------------------- ### getTown() Source: https://github.com/otland/forgottenserver/wiki/Metatable:House Gets the town the house is located in. This method does not require any parameters. ```APIDOC ## getTown() ### Description Gets the town the house is located in. ### Parameters None ### Example ```Lua local house = House(...) house:getTown() ``` ``` -------------------------------- ### Build and Link Test Executables Source: https://github.com/otland/forgottenserver/blob/master/src/tests/CMakeLists.txt Iterates through the test source files, creates an executable for each, and links necessary libraries. This setup is for building individual test executables that can be run independently. ```cmake foreach(test_src ${tests_SRC}) get_filename_component(test_name ${test_src} NAME_WE) add_executable(${test_name} ${test_src}) target_link_libraries(${test_name} PRIVATE tfslib Boost::unit_test_framework) add_test(NAME ${test_name} COMMAND ${test_name}) endforeach() ``` -------------------------------- ### getExitPosition() Source: https://github.com/otland/forgottenserver/wiki/Metatable:House Gets the exit position of the house. This method does not accept any parameters. ```APIDOC ## getExitPosition() ### Description Gets the exit position of the house. ### Parameters None ### Example ```Lua local house = House(...) house:getExitPosition() ``` ``` -------------------------------- ### Build The Forgotten Server Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Arch-Linux Compiles The Forgotten Server using the generated build files with the 'make' command. The executable will be located in the './build/tfs' directory. ```bash $ make -C build ``` -------------------------------- ### Singleton Instance Access Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Illustrates the standard pattern for accessing a singleton instance using a static member function. ```C++ class MySingleton { public: static MySingleton& instance(); ``` -------------------------------- ### getOwnerGuid() Source: https://github.com/otland/forgottenserver/wiki/Metatable:House Fetches the owner's GUID for the house. This method does not require any parameters. ```APIDOC ## getOwnerGuid() ### Description Fetches the owner's GUID for the house. ### Parameters None ### Example ```Lua local house = House(...) house:getOwnerGuid() ``` ``` -------------------------------- ### setWorldLight Function Example Source: https://github.com/otland/forgottenserver/wiki/Changelog-1.4 Sets the world's lighting level and color. Level ranges from 1 to 10, color is an RGB value. ```lua setWorldLight(5, 0xFF0000) -- Set light to level 5, red color ``` -------------------------------- ### Get Player Bank Balance Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Retrieves the current bank balance of the player. ```Lua local player = Player(...) player:getBankBalance() ``` -------------------------------- ### Create Tile by Coordinates Source: https://github.com/otland/forgottenserver/wiki/Functions Creates a tile at the specified X, Y, and Z coordinates. Optionally, it can be marked as dynamic. Returns the created or existing tile. ```Lua local tile = Game.createTile(100, 100, 7) local ground = tile:getGround() if ground then print(ground:getName()) end ``` -------------------------------- ### Get Player Account ID Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Retrieves the unique account identifier for the player. ```Lua local player = Player(...) player:getAccountId() ``` -------------------------------- ### Get Creature Zone Type Source: https://github.com/otland/forgottenserver/wiki/Metatable:Creature Retrieves the zone type of the tile the creature is on. ```Lua local creature = Creature(...) creature:getZone() ``` -------------------------------- ### Get House Associated with Tile Source: https://github.com/otland/forgottenserver/wiki/Metatable:Tile Retrieves the house object associated with this tile, if any. ```lua local tile = Tile(...) tile:getHouse() ``` -------------------------------- ### Class Naming Convention Examples Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Illustrates good and bad naming practices for classes, emphasizing descriptive names and the use of suffixes like 'Abstract' or 'Interface' for abstract classes. ```cpp class Tool; // Bad: Doesn't describe anything. A tool which does what? class AbstractTool; // Good class ToolInterface; // Good class DebugTool; // Good ``` -------------------------------- ### Creating a Player Instance Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Instantiate a Player object using either a unique ID (UID) or a player's name. The name can also accept a wildcard character. ```Lua local player = Player(uid) local player = Player(name or wildcard) ``` -------------------------------- ### Get Ground Item on Tile Source: https://github.com/otland/forgottenserver/wiki/Metatable:Tile Retrieves the item representing the ground of the tile. ```lua local tile = Tile(...) tile:getGround() ``` -------------------------------- ### Get Creature Base Speed Source: https://github.com/otland/forgottenserver/wiki/Metatable:Creature Retrieves the base movement speed of a creature. ```Lua local creature = Creature(...) local baseSpeed = creature:getBaseSpeed() ``` -------------------------------- ### table.create(arrayLength, keyLength) Source: https://github.com/otland/forgottenserver/wiki/Functions Creates a new table with specified lengths for ordered and unordered indexes. ```APIDOC ## table.create(arrayLength, keyLength) ### Description Creates a new table with specified length. ### Parameters #### Path Parameters * **arrayLength** (number) - Required - Ordered indexes (1, 2, ...arrayLength) * **keyLength** (number) - Required - Unordered indexes (anything that does not follow the above) ### Returns The created table. ### Example ```Lua local t = table.create(5, 0) for i = 1, #t do t[i] = i + 1 end ``` ``` -------------------------------- ### Get Member Count Source: https://github.com/otland/forgottenserver/wiki/Metatable:Party Retrieves the total number of members currently in the party. ```Lua local party = Party(...) party:getMemberCount() ``` -------------------------------- ### Lua Talkaction Example: Display Online Players Source: https://github.com/otland/forgottenserver/wiki/Interface:Talkactions This script demonstrates how to use the onSay() function to list online players. It filters players based on access rights and ghost mode, then sends the information in paginated messages to the player who triggered the talkaction. ```Lua local maxPlayersPerMessage = 10 function onSay(player, words, param) local hasAccess = player:getGroup():getAccess() local players = Game.getPlayers() local onlineList = {} for _, targetPlayer in ipairs(players) do if hasAccess or not targetPlayer:isInGhostMode() then table.insert(onlineList, ("%s [%d]"):format(targetPlayer:getName(), targetPlayer:getLevel())) end end local playersOnline = #onlineList player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, ("%d players online."):format(playersOnline)) for i = 1, playersOnline, maxPlayersPerMessage do local j = math.min(i + maxPlayersPerMessage - 1, playersOnline) local msg = table.concat(onlineList, ", ", i, j) .. "." player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, msg) end return false end ``` -------------------------------- ### Explicit Constructor Example Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Demonstrates the use of the 'explicit' keyword for single-argument constructors to prevent unintended implicit conversions. ```cpp class Foo { explicit Foo(int x, double y); // Good ... }; void Func(Foo f); Func({42, 3.14}); // Error, as expected ``` -------------------------------- ### Get Party Leader Source: https://github.com/otland/forgottenserver/wiki/Metatable:Party Retrieves the player userdata of the current party leader. ```Lua local party = Party(...) party:getLeader() ``` -------------------------------- ### onManaChange() Example Source: https://github.com/otland/forgottenserver/wiki/Interface:Creature-Events Handles changes in a creature's mana. It can be used to modify mana gain or loss. Requires returning the mana change value. ```Lua return 5 ``` ```Lua function onManaChange(creature, attacker, manaChange) if not attacker then return 0 end return manaChange end ``` -------------------------------- ### Get Invitee Count Source: https://github.com/otland/forgottenserver/wiki/Metatable:Party Retrieves the number of players currently invited to the party. ```Lua local party = Party(...) party:getInviteeCount() ``` -------------------------------- ### Get ModalWindow Title Source: https://github.com/otland/forgottenserver/wiki/Metatable:ModalWindow Retrieves the current title text of the modal window. ```Lua local modalwindow = ModalWindow(...) modalwindow:getTitle() ``` -------------------------------- ### Get Guild Rank by Level Source: https://github.com/otland/forgottenserver/wiki/Metatable:Guild Retrieves a guild rank based on its level. ```Lua local guild = Guild(...) guild:getRankByLevel(1) ``` -------------------------------- ### addExperience Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Adds experience points to the player. Optionally sends a text message to the player. ```APIDOC ## addExperience(experience[, sendText = false]) ### Description Adds experience points to the player. ### Parameters #### Path Parameters - **experience** (number) - The amount of experience to add. - **sendText** (boolean, optional) - Whether to send a text message to the player. Defaults to false. ### Request Example ```lua local player = Player(...) player:addExperience(100, false) ``` ``` -------------------------------- ### Configure MySQL Connection in config.lua Source: https://github.com/otland/forgottenserver/wiki/Docker-Compose Update your server's configuration file to connect to the Dockerized MySQL database. Ensure the host, user, password, database, and port match your docker-compose setup. ```lua -- MySQL mysqlHost = "db" mysqlUser = "forgottenserver" mysqlPass = "" mysqlDatabase = "forgottenserver" mysqlPort = 3306 mysqlSock = "" ``` -------------------------------- ### Get Container Size Source: https://github.com/otland/forgottenserver/wiki/Metatable:Container Retrieves the current number of items stored in the container. ```Lua local container = Container(...) container:getSize() ``` -------------------------------- ### Get Item by Index from Container Source: https://github.com/otland/forgottenserver/wiki/Metatable:Container Retrieves an item from the container at a specific index. ```Lua local container = Container(...) container:getItem(some_id) ``` -------------------------------- ### onDeEquip() Source: https://github.com/otland/forgottenserver/wiki/Interface:Movements This event is triggered when an item is de-equipped. Currently, its description, parameters, and return values are not specified. ```APIDOC ## onDeEquip() ### Description N/A ### Parameters N/A ### Accepted return values N/A ### Example ```lua N/A ``` ``` -------------------------------- ### Namespace Formatting Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Illustrates the correct formatting for nested namespaces, where contents are not indented and namespaces do not add an extra indentation level. ```cpp namespace foo { namespace bar { } // namespace foo } // namespace bar ``` -------------------------------- ### Creature:move Method Example Source: https://github.com/otland/forgottenserver/wiki/Changelog-1.4 Moves a creature in a specified direction. The direction can be 'north', 'south', 'east', 'west', etc. ```lua creature:move('north') ``` -------------------------------- ### Get Player Death Penalty Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Retrieves information about the player's death penalty. ```Lua local player = Player(...) player:getDeathPenalty() ``` -------------------------------- ### Get Item by Type on Tile Source: https://github.com/otland/forgottenserver/wiki/Metatable:Tile Finds an item on the tile by its item type constant. ```lua local tile = Tile(...) tile:getItemByType(ITEM_TYPE_TELEPORT) ``` -------------------------------- ### House:save Method Example Source: https://github.com/otland/forgottenserver/wiki/Changelog-1.4 Saves the current state of a house, including its items and access lists. This is crucial for persistence. ```lua house:save() ``` -------------------------------- ### setOutfit (detailed) Source: https://github.com/otland/forgottenserver/wiki/Metatable:Condition Sets the outfit for a condition with detailed look parameters. ```APIDOC ## setOutfit(lookTypeEx, lookType, lookHead, lookBody, lookLegs, lookFeet[, lookAddons[, lookMount]]) ### Description Sets the outfit for a condition with detailed look parameters. ### Method `setOutfit` ### Parameters #### Path Parameters - **lookTypeEx** (any) - Required - Description: No description - **lookType** (any) - Required - Description: No description - **lookHead** (any) - Required - Description: No description - **lookBody** (any) - Required - Description: No description - **lookLegs** (any) - Required - Description: No description - **lookFeet** (any) - Required - Description: No description - **lookAddons** (any) - Optional - Description: No description - **lookMount** (any) - Optional - Description: No description ### Request Example ```lua local condition = Condition(...) condition:setOutfit(0, 128, 0, 0, 0, 0, nil, nil) ``` ``` -------------------------------- ### Get Down Item Count on Tile Source: https://github.com/otland/forgottenserver/wiki/Metatable:Tile Returns the count of items that are visually below other items on the tile. ```lua local tile = Tile(...) tile:getDownItemCount() ``` -------------------------------- ### Get Creature Count on Tile Source: https://github.com/otland/forgottenserver/wiki/Metatable:Tile Returns the total number of creatures present on the tile. ```lua local tile = Tile(...) tile:getCreatureCount() ``` -------------------------------- ### Pointer and Reference Expression Syntax Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Demonstrates the correct usage of spaces around dereference and address-of operators, as well as member access operators for pointers and references. ```cpp x = *p; p = &x; x = r.y; x = r->y; char *c; const string &str; ``` -------------------------------- ### Get Bottom Creature on Tile Source: https://github.com/otland/forgottenserver/wiki/Metatable:Tile Retrieves the creature at the bottom of the stack on a given tile. ```lua local tile = Tile(...) tile:getBottomCreature() ``` -------------------------------- ### Generate Build Files on CentOS 7 Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-CentOS Navigates into the forgottenserver directory, creates a build directory, and generates build files using CMake3. ```bash cd forgottenserver $ mkdir build && cd build $ cmake3 .. ``` -------------------------------- ### Get Vocation Name Source: https://github.com/otland/forgottenserver/wiki/Metatable:Vocation Retrieves the name of a vocation. This method is part of the Vocation API. ```Lua local vocation = Vocation(...) vocation:getName() ``` -------------------------------- ### GlobalEvent onTime Example Source: https://github.com/otland/forgottenserver/wiki/Revscriptsys Execute custom logic at a specific time of day, set using the time() method. This function should return true if the event was handled. ```lua local globalevent = GlobalEvent("example") function globalevent.onTime(interval) broadcastMessage("Good morning!", MESSAGE_STATUS_DEFAULT) return true end globalevent:time("08:00") -- will be executed each day on 8am globalevent:register() ``` -------------------------------- ### Get Vocation Description Source: https://github.com/otland/forgottenserver/wiki/Metatable:Vocation Retrieves the description of a vocation. This method is available on Vocation instances. ```Lua local vocation = Vocation(...) vocation:getDescription() ``` -------------------------------- ### Open Outfit Window Source: https://github.com/otland/forgottenserver/wiki/Metatable:Player Opens the outfit selection window for the player. No parameters are required. ```Lua local player = Player(...) player:sendOutfitWindow() ``` -------------------------------- ### Get All Towns Source: https://github.com/otland/forgottenserver/wiki/Functions Retrieves a list of all towns on the server. Useful for iterating through town data. ```Lua local towns = Game.getTowns() for i = 1, #towns do print(towns[i]:getName()) end ``` -------------------------------- ### Create Tile by Position Object Source: https://github.com/otland/forgottenserver/wiki/Functions Creates a tile at the given Position object. It can also be marked as dynamic. Returns the created or existing tile. ```Lua local tile = Game.createTile(Position(100, 100, 7)) local ground = tile:getGround() if ground then print(ground:getName()) end ``` -------------------------------- ### Get Item Count Source: https://github.com/otland/forgottenserver/wiki/Metatable:Item Retrieves the quantity of a specific item. This is useful for stackable items. ```Lua local item = Item(...) item:getCount() ``` -------------------------------- ### Game.createTile(x, y, z[, isDynamic = false]) Source: https://github.com/otland/forgottenserver/wiki/Functions Creates a tile at the specified coordinates (x, y, z). Optionally, it can be marked as dynamic. Returns the created or existing tile. ```APIDOC ## Game.createTile(x, y, z[, isDynamic = false]) ### Description Creates a tile at the specified coordinates (x, y, z). Optionally, it can be marked as dynamic. Returns the created or existing tile. ### Parameters #### Path Parameters - **x** (number) - X coordinate - **y** (number) - Y coordinate - **z** (number) - Z coordinate - **isDynamic** (boolean) - Optional. Is this tile dynamic? (default: false) ### Returns (userdata) The tile created or the previous existing one. ### Example ```Lua local tile = Game.createTile(100, 100, 7) local ground = tile:getGround() if ground then print(ground:getName()) end ``` ``` -------------------------------- ### Get ItemType Type Source: https://github.com/otland/forgottenserver/wiki/Metatable:ItemType Retrieves the general type of an ItemType. Added in version 1.0. ```Lua local itemtype = ItemType(...) itemtype:getType() ``` -------------------------------- ### Get ItemType Name Source: https://github.com/otland/forgottenserver/wiki/Metatable:ItemType Retrieves the display name of an ItemType. Added in version 1.0. ```Lua local itemtype = ItemType(...) itemtype:getName() ``` -------------------------------- ### GlobalEvent onRecord Example Source: https://github.com/otland/forgottenserver/wiki/Revscriptsys Handle custom logic related to recording events. This function should return true if the event was handled. ```lua local globalevent = GlobalEvent("example") function globalevent.onRecord(current, old) return true end globalevent:register() ``` -------------------------------- ### Loop Initialization Spacing Source: https://github.com/otland/forgottenserver/wiki/TFS-Coding-Style-Guide Shows the preferred spacing for loop initializations. No spaces are used inside the parentheses. ```cpp for (int i = 0; i < 5; ++i) { for (auto x : counts) { ``` -------------------------------- ### Get ItemType ID Source: https://github.com/otland/forgottenserver/wiki/Metatable:ItemType Retrieves the unique identifier for an ItemType. Added in version 1.0. ```Lua local itemtype = ItemType(...) itemtype:getId() ``` -------------------------------- ### getPromotion() Source: https://github.com/otland/forgottenserver/wiki/Metatable:Vocation Retrieves the promotion level of the vocation. Currently, the description, parameters, and return value are not specified. ```APIDOC ## getPromotion() ### Description Retrieves the promotion level of the vocation. N/A ### Method `vocation:getPromotion()` ### Parameters N/A ### Returns N/A ### Request Example ```lua local vocation = Vocation(...) vocation:getPromotion() ``` ### Response Example N/A ``` -------------------------------- ### Get Party Members Source: https://github.com/otland/forgottenserver/wiki/Metatable:Party Retrieves a list of all player userdata objects that are members of the party. ```Lua local party = Party(...) party:getMembers() ``` -------------------------------- ### shareExperience(experience) Source: https://github.com/otland/forgottenserver/wiki/Metatable:Party Shares experience among party members. This method is part of the Party metatable. ```APIDOC ## shareExperience(experience) ### Description Shares experience among party members. ### Method `shareExperience` ### Parameters #### Path Parameters - **experience** (number) - No description ### Request Example ```lua local party = Party(...) party:shareExperience(100) ``` ### Response N/A ``` -------------------------------- ### Get House Name Source: https://github.com/otland/forgottenserver/wiki/Metatable:House Retrieves the name of the house. This is the display name shown in the game. ```Lua local house = House(...) house:getName() ``` -------------------------------- ### onAddItem() Source: https://github.com/otland/forgottenserver/wiki/Interface:Movements This event is triggered when an item is added. Currently, its description, parameters, and return values are not specified. ```APIDOC ## onAddItem() ### Description N/A ### Parameters N/A ### Accepted return values N/A ### Example ```lua N/A ``` ``` -------------------------------- ### Get Guild Rank by ID Source: https://github.com/otland/forgottenserver/wiki/Metatable:Guild Retrieves a guild rank based on its unique ID. ```Lua local guild = Guild(...) guild:getRankById(some_id) ``` -------------------------------- ### Get Guild Message of the Day (MOTD) Source: https://github.com/otland/forgottenserver/wiki/Metatable:Guild Retrieves the Message of the Day set for the guild. ```Lua local guild = Guild(...) guild:getMotd() ``` -------------------------------- ### Clone The Forgotten Server Repository Source: https://github.com/otland/forgottenserver/wiki/Compiling-on-Linux-&-Mac-OS-X-(vcpkg) Clones the otland/forgottenserver repository to the specified home directory and changes the current directory to it. ```bash git clone https://github.com/otland/forgottenserver.git "$HOME/forgottenserver" cd "$HOME/forgottenserver" ``` -------------------------------- ### Define Test Source Files Source: https://github.com/otland/forgottenserver/blob/master/src/tests/CMakeLists.txt Lists the C++ source files that will be compiled as part of the test suite. ```cmake set(tests_SRC ${CMAKE_CURRENT_LIST_DIR}/test_base64.cpp ${CMAKE_CURRENT_LIST_DIR}/test_generate_token.cpp ${CMAKE_CURRENT_LIST_DIR}/test_matrixarea.cpp ${CMAKE_CURRENT_LIST_DIR}/test_rsa.cpp ${CMAKE_CURRENT_LIST_DIR}/test_sha1.cpp ${CMAKE_CURRENT_LIST_DIR}/test_xtea.cpp ) ```