Comment on page
Lua functions
Description: Send message to all players Parameters: Returns: Nothing Example:local message = 'Hello'local messageType = MESSAGE_STATUS_DEFAULTGame.broadcastMessage(message, messageType)Added in version: 1.0
Description: Convert numeric representation of IPv4 to string with dot separated octets Parameters: Returns: String Example:function Player:onLook(thing, position, distance)if thing:isCreature() thenif thing:isPlayer() thenlocal playerIp = thing:getIp()local ip = Game.convertIpToString(playerIp)local description = string.format("IP: [%s].", ip)endendself:sendTextMessage(MESSAGE_INFO_DESCR, description)return trueendAdded in version: 1.0
Description: Creates an item. Parameters: Returns: The item created. (userdata) Example:-- Create an item somewhere on the map.local item = Game.createItem(2400, 1, Position(100, 100, 7))---- Create a temporary item that is given to a player (if it isn't moved from creation it will be deleted)local player = Player(...)player:addItemEx(Game.createItem(2400, 1))Added in version: 1.0
Description: Creates a container with given size. Parameters: Returns: The container created. (userdata) Example:-- Create an amulet of loss as a container with size 5 at position: x 100, y 100, z 7.local item = Game.createContainer(ITEM_AMULETOFLOSS, 5, Position(100, 100, 7))---- Create a temporary container that is given to a player (if it isn't moved from creation it will be deleted)local player = Player(...)player:addItemEx(Game.createContainer(ITEM_AMULETOFLOSS, 5))Added in version: 1.1
Description: Creates a monster. Parameters: Returns: The monster created. (userdata) Example:-- This should always create this monster.local monster = Game.createMonster("demon", Position(100, 100, 7), false, true)if not monster then-- Something went wrong?endAdded in version: 1.0
Description: Creates a npc. Parameters: Returns: The npc created. (userdata) Example:-- This may possibly not create the npc.local npc = Game.createMonster("some npc", Position(100, 100, 7), false, false)if not npc then-- Something is probably blocking that position and around it aswellendAdded in version: 1.0
Description: Creates a tile if it can. Parameters: Returns: The tile created or the previous existing one. (userdata) Example:local tile = Game.createTile(100, 100, 7)local ground = tile:getGround()if ground thenprint(ground:getName())endAdded in version: 1.0
Description: Creates a tile if it can. Parameters: Returns: The tile created or the previous existing one. (userdata) Example:local tile = Game.createTile(Position(100, 100, 7))local ground = tile:getGround()if ground thenprint(ground:getName())endAdded in version: 1.0
Description: Find the experience rate related to a certain level. Parameters: Returns: The experience rate related to the specified level. Example:-- Print the experience rate for level 8 to the consoleprint(Game.getExperienceStage(8))Added in version: 1.0
Description: Gets the current gamestate. Parameters: None Returns: Current gamestate on the server. Example:print(Game.getGameState())Added in version: 1.0
Description: Get all houses. Parameters: None Returns: A table containing all houses (userdata). Example:-- This prints the names of all houses that exist on the serverlocal houses = Game.getHouses()for i = 1, #houses doprint(houses[i]:getName())endAdded in version: 1.0
Description: Find the total amount of monsters on the server. Parameters: None Returns: Total amount of monsters on the server. Example:print(Game.getMonsterCount())Added in version: 1.0
Description: Find the total amount of npcs on the server. Parameters: None Returns: Total amount of npcs on the server. Example:print(Game.getNpcCount())Added in version: 1.0
Description: Find the total amount of players on the server. Parameters: None Returns: Total amount of players on the server. Example:print(Game.getPlayerCount())Added in version: 1.0
Description: Get all connected players. Parameters: None Returns: A table containing all connected players (userdata). Example:-- This prints the names of all players connected to the serverlocal players = Game.getPlayers()for i = 1, #players doprint(players[i]:getName())endAdded in version: 1.0
Description: Gets a message associated with the value. Parameters: Returns: true Example:-- This makes no sense but its an example.local player = Player(...)player:say(Game.getReturnMessage(RETURNVALUE_YOUARENOTTHEOWNER), TALKTYPE_SAY)Added in version: 1.0
Description: Gets reversed direction. Parameters: Returns: Direction (integer) Example:local direction = DIRECTION_NORTHlocal reversedDirection = Game.getReverseDirection(direction)print('Numerical value of SOUTH direction is equel '.. tostring(reversedDirection))Added in version: 1.0
Description: Gets skill type associatet with weapon type. Parameters: Returns: Skill type (integer) Example:local itemtype = ItemType(...)local weaponType = itemtype:getWeaponType()local skillType = Game.getSkillType(weaponType)Added in version: 1.0
Description: Get all creatures in the area. Parameters: Returns: A table containing creatures found (userdata). Example:-- This finds all players in a 5x5 area around (100, 100, 7)local spectators = Game.getSpectators(Position(100, 100, 7), false, true, 0, 2, 0, 2)for i = 1, #spectators dolocal spectator = spectators[i]spectator:say(spectator:getName(), TALKTYPE_SAY)endAdded in version: 1.0
Description: Get value from globalStorageTable Parameters: Returns: Value from table on empty index nil value Example:local storage = Game.getStorageValue(1)print(tostring(storage))Added in version: 1.0
Description: Get all towns. Parameters: None Returns: A table containing all towns (userdata). Example:-- This prints the names of all towns that exist on the serverlocal towns = Game.getTowns()for i = 1, #towns doprint(towns[i]:getName())endAdded in version: 1.0
Description: Gets the current world type. Parameters: None Returns: Current gamestate on the server. Example:print(Game.getWorldType())Added in version: 1.0
Description: This loads a new map chunk. Parameters: Returns: Nothing Example:Game.loadMap("data/map/some_other_map.otbm")Added in version: 1.0
Description: Sets the current gamestate. Parameters: Returns: true Example:-- Shutdown the serverGame.setGameState(GAME_STATE_SHUTDOWN)Added in version: 1.0
Description: Insert value into globalStorageTable on specific key Parameters: Returns: Nothing Example:Game.setStorageValue(1, 1000)Added in version: 1.0
Description: Sets the current world type. Parameters: Returns: true Example:-- Change to hardcore pvpGame.setWorldType(WORLD_TYPE_PVP_ENFORCED)Added in version: 1.0
Description: Starts a raid if one with said name exist. Parameters: Returns: true if the raid started, nil otherwise. Example:if Game.startRaid("test") then-- Raid was started.endAdded in version: 1.0
Description: This function is used to run other functions at a later time. Parameters: Returns: The id associated with this event. Example:-- Creates an event that prints "Hello World!" to the console.addEvent(print, 1000, "Hello World!")Added in version: 1.0
Description: This function is used to stop functions that should run later. Parameters: Returns: true if an event was stopped, false otherwise. Example:-- Creates an event that should print "Hello World!" but it's stopped before that can happen.local event = addEvent(print, 1000, "Hello World!")stopEvent(event)Added in version: 1.0
Description: Returns the Unix time (epoch) in milliseconds Parameters: None Returns: The Unix time (epoch) in milliseconds Example:print(os.mtime() .. " milliseconds have passed since the Unix epoch")Added in version: 1.0