Warp (class)

From PGE Wiki
Jump to navigation Jump to search

This class provides fields/functions for managing Warps in the current level. (LunaLua ≥v0.7)

Static functions

Static Warp Functions
Function Return values Description
Warp.count() number How many warps are in the level.
Warp.get() table of Warp Returns all existing warps.
Warp.getIntersectingEntrance(number x1, number y1, number x2, number y2) table of Animation Returns all warps with an entrance intersecting with an area from x1/y1 to x2/y2.
Warp.getIntersectingExit(number x1, number y1, number x2, number y2) table of Animation Returns all warps with an exit intersecting with an area from x1/y1 to x2/y2.
Warp(number index) Warp Returns the Warp object at position index in the global Warp table. Use this constructor with caution! Use Warp.get instead!! (See above)

Instance functions

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

function onStart()
    for index,myWarp in ipairs(Warp.get()) do
        myWarp.exitX = player.x
        myWarp.exitY = player.y
    end
end
Warp class
Type Function/Field Return values/Value type Description
function Warp:mem(int offset, int fieldtype, object value) nil Sets a value of the Warp struct at a specific address-offset.
function Warp:mem(int offset, int fieldtype) object Returns a value of the Warp struct at a specific address-offset.
Field Warp.layerName string The layer name of the warp.
Field Warp.layer Layer The layer name of the warp.
Field Warp.isHidden boolean Whether or not the warp is hidden.
Field Warp.entranceX double The x coordinate of the warp's entrance.
Field Warp.entranceY double The y coordinate of the warp's entrance.
Field Warp.entranceWidth double The width of the warp's entrance.
Field Warp.entranceHeight double The height of the warp's entrance.
Field Warp.entranceSpeedX double The x-speed of the warp's entrance.
Field Warp.entranceSpeedY double The y-speed of the warp's entrance.
Field Warp.entranceDirection number The direction of the warp's entrance. 1 is for up, 2 is for left, 3 is for down, and 4 is for right.
Field Warp.entranceSection number The section of the warp's entrance.
Field Warp.exitX double The x coordinate of the warp's exit.
Field Warp.exitY double The y coordinate of the warp's exit.
Field Warp.exitWidth double The width of the warp's exit.
Field Warp.exitHeight double The height of the warp's exit.
Field Warp.exitSpeedX double The x-speed of the warp's exit.
Field Warp.exitSpeedY double The y-speed of the warp's exit.
Field Warp.exitDirection number The direction of the warp's exit. 1 is for down, 2 is for right, 3 is for up, and 4 is for left.
Field Warp.exitSection number The section of the warp's exit.
Field Warp.warpType number The type of the warp. 0 is for instant, 1 is for pipe and 2 is for door.
Field Warp.levelFilename string The level-filename of the warp.
Field Warp.warpNumber number The index of the warp that a player will be sent to if this warps sends the player to a different level.
Field Warp.toOtherLevel boolean Whether or not this warps sends a player to a different level.
Field Warp.fromOtherLevel boolean Whether or not this warp comes from a different level.
Field Warp.worldMapX number The x coordinate on the map that a player is sent to after entering the warp.
Field Warp.worldMapY number The y coordinate on the map that a player is sent to after entering the warp.
Field Warp.locked boolean Whether or not the warp is currently locked.
Field Warp.allowItems boolean Whether or not held NPCs are allowed through the warp.
Field Warp.noYoshi boolean Whether or not a player can enter the warp when mounted.
Field Warp.starsRequired number How many stars are needed to enter the warp.

Offsets

Warp Memory (0x90 bytes)
Name Memory address Memory type Description
Is locked 0x00 FIELD_BOOL Whether the warp is locked (keyhole)
Allow carried NPCs 0x02 FIELD_BOOL Whether carried NPCs can be brought through the warp
No Yoshi 0x04 FIELD_BOOL Whether Yoshi is allowed
Layer name 0x08 VB6 String Pointer Entrance's layer name
Is hidden 0x0C FIELD_WORD Is hidden flag
Unknown 0x0E FIELD_BOOL Unknown (used by the legacy editor, according to the source code)
Unknown 0x10 FIELD_BOOL Unknown (used by the legacy editor, according to the source code)
Stars required 0x12 FIELD_WORD The number of stars required to use the warp
Entrance X 0x14 FIELD_DFLOAT The x coordinate of the warp's entrance.
Entrance Y 0x1C FIELD_DFLOAT The y coordinate of the warp's entrance.
Entrance Height 0x24 FIELD_DFLOAT The height of the warp's entrance.
Entrance Width 0x2C FIELD_DFLOAT The width of the warp's entrance.
Entrance Y-Speed 0x34 FIELD_DFLOAT The x-speed of the warp's entrance.
Entrance Y-Speed 0x3C FIELD_DFLOAT The y-speed of the warp's entrance.
Exit X 0x44 FIELD_DFLOAT The x coordinate of the warp's exit.
Exit Y 0x4C FIELD_DFLOAT The y coordinate of the warp's exit.
Exit Height 0x54 FIELD_DFLOAT The height of the warp's exit.
Exit Width 0x5C FIELD_DFLOAT The width of the warp's exit.
Exit X-Speed 0x64 FIELD_DFLOAT The x-speed of the warp's exit.
Exit Y-Speed 0x6C FIELD_DFLOAT The y-speed of the warp's exit.
Warp Type 0x74 FIELD_WORD 0 = instant, 1 = pipe, 2 = door
Level filename 0x78 VB6 String Pointer The filename of the level this warp loads
Warp number 0x7C FIELD_WORD The warp number
Is level entrance 0x7E FIELD_WORD Whether this warp takes the player to a different level
Entrance direction 0x80 FIELD_WORD 1 = up; 2 = left; 3 = down; 4 = right
Exit direction 0x82 FIELD_WORD 1 = down; 2 = right; 3 = up; 4 = left
Is level exit 0x84 FIELD_WORD Whether this warp ends the level
World map X 0x86 FIELD_WORD X coordinate on the map the player is moved to
World map Y 0x88 FIELD_WORD Y coordinate on the map the player is moved to
Star Count 0x8A FIELD_WORD The number of stars collected in the level that the warp leads to.
Total Star Count 0x8C FIELD_WORD The total number of stars in the level that the warp leads to.