Warp (class)

From PGE Wiki
Jump to: navigation, 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.entranceX double The x coordinate of warp entrance.
Field Warp.entranceY double The y coordinate of warp entrance.
Field Warp.exitX double The x coordinate of warp exit.
Field Warp.exitY double The y coordinate of warp exit.
Field Warp.levelFilename string The level-filename of the warp.

Offsets

Warp Memory (0x90 bytes)
Name Memory address Memory type Description
Is locked 0x00 FIELD_WORD Whether the warp is locked (keyhole)
Allow carried NPCs 0x02 FIELD_WORD Whether carried NPCs can be brought through the warp
No Yoshi 0x04 FIELD_WORD Whether Yoshi is allowed
Unknown 0x06 FIELD_WORD Unknown
Layer name 0x08 VB6 String Pointer Entrance's layer name
Is hidden 0x0C FIELD_WORD Is hidden flag
Unknown 0x0E FIELD_WORD Unknown
Unknown 0x10 FIELD_WORD Unknown
Stars required 0x12 FIELD_WORD The number of stars required to use the warp
Entrance position 0x14 Momentum
Exit position 0x44 Momentum
Warp Type 0x74 FIELD_WORD 0 = instant, 1 = pipe, 2 = door
Unknown 0x76 FIELD_WORD Unknown
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
Unknown 0x8A FIELD_WORD Unknown
Unknown 0x8C FIELD_WORD Unknown
Unknown 0x8E FIELD_WORD Unknown