Game
Parameters in square brackets "[parameter]" are optional
and their default value is specified after the name e.g "= false"

Game.getSpectators()

position[, multifloor = false[, onlyPlayer = false[, minRangeX = 0[, maxRangeX = 0[, minRangeY = 0[, maxRangeY = 0]]]]]]
This method is pretty heavy (excessive usage might be affecting performance)
1
local position = Position(1000, 1000, 7)
2
local spectators = Game.getSpectators(position, false, true, 10, 10, 10, 10)
3
-- get all spectators from position in radius of 10 vertically and horizontally
4
for _, spectator in ipairs(spectators) do
5
-- iterates over all spectators and prints their type (npc, monster or player)
6
print(type(spectator))
7
end
Copied!

Game.getPlayers()

1
local players = Game.getPlayers()
2
print(#players) -- prints players online
3
for _, player in ipairs(players) do
4
-- iterate through players online and print their names
5
print(player:getName()
6
end
Copied!

Game.loadMap()

path
1
Game.loadMap("/data/world/map.otbm")
Copied!

Game.getExperienceStage()

level
1
local experienceStage = Game.getExperienceStages(100)
2
print(experienceStage) -- prints current experience stage for level 100
Copied!

Game.getMonstersCount()

1
local monstersCount = Game.getMonstersCount()
2
print(monstersCount) -- prints number of alive monsters
Copied!

Game.getPlayersCount()

1
local playersCount = Game.getPlayersCount()
2
print(playersCount) -- prints number of players online
Copied!

Game.getNpcCount()

1
local npcCount = Game.getNpcCount()
2
print(npcCount) -- prints number of npcs
Copied!

Game.getMonsterTypes()

1
local monsterTypes = Game.getMonsterTypes()
2
for _, monsterType in ipairs(monsterTypes) do
3
-- iterates through monster types and prints their names
4
print(monsterType:getName())
5
end
Copied!

Game.getTowns()

1
local towns = Game.getTowns()
2
for _, townin ipairs(towns) do
3
-- iterates through towns and prints their names
4
print(town:getName()) TODO FIND THE METHOD
5
end
Copied!

Game.getHouses()

1
local houses = Game.getHouses()
2
for _, house in ipairs(houses) do
3
-- iterates through houses and prints their owners guid
4
print(house:getOwnerGuid())
5
end
Copied!

Game.getGameState()

1
local gameState = Game.getGameState()
2
if gameState == GAME_STATE_CLOSED then
3
-- checks if server is closed, if it's then open it
4
Game.setGameState(GAME_STATE_NORMAL)
5
end
Copied!

Game.setGameState()

state
1
Game.setGameState(GAME_STATE_NORMAL) -- sets game state to state normal
Copied!

Game.getWorldType()

1
local worldType = Game.getWorldType()
2
print(worldType) -- prints currently set world type ex. WORLD_TYPE_PVP
Copied!

Game.setWorldType()

worldType
1
Game.setWorldType(WORLD_TYPE_NO_PVP) -- sets current world type to non pvp
Copied!

Game.getReturnMessage()

returnValue
1
local player = Player(...)
2
if player then
3
local returnMessage = Game.getReturnMessage(RETURNVALUE_NOTPOSSIBLE)
4
print(returnMessage) -- prints Sorry not possible.
5
player:sendCancelMessage(returnMessage)
6
end
Copied!

Game.createItem()

itemId[, count[, position]]
1
local item = Game.createItem(2160)
2
print(item) -- prints memory address
3
-- at this point item was created, but not added to anywhere, so it's stored in memory
4
-- either add it to any container
5
container:addItemEx(item)
6
-- or delete it to avoid memory leak
7
item:remove()
8
9
item = Game.createItem(2160, 1, Position(1001, 1000, 7)
10
print(item:getPosition().x) -- prints 1001
Copied!

Game.createContainer()

itemId, size[, position]
1
local container = Game.createContainer(1987, 10)
2
print(container) -- prints memory address
3
-- at this point container was created, but not added to anywhere, so it's stored in memory
4
-- either add it to any container
5
container:addItemEx(container)
6
-- or delete it to avoid memory leak
7
container:remove()
8
9
container = Game.createContainer(2160, 10, Position(1001, 1000, 7)
10
print(container:getPosition().x) -- prints 1001
Copied!

Game.createMonster()

monsterName, position[, extended = false[, force = false]]
extended means monster can be spawned in area near the specified position
force means monster will be always spawned in specified position, even if position is blocked
1
local monster = Game.createMonster("rat", Position(1000, 1000, 7), false, true)
2
if monster then
3
print(monster:getId()) -- prints monster unique id
4
end
Copied!

Game.createNpc()

npcName, position[, extended = false[, force = false]]
1
local npc = Game.createNpc("Nekiro", Position(1000, 1000, 7), false, true)
2
if npc then
3
print(npc:getId()) -- prints npc unique id
4
end
Copied!

Game.createTile()

x, y, z[, isDynamic = false]
position[, isDynamic = false]
Dynamic tiles can store items and creatures, in most cases walkable one. (They take more memory too)
1
local tile = Game.createTile(1001, 1000, 7, false)
2
-- or Game.createTile(Position(1001, 1000, 7), false)
3
if tile then
4
print(tile:getPosition().x) -- prints 1001
5
end
Copied!

Game.createMonsterType()

name
This method can overwrite already created monster types and clear their loot and spells
1
local newMonsterType = Game.createMonsterType("SpecialRat")
2
-- creates new (or overwrites if exists) monster type
3
if newMonsterType then
4
print(newMonsterType:getName()) -- prints SpecialRat
5
end
Copied!

Game.startRaid()

raidName
This method might get soon deprecated in favor of raid system written in Lua
1
Game.startRaid("RatsThais") -- starts raid with name RatsThais
Copied!

Game.getClientVersion()

1
local clientVersion = Game.getClientVersion()
2
print(clientVersion) -- prints table: 0x93ff90
3
4
-- prints min and max allowed client version and version string
5
print(clientVersion.min, clientVersion.max, clientVersion.string)
Copied!

Game.reload()

reloadType
1
Game.reload(RELOAD_TYPE_GLOBAL) -- reloads all libs
2
Game.reload(RELOAD_TYPE_ACTIONS) -- reloads all actions
3
-- and so on...
Copied!
Last modified 1yr ago