World Object Documentation
Overview
The World object provides access to all world-specific data, player interactions, tiles, and item effects. Methods are used with the colon operator (world:methodName()).
World Info
world:getOwner(player) -- Checks if a player is the owner of the world.
world:getName() -- Returns the world's name.
world:getID() -- Returns the world's ID.
world:getSizeX() -- Returns the horizontal size of the world.
world:getSizeY() -- Returns the vertical size of the world.
world:getWorldSizeX()
world:getWorldSizeY()
world:getTiles() -- Returns a table of all tiles in the world.
world:getTilesByActionType(actionType) -- Returns tiles with a specific action type.
world:getWorldLock() -- Returns the world lock tile, or nil if world is not locked.World Access Management
Manage player access to worlds and specific tiles:
world:hasAccess(player) -- Checks if player has build access to the entire world.
world:hasTileAccess(player, tile) -- Checks if player has build access to a specific tile.
-- Grant/remove access (only works if world is World Locked)
world:addAccess(player, adminType) -- Give player access (0 = regular, 1 = super-admin).
world:removeAccess(player) -- Remove player's world access.
-- Tile-specific access (very powerful - be careful!)
world:addTileAccess(player, tile) -- Give permanent tile access (can break locks!).
world:removeTileAccess(player, tile) -- Remove tile access.
world:removeAllTileAccess() -- Emergency: Remove all tile access grants.Powerful Access Control
addTileAccess is very powerful - if you give players access to lock tiles, they can break them! Use with extreme caution.
World Flags
Check world flags for special properties:
world:hasFlag(id) -- Check if world has a specific flag.Available Flags:
| Flag ID | Property |
|---|---|
| 0 | Open to public |
| 1 | Signal jammer |
| 2 | Punch jammer |
| 3 | Zombie jammer |
| 4 | Balloon jammer |
| 5 | Antigravity |
| 6 | Ghost jammed |
| 7 | Pineapple guardian |
| 8 | Firehouse |
| 9 | Mini-mod |
| 10 | Xenonite crystal |
| 11 | Silenced |
| 12 | Silenced, but admins ignore |
| 13 | Instant collect gems |
| 14 | Block dropped items |
| 15 | Disable ghost |
| 16 | Disable cheats |
| 17 | Disable one-hit |
Player Interaction
world:hasAccess(player) -- Checks if player has build access to the entire world.
world:hasTileAccess(player, tile) -- Checks if player has build access to a specific tile.
world:setPlayerPosition(player, x, y) -- Teleports a player to a specific tile coordinate.
world:kill(player) -- Kills a player in the world.
world:setClothing(player, itemID) -- Force equips an item on a player.
world:updateClothing(player) -- Updates player's clothing.
world:addXP(player, amount) -- Adds XP to a player.
world:adjustGems(player, tile, gem_count, val) -- Adjusts gem count for a player from a tile action.Players in World
world:getPlayers() -- Returns a table of all player objects currently in the world.
world:getPlayersCount(includeInvisible) -- Returns the number of players, pass `1` to include invisible players.
world:getVisiblePlayersCount() -- Returns the number of visible players.
world:findNPCByName(name) -- Finds an NPC by name and returns its player object.
world:createNPC(name, x, y) -- Spawns an NPC in the world and returns its player object.
world:removeNPC(npc) -- Removes an NPC from the world.NPC System
You can create and manage NPCs in worlds to add interactive elements or guide players through custom content!
Messaging & Effects
world:sendPlayerMessage(player, message) -- Sends a message to a player.
world:onCreateChatBubble(x, y, text, netID) -- Creates a chat bubble in the world.
world:onCreateExplosion(x, y, radius, power) -- Creates an explosion at coordinates.
world:useItemEffect(playerNetID, itemID, targetNetID, effectDelay) -- Triggers a visual item effect in the world.
spawnGems(x, y, amount, player) -- Spawns gems in the world.Tile Manipulation
world:setTileForeground(tile, itemID, isVisual:optional, player:optional) -- Sets the foreground of a tile.
world:setTileBackground(tile, itemID, isVisual:optional, player:optional) -- Sets the background of a tile.
world:updateTile(tile) -- Forces a visual update for a tile.
world:punchTile(tile) -- Simulates a punch on a tile (break logic).
world:getTileDroppedItems(tile) -- Returns a table of all dropped items on the tile.Items & Dropped Objects
world:getDroppedItems() -- Returns a table of all dropped items in the world.
world:removeDroppedItem(DropUID) -- Removes a dropped item by its UID.
world:spawnItem(x, y, itemID, count, center) -- Spawns an item, returns dropped item object.
-- center: 1 (default) = centered, 0 = not centered
world:getMagplantRemoteTile(player) -- Returns tile being used with magplant remote.
world:useConsumable(player, tile, id, should_NOT_trigger_callback) -- Use a consumable item.
-- should_NOT_trigger_callback: 1 = suppress callback, 0 = trigger (default)Spawn Item Returns Object
The spawnItem() function now returns the dropped item object, allowing you to get its UID and manipulate it directly!
Example:
local droppedItem = world:spawnItem(5, 5, 2, 1, 0) -- Spawn 1 dirt at (5,5), not centered
if droppedItem then
local uid = droppedItem:getUID()
print("Spawned item UID: " .. uid)
end
-- Magplant remote example
local magplantTile = world:getMagplantRemoteTile(player)
if magplantTile then
local itemID = magplantTile:getForegroundItemID()
print("Player's magplant remote is linked to tile with item: " .. itemID)
end
-- Using consumable without triggering callback (prevents infinite recursion)
world:useConsumable(player, tile, itemID, 1)Callback Control
You can now suppress the onPlayerUsedConsumableCallback when calling useConsumable() to prevent infinite recursion in your scripts!
Game Status
world:isGameActive() -- Returns true if the game is active.
world:onGameWinHighestScore() -- Returns the game's highest win score.