Player (class)
Jump to navigation
Jump to search
This class provides fields/functions for managing Players in the current level or world map.
| Player class | |||
|---|---|---|---|
| Type | Function/Field | Return values/Value type | Description |
| Constructor | myPlayer = Player() | Player | Construct a new Player-Object. This objects references to the first player. You might want to use the constants player and player2 (for the 2nd player) instead. |
| Constructor | myPlayer = Player(int internalIndex) | Player | Construct a new Player-Object. This object reference to the player given in internalIndex. 1 = first player, 2 = second player |
| function | Player:mem(int offset, int fieldtype, object value) | nil | Sets a value of the Player struct at a specific address-offset. |
| function | Player:mem(int offset, int fieldtype) | object | Returns a value of the Player struct at a specific address-offset. |
| function | Player:kill() | nil | Kills the player. |
| function | Player:harm() | nil | Harms the player. |
| Field | Player.x | double | The x coordinate of the player. |
| Field | Player.y | double | The y coordinate of the player. |
| Field | Player.speedX | double | The x-speed of the player. |
| Field | Player.speedY | double | The y-speed of the player. |
| Field (ro) | Player.screen | RECT | Returns the distances from the player's coordinates to the screen boundaries of player camera. Note that this means width is 'right' + 'left', and not 'right' - 'left', etc. |
| Field (ro) | Player.section | int | Returns the current section number of the player. |
| Field (ro) | Player.sectionObj | Section | Returns the current section object of the player. |
| Field | Player.powerup | int | The current powerup state the player is in. See constants for the values you can put it. |
| Field | Player.character | int | The current character of the player is in. See constants for the values you can put it. (LunaLua ≥ v0.7.2) |
| Field | Player.reservePowerup | int | The npc-id in the powerup box of the player. |
| Field | Player.width | int | The player width. |
| Field | Player.height | int | The player height. |
| Field (ro) | Player.holdingNPC | NPC or nil | The npc which the player is holding. If the player holds nothing then nil is returned. |
| Field | Player.upKeyPressing | boolean | True, if the player is pressing the up key. Can be overwritten with the Event onInputUpdate, to lock or reverse controls (LunaLua ≥v0.7) |
| Field | Player.downKeyPressing | boolean | True, if the player is pressing the down key. Can be overwritten with the Event onInputUpdate, to lock or reverse controls (LunaLua ≥v0.7) |
| Field | Player.leftKeyPressing | boolean | True, if the player is pressing the left key. Can be overwritten with the Event onInputUpdate, to lock or reverse controls (LunaLua ≥v0.7) |
| Field | Player.rightKeyPressing | boolean | True, if the player is pressing the right key. Can be overwritten with the Event onInputUpdate, to lock or reverse controls (LunaLua ≥v0.7) |
| Field | Player.jumpKeyPressing | boolean | True, if the player is pressing the jump key. Can be overwritten with the Event onInputUpdate, to lock or reverse controls (LunaLua ≥v0.7) |
| Field | Player.altJumpKeyPressing | boolean | True, if the player is pressing the alt jump key. Can be overwritten with the Event onInputUpdate, to lock or reverse controls (LunaLua ≥v0.7) |
| Field | Player.runKeyPressing | boolean | True, if the player is pressing the run key. Can be overwritten with the Event onInputUpdate, to lock or reverse controls (LunaLua ≥v0.7) |
| Field | Player.altRunKeyPressing | boolean | True, if the player is pressing the alt run key. Can be overwritten with the Event onInputUpdate, to lock or reverse controls (LunaLua ≥v0.7) |
| Field | Player.dropItemKeyPressing | boolean | True, if the player is pressing the drop item key. Can be overwritten with the Event onInputUpdate, to lock or reverse controls (LunaLua ≥v0.7) |
| Field | Player.pauseKeyPressing | boolean | True, if the player is pressing the pause key. Can be overwritten with the Event onInputUpdate, to lock or reverse controls (LunaLua ≥v0.7) |
| function | Player:getCurrentPlayerSetting() | PlayerSettings | Returns a PlayerSettings object of the current character and powerup state of the Player. (LunaLua ≥ v0.7.2) |
| function | Player:getCurrentSpriteIndex() | number, number | Returns the current indexX and indexY of the sprite on the spritesheet. Can be used with PlayerSettings. (LunaLua ≥ v0.7.2) |
| function | Player:setCurrentSpriteIndex(number indexX, number indexY, boolean forceDirection) | nil | Sets the current sprite on the spritesheet. If forceDirection is true, then the direction of the player will be set. Caution: This may not work, depending on the players movement!. Can be used with PlayerSettings. (LunaLua ≥ v0.7.2) |
| Field (ro) | Player.isValid | boolean | Checks if the player is acutally valid. |
There are also raw fields. These fields are not maintained and not camel-case affected!