Skip to content
KabanFriends edited this page Aug 3, 2023 · 4 revisions

A Level is an object that holds the level that the script is running on. It can be accessed from the constant variable level.

name : string

  • Name of the level.

playerCount : number

  • Number of players currently in the level.

epochMs : number

  • The number of milliseconds that have passed since the unix epoch time (January 1, 1970).

broadcast(string: message)

  • Sends a message to all players in the level.

getPlayers() : table

  • Returns the list of Players currently in the level.

getPlayer(string: name) : Player

  • Returns a Player object by their player name. It will return nil when the player with the specified name is not in the level.

getBlockName(number: id) : string

  • Gets the name of a block by its numerical ID. (e.g. 1 -> "Stone", 2 -> "Grass Block")

getBlockId(string: name) : number

  • Gets the numerical ID of a block by its name.

placeBlock(number/string: block, number: x, number: y, number: z)

  • Places a block at the specified coordinate in the level.
  • The block parameter can be either a number of the block ID, or a string of the block name.

getBlockAt(number: x, number: y, number: z) : number

  • Gets the numerical ID of a block at the specified coordinate in the level.

Data Storage

This section is the documentation of data storage related functions. See Data Storage for more information about data storages.

writeData(string: key, string/number/boolean: data)

  • Writes a data with the specified key to the level's data storage.

readData(string: key) : string/number/boolean

  • Reads a data with the specified key from the level's data storage.
  • Returns nil if the specified key doesn't exist.

removeData(string: key)

  • Removes a data with the specified key from the level's data storage.

dataExists(string: key) : boolean

  • Returns true if a data with the specified key exists in the level's data storage.

getAllData() : table

  • Returns a table with all keys and their data in the level's data storage.

clearAllData()

  • Clears all data from the level's data storage.
Clone this wiki locally