World
The world API is accessed through the world
global. Like so: world.getTime()
.
The functions in the World API never receive self
as a parameter. Because of this they should be called with a .
instead of :
world:getBlockState(player:getPos())
world.getBlockState(player:getPos())
exists()
Checks whether or not a world currently exists
This will almost always be true, but might be false on some occasions such as while traveling between dimensions
Example:
world.exists()
getPlayers()
Returns a table containing instances of Player for all players in the world
The players are indexed by their names
Example:
for _, players in pairs(world.getPlayers()) do
log(players)
end
getTime()
Gets the current game time of the world
If delta is passed in, then it adds delta to the time
The default value of delta is zero
Example:
world.getTime()
getTimeOfDay()
Gets the current day time of the world
If delta is passed in, then it adds delta to the time
The default value of delta is zero
Example:
world.getTimeOfDay()
getMoonPhase()
Gets the current moon phase of the world, stored as an integer
Example:
world.getMoonPhase()
getDimension()
Gets the dimension name of this world
Example:
world.getDimension()
getBiome(Vector3)
Gets the Biome located at the given position
Example:
world.getBiome(player:getPos())
getEntity(string)
Returns an EntityAPI object from this UUID's entity, or nil if no entity was found
Example:
world.getEntity("5003b2ce-7a8d-4c56-8b91-ec705985fe08")
getBlockState(Vector3)
Gets the BlockState of the block at the given position
Example:
world.getBlockState(player:getPos())
getStrongRedstonePower(Vector3)
Gets the direct redstone power level of the block at the given position
Example:
world.getStrongRedstonePower(player:getPos())
getRedstonePower(Vector3)
Gets the redstone power level of the block at the given position
Example:
world.getRedstonePower(player:getPos())
getSkyLightLevel(Vector3)
Gets the sky light level of the block at the given position
Example:
world.getSkyLightLevel(player:getPos())
getBlockLightLevel(Vector3)
Gets the block light level of the block at the given position
Example:
world.getBlockLightLevel(player:getPos())
getLightLevel(Vector3)
Gets the overall light level of the block at the given position
Example:
world.getLightLevel(player:getPos())
isOpenSky(Vector3)
Gets whether or not the sky is open at the given position
Example:
world.isOpenSky(player:getPos())
getRainGradient(delta)
Gets the current rain gradient in the world, interpolated from the previous tick to the current one
The default value of delta is 1, which is the current tick
Example:
world.getRainGradient()
isThundering()
Gets whether or not there is currently thunder/lightning happening in the world
Example:
world.isThundering()
getBuildHeight()
Returns the minimum and maximum build height of the world, as varargs
Example:
world.getBuildHeight()
getSpawnPoint()
Returns a vector with the coordinates of the world spawn
Example:
world.getSpawnPoint()
getBlocks(Vector3,Vector3)
Gets a list of all BlockStates in the specified area
The maximum area size is 8 x 8 x 8
newItem(string,integer,integer)
Parses and create a new ItemStack from the given string
A count and damage can be given, to be applied on this itemstack
Note: This doesn't create an item in the world, if you want to make a fake item you want item tasks
Example:
world.newItem("grass_block", 64, 5)
newBlock(string,Vector3)
Parses and create a new BlockState from the given string
A world position can be optionally given for the blockstate functions that relies on its position
Note: This doesn't create a block in the world, if you want to make a fake block you want block tasks
Example:
world.newBlock("grass_block", player:getPos())
avatarVars()
Returns a table containing variables stored from all loaded Avatars "avatar:store()" function The table will be indexed by the avatar's owner UUID
Example:
world.avatarVars()