Liquid (class)

From PGE Wiki
Jump to navigation Jump to search

This class provides fields/functions for managing water/quicksand boxes in the current level.

Static functions

Static Liquid Functions
Function Return values Description
Liquid.count() number How many liquid boxes are in the level.
Liquid.get() table of Liquid Returns all liquid boxes
Liquid.getIntersecting(number x1, number y1, number x2, number y2) table of Liquid Returns all liquid boxes which are intersecting with an area from x1/y1 to x2/y2.
Liquid(number index) Liquid Returns the liquid box object at position index in the global liquid table. (Invalid liquids may be returned when using a strange index.)

Instance functions

These fields and functions are part of Liquid Objects and have to be called for that object. Trying to call them from the static Liquid class will result in an error. Example (feel free to copy it into your lua file to see how it works):

function onTick()
    for index,myLiquid in ipairs(Liquid.get()) do
        myLiquid.isQuicksand = true -- Turns all water boxes into quicksand boxes.
    end
end


Liquid class
Type Function/Field Return values/Value type Description
Function Liquid:mem(int offset, int fieldtype, object value) nil Sets a value of the liquid struct at a specific address-offset.
Function Liquid:mem(int offset, int fieldtype) object Returns a value of the liquid struct at a specific address-offset.
Field Liquid.isHidden boolean Whether or not the liquid box is hidden.
Field Liquid.x double The x coordinate of the liquid box.
Field Liquid.y double The y coordinate of the liquid box.
Field Liquid.width double The width of the liquid box.
Field Liquid.height double The height of the liquid box.
Field Liquid.speedX double The x-speed of the liquid box.
Field Liquid.speedY double The y-speed of the liquid box.
Field Liquid.isQuicksand boolean Whether or not the liquid box is quicksand.
Field Liquid.layerName VBStr The layer name of the liquid box.
Field Liquid.layer Layer The layer object of the liquid.
Field (ro) Liquid.isValid boolean Checks if the liquid box is acutally valid. Should always be used when storing this class into a variable/field.


Liquid Memory
Name Memory address Memory type Description
SMBX Liquid+0x00 0x00 VB6StrPtr Name of the layer the liquid box belongs to.
SMBX Liquid+0x02 0x04 FIELD_BOOL Whether or not this liquid box is hidden.
SMBX Liquid+0x04 0x06 FIELD_FLOAT Unused.
SMBX Liquid+0x06 0x0C FIELD_WORD Whether or not this liquid box is quicksand.
SMBX Liquid+0x20 0x10 FIELD_DFLOAT Current x-position
SMBX Liquid+0x28 0x18 FIELD_DFLOAT Current y-position
SMBX Liquid+0x30 0x20 FIELD_DFLOAT Height
SMBX Liquid+0x38 0x28 FIELD_DFLOAT Width
SMBX Liquid+0x40 0x30 FIELD_DFLOAT Current x-speed
SMBX Liquid+0x48 0x38 FIELD_DFLOAT Current y-speed