Skip to content

World

getID

Returns the world's ID.

lua
world:getID()

getName

Returns the world's name.

lua
world:getName()

getTile

Returns the tile object at the specified coordinates.

lua
world:getTile(x, y)

getOwner

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

lua
world:getOwner()

getSizeX

Get the world size horizontally.

lua
world:getSizeX()

getSizeY

Get the world size vertically.

lua
world:getSizeY()

getTiles

Returns an array of all tiles in the world.

lua
world:getTiles()

getPlayers

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

lua
world:getPlayers()

getWorldLock

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

lua
world:getWorldLock()

getWorldType

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

lua
world:getWorldType()

getDroppedItems

Returns a table of all dropped items in the world.

lua
world:getDroppedItems()

getPlayersCount

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

lua
world:getPlayersCount(includeInvisible)

getTileDroppedItems

Returns a list of dropped items on a specific tile.

lua
world:getTileDroppedItems(tile)

getTilesByActionType

Returns tiles with a specific action type.

lua
world:getTilesByActionType(actionType)

getMagplantRemoteTile

Returns the tile object linked to the player's Magplant Remote.

lua
world:getMagplantRemoteTile(player)

getVisiblePlayersCount

Returns the number of visible players in the world.

lua
world:getVisiblePlayersCount()

setOwner

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

lua
world:setOwner(user_id)

setWeather

Permanently changes the default weather of a world.

lua
world:setWeather(weather_id)

setClothing

Force-equips an item onto a player.

lua
world:setClothing(player, item_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)

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)

kill

Kills a player in the world.

lua
world:kill(player)

save

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

lua
world:save()

addXP

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

lua
world:addXP(player, amount)

delete

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

lua
world:delete()

onLoot

Triggers a loot event for a player from a tile.

lua
world:onLoot(player, tile, gem_count)

hasFlag

Checks if the world has a specific flag (e.g., 0 for open to public, 1 for signal jammer, etc.).

lua
world:hasFlag(flagID)

addAccess

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

lua
world:addAccess(player, adminType)

createNPC

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

lua
world:createNPC(name, x, y)

hasAccess

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

lua
world:hasAccess(player)

punchTile

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

lua
world:punchTile(tile)

removeNPC

Removes an NPC from the world.

lua
world:removeNPC(npc)

spawnGems

Spawns gems at a specific tile coordinate.

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

spawnItem

Spawns an item. center: 1 (default) to center, 0 to not. Returns the dropped item object.

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

adjustGems

Adjusts gem count for a player from a tile action.

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

redeemCode

Forces the player to redeem a specific code.

lua
world:redeemCode(player, code)

updateTile

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

lua
world:updateTile(tile)

removeOwner

Removes the owner of the world, bypassing world locks.

lua
world:removeOwner()

isGameActive

Returns if a game is active in the world.

lua
world:isGameActive()

removeAccess

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

lua
world:removeAccess(player)

addTileAccess

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

lua
world:addTileAccess(player, tile)

findNPCByName

Finds an NPC by name and returns its player object.

lua
world:findNPCByName(name)

hasTileAccess

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

lua
world:hasTileAccess(player, tile)

useConsumable

Uses a consumable. 4th arg: 1 to suppress callback, 0 to trigger (default).

lua
world:useConsumable(player, tile, id, should_NOT_trigger_callback)

useItemEffect

Triggers a visual item effect in the world.

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

updateClothing

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

lua
world:updateClothing(player)

newFromTemplate

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

lua
world:newFromTemplate(name, templateFile)

removeTileAccess

Removes a player's access to a specific tile.

lua
world:removeTileAccess(player, tile)

onCreateExplosion

Creates an explosion at a specific pixel coordinate.

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

removeDroppedItem

Removes a dropped item by its unique ID.

lua
world:removeDroppedItem(dropUID)

sendPlayerMessage

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

lua
world:sendPlayerMessage(player, message)

onCreateChatBubble

Creates a chat bubble at a specific pixel coordinate.

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

removeAllTileAccess

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

lua
world:removeAllTileAccess()

onGameWinHighestScore

Returns the game's highest win score.

lua
world:onGameWinHighestScore()

Released under the MIT License.