World¶
Overview¶
The World table contains access to a variety of information about the current game world.
Enumerations¶
HeightOffsetType¶
Used with World.GetGroundHeight() to apply additional offsets to the ground height, depending on the type of LocEntity placed at the sampled position.
| Name | Value | Description |
|---|---|---|
| NONE | 0 | Applies no offset to the ground height |
| GROUND_DECOR | 1 | Applies any offset from a LocEntity using LocShapeType.GROUNDDECOR, i.e. a rug.See LocType.groundDecorOffset. |
| LOCATION | 2 | Offsets the height by the total height of the LocEntity, i.e. a table. |
Functions¶
IsAvailable¶
Returns whether the world data can currently be accessed.
| Returns | Description |
|---|---|
| Boolean | Whether the world data is available to read from. |
Example
IsMembers¶
Returns whether the currently connected world is a Member's world.
| Returns | Description |
|---|---|
| Boolean | Whether the world is a Member's world. |
GetPing¶
Returns the ping value to the current game world.
This function will return -1 if there is no active connection to a game world.
Info
This function has an internal limit of 5 seconds per ping request.
| Returns | Description |
|---|---|
| Integer | The ping value to the current game world. |
GetRebootTimer¶
Returns the number of logic ticks (50 per second) until the currently connected server reboots.
Info
This will return 0 if the world is unavailable or no reboot is currently scheduled.
| Returns | Description |
|---|---|
| Integer | The number of logic ticks until a server reboot. |
Example
IsRegion¶
Returns whether the current game world is a region or not.
Info
A region is a duplicated area outside of the main game world, typically to allow players to experience content alone or within a group.
A Region is often known in game-terms as an Instance.
The term region is used to clearly differentiate this concept from other uses of instance in the API.
| Returns | Description |
|---|---|
| Boolean | Whether the current game world is a region. |
GetRegionSourceForCoordGrid¶
Returns the source coordinate for a given region CoordGrid.
Info
Regions are constructed by referencing data from other parts of the game world.
Referenced zones (8x8 tiles) and map squares (64x64 tiles) are copied into the target region to populate it.
The input CoordGrid is used to find the source data which that coordinate was populated from.
Once the source data is found, this method returns its bottom-left CoordGrid.
| Parameter | Type | Description |
|---|---|---|
| coord | CoordGrid | The input coordinate. |
| Returns | Description |
|---|---|
| CoordGrid? | The bottom-left CoordGrid for the input coordinate's source data.Returns nil if the Player Character is not currently in a region, or the input coordinate was outside of the region bounds. |
Example
GetMapSquareBounds¶
Returns the map square bounds for the currently loaded game world.
Info
Values are in numbers of map squares. For example, when in a Dungeoneering region/instance this function returns:
This means that that bottom-left map square in the bounds is X=107, Z=1 and is both 2 map squares wide and long.| Returns | Description |
|---|---|
| Rect? | The rectangle encompassing the current World's map square bounds. |
Example
GetGroundHeight¶
function World.GetGroundHeight(level : Integer, x : Integer, z : Integer, heightOffsetType? : HeightOffsetType) -> Integer,Boolean
Returns the height for the given level and position values, along with whether the height was available for that position.
All positional values are in fine units, where a tile dimension is 512 fine units.
Info
Valid height values are always positive.
A value of -1 will be returned if the height could not be accessed.
| Parameter | Type | Description |
|---|---|---|
| level | Integer | The coordinate level of height map data to read.The value of level must be between 0 and 3. |
| x | Integer | The world-space X position, in fine units, to access the height value for. |
| z | Integer | The world-space Z position, in fine units, to access the height value for. |
| heightOffsetType? | HeightOffsetType | An optional parameter, indicating what kind of height offset should be applied to the base ground height at the sampled position. |
| Returns | Description |
|---|---|
| Integer,Boolean | The height and success pair for the input position values.Returns a height of -1 on failure. |
Example
RemoveRoof¶
Overview¶
The Remove Roof system allows the client to hide upper levels of the game world in order to provide a clearer view to players. Portions of the game world, such as the upper floors of a building, are grouped together and hidden as a whole when the system is told to 'reveal' a coordinate on a level underneath the group.
Some coordinates are marked in this way by default, such as:
- The Player Character's current coordinate, and
- All coordinates between the camera position and its focal target position.
The functions below allow plugins to add individual coordinates, and coordinate ranges, to further extend which parts of the game world should be hidden by this system.
Warning
These functions will only impact the Remove Roof system if the Graphics setting for Remove Roofs is set to Selectively.
Important
- A Remove Roof coordinate, or coordinate range, belongs to the plugin which registered it.
- Different plugins may share the same registered name without clashing.
- The coordinate, or coordinate range, will be removed when the plugin unloads.
Functions¶
Add(name, coord)¶
Adds the given coordinate to the Remove Roof system, registering it by the given name.
If the name has already been registered then the existing coordinate, or coordinate range, is updated with the new coordinate.
| Parameter | Type | Description |
|---|---|---|
| name | String | The name to register the coordinate with. |
| coord | CoordGrid | The coordinate to add to the Remove Roof system. |
Example
Add(name, coordRangeMin, coordRangeMax)¶
Adds the given coordinate range to the Remove Roof system, registering it by the given name.
If the name has already been registered then the existing coordinate, or coordinate range, is updated with the new coordinate range.
Info
The coordinate range is applied as shown in this pseudocode example:
| Parameter | Type | Description |
|---|---|---|
| name | String | The name to register the coordinate with. |
| coordRangeMin | CoordGrid | The minimum coordinate of the range to add to the Remove Roof system. |
| coordRangeMax | CoordGrid | The maximum coordinate of the range to add to the Remove Roof system. |
Example
-- Add the mouse coord, with a 1-tile buffer around it
local coordGrid = ScreenConvert.ScreenToCoordGrid(Mouse.GetPosition())
if coordGrid ~= nil then
local coordGridMin = CoordGrid.new(coordGrid)
local coordGridMax = CoordGrid.new(coordGrid)
coordGridMin.x = coordGridMin.x - 1
coordGridMin.z = coordGridMin.z - 1
coordGridMax.x = coordGridMax.x + 1
coordGridMax.z = coordGridMax.z + 1
World.RemoveRoof.Add("cursorTile", coordGridMin, coordGridMax)
end
Remove¶
Removes the coordinate, or coordinate range, registered by the given name from the Remove Roof system.
| Parameter | Type | Description |
|---|---|---|
| name | String | The registered name to remove. |
Example
Clear¶
Removes all Remove Roof coordinates registered by the current plugin.