Wizards of Lua

The Art of Spell Crafting


World - Where All Exists

The World is the space around every creature and item in it.

The World class is a subtype of the Object class and inherits all its properties and functions.

Here is an overview of the World properties:

Property Type read / write
daytime number (long) r
difficulty string r/w
dimension number (int) r
folder string r
name string r
spawnPoint Vec3 r/w
time number (long) r/w

Here is an overview of the World functions:

Function Parameters Results
 canSeeSky  pos boolean
 getNearestVillage  position, radius Vec3
 isGeneratedAt  pos boolean
 isLoadedAt  pos boolean

Properties

Below you find short descriptions about each of the properties and some examples about how to use them in your spells.


daytime : number (long)

The ‘daytime’ is the number of game ticks that have passed since the last sunrise. In Mincraft the day runs from sunrise to sunrise and is divided into 24000 game ticks. For example, 0 means sunrise, 6000 noon, 12000 sunset, 18000 midnight, and 23999 is the end of the night.


difficulty : string

The difficulty defines how difficult it is for the players to live in this world. This is one of PEACEFUL, EASY, NORMAL, HARD.


dimension : number (int)

The ‘dimension’ is a magic number that defines which kind of world this is. 0 means the Overworld. -1 is the Nether, and 1 is the End.


folder : string

This is the name of the folder where this world is stored on the file system.


name : string

This is the name of this world.


spawnPoint : Vec3

The spawn point is a certain point in this world where Players will spawn when they enter the world the first time, or when their personal spawn point is somehow not accessible anymore.


time : number (long)

The ‘time’ is the number of game ticks that have passed since the world has been created. But in contrast to Time.gametime this value can be modified by operators using the /time command.


Functions

Below you find short descriptions about each of the functions and some examples about how to use them in your spells.


canSeeSky (pos) -> boolean

The ‘canSeeSky’ function returns true if the sky is visible from the given position when looking straight up.


getNearestVillage (position, radius) -> Vec3

The ‘getNearestVillage’ function returns the village center of the nearest village relative to the given position, or nil, if no village is found within the given radius.


isGeneratedAt (pos) -> boolean

The ‘isGeneratedAt’ function returns true if the world chunk that contains the given world coordinates has already been generated. Please note that this doesn’t imply that this chunk also is currently loaded.


isLoadedAt (pos) -> boolean

The ‘isLoadedAt’ function returns true if the world chunk that contains the given world coordinates is currently loaded into the server.