Overlay Module¶
The Overlay Module allows scripts render stuff on player's GUI.
Objects¶
All fields will have a getter and a setter, which is defined as getXxx and setXxx.
For boolean fields, getter is defined as either isXxx or hasXxx.
OverlayObject¶
| Field | Type | Default | Description |
|---|---|---|---|
enabled |
boolean |
true |
whether or not to render the object |
type¶
getType() -> string
returns the object's type.
getId¶
getId() -> number
returns the object's integer ID.
RenderableObject¶
Based on OverlayObject
| Field | Type | Default | Description |
|---|---|---|---|
opacity |
number |
1 |
A decimal number that determines the transparency of the object, in range of [0.0, 1.0] |
color |
number |
-1 |
An integer that determines the color of the object, in format of 0xRRGGBB. The default value -1 is equivalent to 0xFFFFFF in most cases. |
x |
number |
0 |
A decimal number of the object's X position |
y |
number |
0 |
A decimal number of the object's Y position |
z |
number |
0 |
A decimal number of the object's Z position |
rotX |
number |
0 |
A decimal number determine the degrees the object's rotation around the X-axis, in range of [0, 360] |
rotY |
number |
0 |
A decimal number determine the degrees the object's rotation around the Y-axis, in range of [0, 360] |
rotZ |
number |
0 |
A decimal number determine the degrees the object's rotation around the Z-axis, in range of [0, 360] |
getPos¶
getPos() -> number, number, number
returns the object's x, y, z.
setPos¶
setPos(number, number, number) -> nil
sets the object's x, y, z.
CircleObject¶
Based on RenderableObject
| Field | Type | Default | Description |
|---|---|---|---|
radius |
number |
0 |
Integer of the circle's radius, in range of [0, ∞) |
filled |
boolean |
true |
If the circle should be filled |
pixelated |
boolean |
true |
If the circle should be pixelated |
borderWidth |
number |
4 |
Integer of the circle's border width, in range of [0, 32767] |
segments |
number |
25 |
Integer of the circle's segments, in range of [0, 100] |
ItemObject¶
Based on RenderableObject
| Field | Type | Default | Description |
|---|---|---|---|
item |
string | nil |
nil |
The registry ID of the item to render |
LineObject¶
Based on RenderableObject
| Field | Type | Default | Description |
|---|---|---|---|
endX |
number |
0 |
A decimal number of line's X end |
endY |
number |
0 |
A decimal number of line's Y end |
pixelated |
boolean |
false |
If the line should be pixelated |
width |
number |
4 |
Integer of the line's width, in range of [0, 32767] |
getEndPos¶
getEndPos() -> number, number
returns the object's endX, endY.
setEndPos¶
setEndPos(number, number) -> nil
sets the object's endX, endY.
RectangleObject¶
Based on RenderableObject
| Field | Type | Default | Description |
|---|---|---|---|
sizeX |
number |
0 |
A decimal number of rectangle's X size, in range of [0, ∞) |
sizeY |
number |
0 |
A decimal number of rectangle's Y size, in range of [0, ∞) |
getSizes¶
getSizes() -> number, number
returns the object's sizeX, sizeY.
setSizes¶
setSizes(sizeX: number, sizeY: number) -> nil
sets the object's sizeX, sizeY.
TextObject¶
Based on RenderableObject
| Field | Type | Default | Description |
|---|---|---|---|
content |
string |
"" |
The text to render |
fontSize |
number |
1 |
A decimal number represents the text's font size, in range of [0.0, 128.0] |
shadow |
boolean |
false |
Whether or not render a shadow for the text |
center |
boolean |
false |
If the text should be centered at its position |
ThreeDimensionalObject¶
Based on RenderableObject
| Field | Type | Default | Description |
|---|---|---|---|
relativePosition |
boolean |
false |
Should the object's position relative to the player's head |
relativeRotation |
boolean |
false |
Should the object's rotation relative to the player's head |
depthTest |
boolean |
true |
If the object should hide behind other objects |
culling |
boolean |
true |
If the object's hidden faces should not be seen |
BoxObject¶
Based on ThreeDimensionalObject
| Field | Type | Default | Description |
|---|---|---|---|
sizeX |
number |
0 |
A decimal number of rectangle's X size, in range of [0, ∞) |
sizeY |
number |
0 |
A decimal number of rectangle's Y size, in range of [0, ∞) |
sizeZ |
number |
0 |
A decimal number of rectangle's Z size, in range of [0, ∞) |
getSizes¶
getSizes() -> number, number, number
returns the object's sizeX, sizeY, sizeZ.
setSizes¶
setSizes(sizeX: number, sizeY: number, sizeZ: number) -> nil
sets the object's sizeX, sizeY, sizeZ.
BlockObject¶
Based on BoxObject
| Field | Type | Default | Description |
|---|---|---|---|
block |
string? |
nil |
The registry ID of the block to render |
states |
table |
default states of the block | The states of the block |
tintAll |
boolean |
false |
Make the color attribute affect the whole block, not only the tintable parts |
If color is -1, the block will shown with its original color palettes.
SphereObject¶
Based on ThreeDimensionalObject
| Field | Type | Default | Description |
|---|---|---|---|
sectors |
number |
16 |
An integer in range of [1, 1024] |
stacks |
number |
16 |
An integer in range of [1, 1024] |
radius |
number |
1 |
A decimal number of the sphere's radius, in range of (0, 128] |
TextureObject¶
Based on ThreeDimensionalObject
| Field | Type | Default | Description |
|---|---|---|---|
sizeX |
number |
0 |
A decimal number of texture's X size, in range of [0, ∞) |
sizeY |
number |
0 |
A decimal number of texture's Y size, in range of [0, ∞) |
width |
number |
0 |
Image X-axis pixels count in range of [0, 4096) |
height |
number |
0 |
Image Y-axis pixels count in range of [0, 4096) |
getSizes¶
getSizes() -> number, number
returns the texture's sizeX, sizeY.
setSizes¶
setSizes(sizeX: number, sizeY: number) -> nil
sets the texture's sizeX, sizeY.
getImageSize¶
getImageSize() -> number, number
returns the texture's width, height.
setImageSize¶
setImageSize(width: number, height: number) -> nil
sets the texture's width, height.
getPixel¶
getPixel(x: number, y: number) -> number
returns the texture's pixel at (x, y), in format of 0xAARRGGBB.
setPixel¶
setPixel(x: number, y: number, color: number) -> nil
sets the texture's pixel at (x, y), in format of 0xAARRGGBB.
getAllPixels¶
getAllPixels() -> table
returns the texture's all pixels as a 2D map that can be indexed by pixels[y][x].
getPixels¶
getPixels(minX: number, minY: number, width: number, height: number) -> table
returns the texture's sub-pixels in the range as a 2D map that can be indexed by pixels[y][x].
setPixels¶
setPixels(minX: number, minY: number, two_dim_data: table) -> nil
setPixels(minX: number, minY: number, width: number, height: number, one_dim_data: table) -> nil
sets the texture's sub-pixels in the range from a 2D map that can be indexed by pixels[y][x],
or from a 1D map that can be indexed by pixels[(y - 1) * width + x]
load¶
load(data: string) -> nil
load texture from data (which is the image bytes). width and height will be set to the image's width and height afterwards.
Info
Supported image format may vary depends on the server.
Default supported formats may include bmp, gif, jpeg, png, tiff, wbmp.
TorusObject¶
Based on ThreeDimensionalObject
| Field | Type | Default | Description |
|---|---|---|---|
sides |
number |
32 |
An integer in range of [1, 1024] |
rings |
number |
16 |
An integer in range of [1, 1024] |
minorRadius |
number |
0.1 |
A decimal number of inner radius of the ring, in range of (0, 128] |
majorRadius |
number |
0.5 |
A decimal number of outer radius of the ring, in range of (0, 128] |
TriangleObject¶
Based on ThreeDimensionalObject
Note
Triangle objects only visible when the vertex is ordered in counter-clockwise.
| Field | Type | Default | Description |
|---|---|---|---|
x1 |
number |
0 |
A decimal number of the first vertex's X position |
y1 |
number |
0 |
A decimal number of the first vertex's Y position |
z1 |
number |
0 |
A decimal number of the first vertex's Z position |
x2 |
number |
0 |
A decimal number of the second vertex's X position |
y2 |
number |
0 |
A decimal number of the second vertex's Y position |
z2 |
number |
0 |
A decimal number of the second vertex's Z position |
x3 |
number |
0 |
A decimal number of the third vertex's X position |
y3 |
number |
0 |
A decimal number of the third vertex's Y position |
z3 |
number |
0 |
A decimal number of the third vertex's Z position |
getPos1¶
getPos1() -> number, number, number
returns the object's x1, y1, z1.
setPos1¶
setPos1(x1: number, y1: number, z1: number) -> nil
sets the object's x1, y1, z1.
getPos2¶
getPos2() -> number, number, number
returns the object's x2, y2, z2.
setPos2¶
setPos2(x2: number, y2: number, z2: number) -> nil
sets the object's x2, y2, z2.
getPos3¶
getPos3() -> number, number, number
returns the object's x3, y3, z3.
setPos3¶
setPos3(x3: number, y3: number, z3: number) -> nil
sets the object's x3, y3, z3.
Functions¶
createObject¶
createObject(id: string, object: table) -> table
id must be a valid object's type ID
object should contains the object's initial properties
returns a copy of the object with getters & setters to change its properties.
createBlock¶
createBlock(object: table) -> table
object is a BlockObject
returns a copy of the object with getters & setters to change its properties.
createBox¶
createBox(object: table) -> table
object is a BoxObject
returns a copy of the object with getters & setters to change its properties.
createSphere¶
createSphere(object: table) -> table
object is a SphereObject
returns a copy of the object with getters & setters to change its properties.
createTexture¶
createTexture(object: table) -> table
object is a TextureObject
returns a copy of the object with getters & setters to change its properties.
createTorus¶
createTorus(object: table) -> table
object is a TorusObject
returns a copy of the object with getters & setters to change its properties.
createTriangle¶
createTriangle(object: table) -> table
object is a TriangleObject
returns a copy of the object with getters & setters to change its properties.
createCircle¶
createCircle(object: table) -> table
object is a CircleObject
returns a copy of the object with getters & setters to change its properties.
createItem¶
createItem(object: table) -> table
object is a ItemObject
returns a copy of the object with getters & setters to change its properties.
createLine¶
createLine(object: table) -> table
object is a LineObject
returns a copy of the object with getters & setters to change its properties.
createRectangle¶
createRectangle(object: table) -> table
object is a RectangleObject
returns a copy of the object with getters & setters to change its properties.
createText¶
createText(object: table) -> table
object is a TextObject
returns a copy of the object with getters & setters to change its properties.
getObject¶
getObject(id: number) -> table | nil
returns a RenderableObject by the object's ID, or nil if the ID not exists.
removeObject¶
removeObject(id: number) -> boolean
remove an object by its ID and returns if the object with given ID existed
clear¶
clear() -> number
remove all objects, returns the number of removed object.
getObjectsCount¶
getObjectsCount() -> number
returns the number of all objects.
getGuiSize¶
getGuiSize() -> number, number, number
returns the client's width, height, and GUI scale
getEyePosition¶
getEyePosition() -> number, number, number
returns the player's eye position
update¶
update() -> number
manually update objects, returns the number of updated object.
isAutoUpdating¶
isAutoUpdating() -> boolean
returns if objects will be auto synced to client when its fields updating
setAutoUpdate¶
setAutoUpdate(value: boolean) -> nil
sets if objects will be auto synced to client
Changelog/Trivia¶
0.8
Added Overlay Module
