Skip to content

World

addAccess

Gives a player access to a World Locked world. adminType: 0 for regular, 1 for super-admin.

lua
world:addAccess(player, adminType)

addTileAccess

Gives a player permanent access to a specific tile (e.g., Small Lock).

lua
world:addTileAccess(player, tile)

addXP

Adds XP to a player. Recommended over player:addXP for better management.

lua
world:addXP(player, amount)

adjustGems

Adjusts gem count for a player from a tile action.

lua
world:adjustGems(player, tile, gem_count, val)

createNPC

Spawns an NPC in the world and returns its player object.

lua
world:createNPC(name, x, y)

delete

Deletes a world object from memory if it hasn't been saved.

lua
delete()

findNPCByName

Finds an NPC by name and returns its player object.

lua
world:findNPCByName(name)

getDroppedItems

Returns a table of all dropped items in the world.

lua
getDroppedItems()

getID

Returns the world's ID.

lua
getID()

getName

Returns the world's name.

lua
getName()

getOwner

Returns the player object of the world's owner, if one exists.

lua
getOwner()

getPlayers

Returns a table of all player objects currently in the world.

lua
getPlayers()

getPlayersCount

Returns the number of players in the world. Pass 1 to include invisible players.

lua
world:getPlayersCount(includeInvisible)

getSizeX

Get the world size horizontally.

lua
getSizeX()

getSizeY

Get the world size vertically.

lua
getSizeY()

getTile

Returns the tile object at the specified coordinates.

lua
world:getTile(x, y)

getTileDroppedItems

Returns a list of dropped items on a specific tile.

lua
world:getTileDroppedItems(tile)

getTiles

Returns an array of all tiles in the world.

lua
getTiles()

getTilesByActionType

Returns tiles with a specific action type.

lua
world:getTilesByActionType(actionType)

getVisiblePlayersCount

Returns the number of visible players in the world.

lua
getVisiblePlayersCount()

getWorldLock

Returns the tile object of the world lock if present, or nil.

lua
getWorldLock()

getWorldType

Returns the world type (e.g., 0 for normal, 255 for dungeon).

lua
getWorldType()

hasAccess

Checks if a player has build access to the entire world (e.g., via world lock).

lua
world:hasAccess(player)

hasTileAccess

Checks if a player has build access to a specific tile (e.g., via small lock).

lua
world:hasTileAccess(player, tile)

isGameActive

Returns if a game is active in the world.

lua
isGameActive()

kill

Kills a player in the world.

lua
world:kill(player)

new

Static method to create a new world object in memory. Use world:save() to create it on the server.

lua
world:new(name, sizeX, sizeY, worldType)

newFromTemplate

Static method to create a new world from a .dat template. Use world:save() to create it.

lua
world:newFromTemplate(name, templateFile)

onCreateChatBubble

Creates a chat bubble at a specific pixel coordinate.

lua
world:onCreateChatBubble(x, y, text, netID)

onCreateExplosion

Creates an explosion at a specific pixel coordinate.

lua
world:onCreateExplosion(x, y, radius, power)

onGameWinHighestScore

Returns the game's highest win score.

lua
onGameWinHighestScore()

onLoot

Triggers a loot event for a player from a tile.

lua
world:onLoot(player, tile, gem_count)

punchTile

Simulates a punch on a tile, triggering its break logic.

lua
world:punchTile(tile)

redeemCode

Forces the player to redeem a specific code.

lua
world:redeemCode(player, code)

removeAccess

Removes a player's access to a World Locked world.

lua
world:removeAccess(player)

removeAllTileAccess

Removes all tile access permissions in the world (emergency command).

lua
removeAllTileAccess()

removeDroppedItem

Removes a dropped item by its unique ID.

lua
world:removeDroppedItem(dropUID)

removeNPC

Removes an NPC from the world.

lua
world:removeNPC(npc)

removeOwner

Removes the owner of the world, bypassing world locks.

lua
removeOwner()

removeTileAccess

Removes a player's access to a specific tile.

lua
world:removeTileAccess(player, tile)

save

Saves a world created with World.new or World.newFromTemplate to the server.

lua
save()

sendPlayerMessage

Sends a message to a player, can also run commands.

lua
world:sendPlayerMessage(player, message)

setClothing

Force-equips an item onto a player.

lua
world:setClothing(player, item_id)

setOwner

Sets the owner of the world by user ID, bypassing world locks.

lua
world:setOwner(user_id)

setPlayerPosition

Teleports a player to a specific tile coordinate within the world.

lua
world:setPlayerPosition(player, x, y)

setTileBackground

Sets the background of a tile. If isVisual is true, it's a temporary visual change, optionally for a single player.

lua
world:setTileBackground(tile, itemID, isVisual, player)

setTileForeground

Sets the foreground of a tile. If isVisual is true, it's a temporary visual change, optionally for a single player.

lua
world:setTileForeground(tile, itemID, isVisual, player)

setWeather

Permanently changes the default weather of a world.

lua
world:setWeather(weather_id)

spawnGems

Spawns gems at a specific tile coordinate.

lua
world:spawnGems(x, y, amount, player)

spawnItem

Spawns an item. Now returns the dropped item object.

lua
world:spawnItem(x, y, itemID, count)

updateClothing

Forces a visual update of a player's clothing for everyone in the world.

lua
world:updateClothing(player)

updateTile

Forces a visual update for a tile, necessary after using tile:setTileData.

lua
world:updateTile(tile)

useItemEffect

Triggers a visual item effect in the world.

lua
world:useItemEffect(playerNetID, itemID, targetNetID, effectDelay)

Released under the MIT License.