LunaScript Memory Map - TheXTech/TheXTech GitHub Wiki

Contents

Memory emulator mapping reference

Since LunaScript inherited the memory commands and has a goal to allow old scripts made for original LunaDLL to work on TheXTech. Unlike the original LunaDLL, there is only a part of the global variables is available for manipulation.

Global memory

Absolute addresses of the SMBX binary global memory.

Note: Some fields are available since a specific version of TheXTech.

Mapped address Internal field name Data type Description Minimal TheXTech version
0x00B2504C TakeScreen bool Take a screenshot. Set this field to True to cause a screenshot to be taken and saved on the next frame. It gets reset back to False after the screenshot got been saved. 1.3.6
0x00B250D6 numLocked int32 Number of locked doors. The number of additional BGOs added into the array together with locked doors. 1.3.6
0x00B250E2 GamePaused bool Read-only simulation of the GamePaused variable. Internally it's an enumeration. 1.3.6
0x00B25134 LevelEditor bool It's true when the built-in level editor is active. Can't be used by scripts. 1.3.6
0x00B251E0 numStars int32 The number of collected stars. 1.3.6
0x00B25700 numWater int32 Number of physical environment zones placed on the level. 1.3.6
0x00B25724 StartLevel string The next level to open after exiting the current level. Can't be accessed through LunaScript. 1.3.6
0x00B25728 NoMap bool It's true when it's a hub-based episode without a world map. 1.3.6
0x00B2572A RestartLevel bool If it's true, the level will get restarted after the player fails to play it. 1.3.6
0x00B257A4 numTiles int32 Number of terrain tiles placed on the world map. 1.3.6
0x00B257A6 numScenes int32 Number of sceneries placed on the world map. 1.3.6
0x00B258E0 numWorldPaths int32 Number of path cells placed on the world map. 1.3.6
0x00B258E2 numWarps int32 Number of warp entries placed on a current level. 1.3.6
0x00B25956 numBlock int32 Number of blocks placed on a current level. 1.3.6
0x00B25958 numBackground int32 Number of background objects placed on a current level. 1.3.6
0x00B2595A numNPCs int32 Total number of NPCs on a current level. 1.3.6
0x00B2595E numPlayers int32 Number of playable characters walking on a current level. 1.3.6
0x00B25960 numWorldLevels int32 Number of level entrances placed on the world map. 1.3.6
0x00B25980 numWorldMusic int32 Number of music boxes placed on the world map. 1.3.6
0x00B2C5A8 Coins int32 Number of coins that player holds. 1.3.6
0x00B2C5AC Lives int32 Amount of lives that player has. 1.3.6
0x00B2C624 WorldName string Name of episode. Can't be accessed through LunaScript. 1.3.6
0x00B2C62C PSwitchTime int32 P-Switch timer 1.3.6
0x00B2C62E PSwitchStop int32 Stopwatch timer 1.3.6
0x00B2C630 PSwitchPlayer int32 Player array index who started the P-Switch mechanism. 1.3.6
0x00B2C684 FrameSkip bool When it's true, the frame-skipping mechanism will be enabled. 1.3.6
0x00B2C6DC Physics.PlayerJumpHeight int32 Jump height for playable character. 1.3.6.1
0x00B2C6DE Physics.PlayerBlockJumpHeight int32 Block jump height. 1.3.6.1
0x00B2C6E0 Physics.PlayerHeadJumpHeight int32 Player Head Jump Height: Jump height off another players head. 1.3.6.1
0x00B2C6E2 Physics.PlayerNPCJumpHeight int32 NPC jump height. 1.3.6.1
0x00B2C6E4 Physics.PlayerSpringJumpHeight int32 Spring jump height. 1.3.6.1
0x00B2C6E8 Physics.PlayerJumpVelocity float32 Jump velocity. 1.3.6.1
0x00B2C6EC Physics.PlayerRunSpeed float32 Run speed. 1.3.6.1
0x00B2C6F0 Physics.PlayerWalkSpeed float32 Walk speed. 1.3.6.1
0x00B2C6F4 Physics.PlayerTerminalVelocity int32 Terminal velocity. 1.3.6.1
0x00B2C6F8 Physics.PlayerGravity float32 Gravity of playable character. 1.3.6.1
0x00B2C860 Physics.NPCShellSpeed float32 Speed of NPC shell. 1.3.6.1
0x00B2C864 Physics.NPCShellSpeedY float32 Y speed of NPC shell. 1.3.6.1
0x00B2C868 Physics.NPCWalkingSpeed float32 NPC walking speed. 1.3.6.1
0x00B2C86C Physics.NPCWalkingOnSpeed float32 Speed of NPCs that can be walked on walking speed. 1.3.6.1
0x00B2C870 Physics.NPCMushroomSpeed float32 Universal speed for mushroom NPCs. 1.3.6.1
0x00B2C874 Physics.NPCGravity float32 The buffer of the current NPC gravity. 1.3.6.1
0x00B2C878 Physics.NPCGravityReal float32 The default NPC gravity factor. 1.3.6.1
0x00B2C87C Physics.NPCPSwitch int32 Duration of the P-Switch effect in 1/65 of seconds (the duration of one in-game frame). 1.3.6
0x00B2C880 MenuCursor int32 Currently selected main menu item at the main menu. 1.3.6
0x00B2C882 MenuMode int32 Current main menu mode identifier. 1.3.6
0x00B2C894 BlocksSorted bool Read-only simulation of the BlocksSorted variable. Always true. 1.3.6
0x00B2C896 SingleCoop int32 Two-player game related state. 1.3.6.1
0x00B2C898 CheatString string Text input buffer used to detect any typed cheat codes. 1.3.6.1
0x00B2C89C GameOutro bool It's true when a credits screen is active. 1.3.6.1
0x00B2C8A0 CreditChop float The size of black edges at the credits screen. 1.3.6.1
0x00B2C8A4 EndCredits int32 Timer before the end of the credits. 1.3.6.1
0x00B2C8A6 curStars int32 Number of currently taken stars. 1.3.6.1
0x00B2C8A8 maxStars int32 Total number of stars at the current level. 1.3.6.1
0x00B2C8AA ShadowMode bool Enable the Shadow Star cheat. 1.3.6.1
0x00B2C8AC MultiHop bool Enable the Multi Hop cheat. 1.3.6.1
0x00B2C8AE SuperSpeed bool Enable the Super-Speed cheat. 1.3.6.1
0x00B2C8B0 WalkAnywhere bool Enable the Walk Anywhere cheat at the world map. 1.3.6.1
0x00B2C8B2 FlyForever bool Enable the Forever flying cheat. 1.3.6.1
0x00B2C8B4 FreezeNPCs bool When it's true, all NPC logic will be suspended. Used by a stopwatch effect. 1.3.6
0x00B2C8B6 CaptainN bool Enable the Captain N cheat. 1.3.6.1
0x00B2C8B8 FlameThrower bool Enable the Flame Thrower cheat. 1.3.6.1
0x00B2C8BA CoinMode bool Enable the Money Tree cheat. 1.3.6.1
0x00B2C8BE MaxFPS bool Toggle framerate into the maximum. 1.3.6.1
0x00B2C8C0 GodMode bool Makes playable character being immortal. 1.3.6.1
0x00B2C8C2 GrabAll bool Enable the Sticky Fingers cheat. 1.3.6.1
0x00B2C8C4 Cheater bool This variable gets true when the player types any cheat code. When it's true, a player is unable to save the game. 1.3.6
0x00B2C8E4 Score int32 The number of points earned by the player, is shown in the HUD. 1.3.6
0x00B2C906 MaxWorldStars int32 Total stars available in the current episode. 1.3.6
0x00B2C908 Debugger bool It's true when the in-editor debugger is shown. 1.3.6.1
0x00B2D6B8 PlayerCharacter int32 Selected playable character for the first player at the main menu. 1.3.6.1
0x00B2D6BA PlayerCharacter2 int32 Selected playable character for the second player at the main menu. 1.3.6.1
0x00B2D6BC SharedCursor.X double Mouse cursor position X. 1.3.6
0x00B2D6C4 SharedCursor.Y double Mouse cursor position Y. 1.3.6
0x00B2D6CC SharedCursor.Primary bool Gets true when a left mouse button gets pressed down. 1.3.6
0x00B2D6D0 MenuMouseRelease bool Gets true for one frame after the mouse button got released. 1.3.6
0x00B2D6D2 SharedCursor.Move bool Gets true after the mouse got moved after the previous frame. 1.3.6
0x00B2D710 numEvents int32 Number of events added into the current level. 1.3.6
0x00B2D734 noSound bool It's true when the sound engine is disabled. 1.3.6
0x00B2D740 BattleMode bool If it's true, the battle mode game is active. 1.3.6.1

Location_t structure

This is a structure used to hold coordinates and speed values. Used multiple times below. All addresses are relative to the base address of the structure field location at the Player_t or NPC_t.

Mapped address Internal field name Data type Description
0x00 Location_t::X double Position X (pixels)
0x08 Location_t::Y double Position Y (pixels)
0x10 Location_t::Height double Height of object in pixels.
0x18 Location_t::Width double Width of object in pixels.
0x20 Location_t::SpeedX double Speed X in pixels per 1/65 of the second.
0x28 Location_t::SpeedY double Speed Y in pixels per 1/65 of the second.

Controls_t structure

This is a structure used to hold the state of control. All addresses are relative to the base address of the structure field location at the Player_t.

Mapped address Internal field name Data type Description
0x00 Controls_t::Up bool UP key is pressed.
0x02 Controls_t::Down bool DOWN key is pressed.
0x04 Controls_t::Left bool LEFT key is pressed.
0x06 Controls_t::Right bool RIGHT key is pressed.
0x08 Controls_t::Jump bool JUMP key is pressed.
0x0A Controls_t::AltJump bool ALT-JUMP key is pressed.
0x0C Controls_t::Run bool RUN key is pressed.
0x0E Controls_t::AltRun bool ALT-RUN key is pressed.
0x10 Controls_t::Drop bool DROP key is pressed.
0x12 Controls_t::Start bool START key is pressed.

Player memory

Relative addresses of the Player_t structure used for playable characters.

At LunaScript, you can access these fields using the next commands:

  • OnPlayerMem - Trigger a LunaScript event when the referred memory field met the given condition.
  • LoadPlayerVar - Load the data of the referred memory field into the variable by name set at the "reference" part.
  • PlayerMemSet - Set the data to the referred memory field of the Player_t structure.
Mapped address Internal field name Data type Description
0x000 Player_t::DoubleJump bool
0x002 Player_t::FlySparks bool
0x004 Player_t::Driving bool
0x006 Player_t::Quicksand int32
0x008 Player_t::Bombs int32
0x00a Player_t::Slippy bool
0x00c Player_t::Fairy bool
0x00e Player_t::FairyCD int32
0x010 Player_t::FairyTime int32
0x012 Player_t::HasKey bool
0x014 Player_t::SwordPoke int32
0x016 Player_t::Hearts int32
0x018 Player_t::CanFloat bool
0x01a Player_t::FloatRelease bool
0x01c Player_t::FloatTime int32
0x020 Player_t::FloatSpeed float32
0x024 Player_t::FloatDir int32
0x026 Player_t::GrabTime int32 The time of how long the player has been trying to grab an npc from above.
0x028 Player_t::GrabSpeed float32
0x02c Player_t::VineNPC double The NPC that the player is climbing.
0x034 Player_t::Wet int32 Weather or not the player is underwater.
0x036 Player_t::WetFrame bool True if the play should be swimming.
0x038 Player_t::SwimCount int32 Cool down between swim strokes.
0x03a Player_t::NoGravity int32
0x03c Player_t::Slide bool True if the player is sliding.
0x03e Player_t::SlideKill bool True if the player is sliding fast enough to kill an NPC.
0x040 Player_t::Vine int32 Greater than 0 if the player is climbing.
0x042 Player_t::NoShellKick int32 Don't kick a shell.
0x044 Player_t::ShellSurf bool True if surfing a shell.
0x046 Player_t::StateNPC int32
0x048 Player_t::Slope int32 The block that the player is standing on when on a slope.
0x04a Player_t::Stoned bool True of a statue form (tanooki suit).
0x04c Player_t::StonedCD int32 Delay before going back into stone form.
0x04e Player_t::StonedTime int32 The time of how long the player can remain as a statue.
0x050 Player_t::SpinJump bool True if spin jumping.
0x052 Player_t::SpinFrame int32 Frame for spinning.
0x054 Player_t::SpinFireDir int32 For shooting fireballs while spin jumping.
0x056 Player_t::Multiplier int32 For score increase for multiple hops.
0x058 Player_t::SlideCounter int32 For creating the dust effect when sliding.
0x05a Player_t::ShowWarp int32
0x05c Player_t::GroundPound bool For purple Yoshi pound.
0x05e Player_t::GroundPound2 bool For purple Yoshi pound.
0x060 Player_t::CanPound bool For purple Yoshi pound.
0x062 Player_t::ForceHold int32 Force the player to hold an item for a specific amount of time.
0x064 Player_t::YoshiYellow bool Power of Yellow Yoshi.
0x066 Player_t::YoshiBlue bool Power of Blue Yoshi.
0x068 Player_t::YoshiRed bool Power of Red Yoshi.
0x06a Player_t::YoshiWingsFrame int32
0x06c Player_t::YoshiWingsFrameCount int32
0x06e Player_t::YoshiTX int32 Yoshi top display offset X.
0x070 Player_t::YoshiTY int32 Yoshi top display offset Y.
0x072 Player_t::YoshiTFrame int32 Yoshi top frame to display.
0x074 Player_t::YoshiTFrameCount int32 Yoshi top frames counter.
0x076 Player_t::YoshiBX int32 Yoshi bottom display offset X.
0x078 Player_t::YoshiBY int32 Yoshi bottom display offset Y.
0x07a Player_t::YoshiBFrame int32 Yoshi bottom frame to display.
0x07c Player_t::YoshiBFrameCount int32 Yoshi bottom frames counter.
0x0с0 Player_t::YoshiTongue Location_t Begin of the YoshiTongue structure. The offset of Yoshi's tongue relative to the player. See Location_t reference above. You should add the Location_t address to 0x80 to get the valid address of this sub-structure field.
0x0b0 Player_t::YoshiTongueX float32
0x0b4 Player_t::YoshiTongueLength int32 Length of Yoshi's tongue.
0x0b6 Player_t::YoshiTonugeBool bool
0x0b8 Player_t::YoshiNPC int32 The NPC that is in Yoshi's mouth.
0x0ba Player_t::YoshiPlayer int32 The player that is in Yoshi's mouth.
0x0bc Player_t::Dismount int32 Delay before you can remount.
0x0be Player_t::NoPlayerCol int32
0x0с0 Player_t::Location Location_t Begin of the Location structure. The absolute position of the player. See Location_t reference above. You should add the Location_t address to 0xC0 to get the valid address of this sub-structure field.
0x0f0 Player_t::Character int32 Playable character ID.
0x0f2 Player_t::Controls Controls_t Begin of the Controls structure. State of player's controls. See Controls_t reference above. You should add the Location_t address to 0xF2 to get the valid address of this sub-structure field.
0x106 Player_t::Direction int32 Direction of player's facing.
0x108 Player_t::Mount int32 Mount type (0 - none, 1 - shoe, 2 - clown car, 3 - Yoshi)
0x10a Player_t::MountType int32 The sub-type of the mount (colour, variant).
0x10c Player_t::MountSpecial int32
0x10e Player_t::MountOffsetY int32
0x110 Player_t::MountFrame int32 GFX frame for the player's mount.
0x112 Player_t::State int32 1 for a small state, 2 for super, 3 for fire, 4 for racoon, 5 for tanooki, 6 for hammer, 7 for an ice
0x114 Player_t::Frame int32
0x118 Player_t::FrameCount int32
0x11c Player_t::Jump int32 How long the player can jump for.
0x11e Player_t::CanJump bool True if the player can jump.
0x120 Player_t::CanAltJump bool True if the player can alt jump.
0x122 Player_t::Effect int32 For various effects like shrinking/growing/warping.
0x124 Player_t::Effect2 double Counter for the effects.
0x12c Player_t::DuckRelease bool
0x12e Player_t::Duck bool True if ducking.
0x130 Player_t::DropRelease bool
0x132 Player_t::StandUp bool Aid with collision detection after ducking.
0x134 Player_t::StandUp2 bool
0x136 Player_t::Bumped bool True if hit by another player.
0x138 Player_t::Bumped2 float32
0x13c Player_t::Dead bool True when the character got failed the game.
0x13e Player_t::TimeToLive int32
0x140 Player_t::Immune int32
0x142 Player_t::Immune2 bool
0x144 Player_t::ForceHitSpot3 bool
0x146 Player_t::Pinched1 int32
0x148 Player_t::Pinched2 int32
0x14a Player_t::Pinched3 int32
0x14c Player_t::Pinched4 int32
0x14e Player_t::NPCPinched int32
0x150 Player_t::m2Speed float32
0x154 Player_t::HoldingNPC int32
0x156 Player_t::CanGrabNPCs bool
0x158 Player_t::HeldBonus int32
0x15a Player_t::Section int32
0x15c Player_t::WarpCD int32
0x15e Player_t::Warp int32
0x160 Player_t::FireBallCD int32
0x162 Player_t::FireBallCD2 int32
0x164 Player_t::TailCount int32
0x168 Player_t::RunCount float32
0x16c Player_t::CanFly bool
0x16e Player_t::CanFly2 bool
0x170 Player_t::FlyCount int32
0x172 Player_t::RunRelease bool
0x174 Player_t::JumpRelease bool
0x176 Player_t::StandingOnNPC int32
0x178 Player_t::StandingOnTempNPC int32
0x17a Player_t::UnStart bool
0x17c Player_t::mountBump float32
0x180 Player_t::SpeedFixY float32

NPC memory

Relative addresses of the Player_t structure used for non-playable characters.

At LunaScript, you can access these fields using the next commands:

  • LoadNPCVar - Load the data of the referred memory field into the variable by name set at the "reference" part.
  • NPCMemSet - Set the data to the referred memory field of the NPC_t structure.
Mapped address Internal field name Data type Description
0x000 NPC_t::AttLayer string Attached layer name. Can't be accessed through LunaScript.
0x004 NPC_t::Quicksand int32
0x006 NPC_t::RespawnDelay int32
0x008 NPC_t::Bouce bool
0x00a NPC_t::Pinched1 int32
0x00c NPC_t::Pinched2 int32
0x00e NPC_t::Pinched3 int32
0x010 NPC_t::Pinched4 int32
0x012 NPC_t::MovingPinched int32
0x014 NPC_t::NetTimeout int32
0x018 NPC_t::RealSpeedX float32
0x01c NPC_t::Wet int32
0x01e NPC_t::Settings int32
0x020 NPC_t::NoLavaSplash bool
0x022 NPC_t::Slope int32
0x024 NPC_t::Multiplier int32
0x026 NPC_t::TailCD int32
0x028 NPC_t::Shadow bool
0x02c NPC_t::TriggerActivate string On-Activate event to trigger. Can't be accessed through LunaScript.
0x030 NPC_t::TriggerDeath string On-Death event to trigger. Can't be accessed through LunaScript.
0x034 NPC_t::TriggerTalk string On-Talk event to trigger. Can't be accessed through LunaScript.
0x038 NPC_t::TriggerLast string On-Last event to trigger. Can't be accessed through LunaScript.
0x03c NPC_t::Layer string Layer name. Can't be accessed through LunaScript.
0x040 NPC_t::Hidden bool
0x042 NPC_t::Legacy bool
0x044 NPC_t::Chat bool
0x046 NPC_t::Inert bool
0x048 NPC_t::Stuck bool
0x04a NPC_t::DefaultStuck bool
0x04c NPC_t::Text string Talk message text. Can't be accessed through LunaScript.
0x050 NPC_t::oldAddBelt float32
0x054 NPC_t::PinchCount int32
0x056 NPC_t::Pinched bool
0x058 NPC_t::PinchedDirection int32
0x05c NPC_t::BeltSpeed float32
0x060 NPC_t::standingOnPlayer int32
0x062 NPC_t::standingOnPlayerY int32
0x064 NPC_t::Generator bool
0x068 NPC_t::GeneratorTimeMax float32
0x06c NPC_t::GeneratorTime float32
0x070 NPC_t::GeneratorDirection int32
0x072 NPC_t::GeneratorEffect int32
0x074 NPC_t::GeneratorActive bool
0x076 NPC_t::playerTemp bool
0x078 NPC_t::Location Location_t Begin of the Location structure. The absolute position of the NPC. See Location_t reference above. You should add the Location_t address to 0x78 to get the valid address of this sub-structure field.
0x0a8 NPC_t::DefaultLocation Location_t Begin of the Location structure. The initial absolute position of the NPC when it gets (re-)activated. See Location_t reference above. You should add the Location_t address to 0xA8 to get the valid address of this sub-structure field.
0x0d8 NPC_t::DefaultDirection float32
0x0dc NPC_t::DefaultType int32
0x0de NPC_t::DefaultSpecial int32
0x0e0 NPC_t::DefaultSpecial2 int32
0x0e2 NPC_t::Type int32
0x0e4 NPC_t::Frame int32
0x0e8 NPC_t::FrameCount float32
0x0ec NPC_t::Direction float32
0x0f0 NPC_t::Special double
0x0f8 NPC_t::Special2 double
0x100 NPC_t::Special3 double
0x108 NPC_t::Special4 double
0x110 NPC_t::Special5 double
0x118 NPC_t::Special6 double
0x120 NPC_t::TurnAround bool
0x122 NPC_t::Killed int32
0x124 NPC_t::Active bool
0x12a NPC_t::TimeLeft int32
0x12c NPC_t::HoldingPlayer int32
0x12e NPC_t::CantHurt int32
0x130 NPC_t::CantHurtPlayer int32
0x132 NPC_t::BattleOwner int32
0x134 NPC_t::WallDeath int32
0x136 NPC_t::Projectile bool
0x138 NPC_t::Effect int32
0x13c NPC_t::Effect2 double
0x144 NPC_t::Effect3 int32
0x146 NPC_t::Section int32
0x148 NPC_t::Damage float32
0x14c NPC_t::JustActivated int32
0x14e NPC_t::Block int32
0x150 NPC_t::tempBlock int32
0x152 NPC_t::onWall bool
0x154 NPC_t::TurnBackWipe bool
0x156 NPC_t::Immune int32