Post subject: Having trouble using Memory addresses with Lua.
Joined: 8/29/2015
Posts: 2
Hello, Recently I've gotten into ROM hacking because I eventually want to make a script for AI in Super Smash Bros 64 using Lua. I'm using MHS--L Spiro as my memory hacking software. With it I found some useful addresses I wanted to test in a Lua script. But when I try using them with Lua commands such as readByte (which I thought would just return the value within that address) I get errors. Do I have to convert the addresses I'm finding before they can be used in Lua? Keep in mind I'm a complete newbie and know next to nothing regarding any of this. So any help at all would be appreciated.
Editor, Expert player (2310)
Joined: 5/15/2007
Posts: 3854
Location: Germany
Noxxa
They/Them
Expert player, Moderator (4131)
Joined: 8/14/2009
Posts: 4083
Location: The Netherlands
I'm assuming you're using BizHawk, as I don't know of other N64 emulators with lua support. MHS does not return the internal RAM address inside the emulated N64; instead, it's the RAM address inside the whole BizHawk process. As such, the RAM addresses you found are native/relative to the client, not the emulated game, and the lua functions, expecting internal RAM addresses, won't recognise it. Use Tools->RAM Search to find memory addresses within the game proper. Then use those memory addresses within the lua functions.
http://www.youtube.com/Noxxa <dwangoAC> This is a TAS (...). Not suitable for all audiences. May cause undesirable side-effects. May contain emulator abuse. Emulator may be abusive. This product contains glitches known to the state of California to cause egg defects. <Masterjun> I'm just a guy arranging bits in a sequence which could potentially amuse other people looking at these bits <adelikat> In Oregon Trail, I sacrificed my own family to save time. In Star trek, I killed helpless comrades in escape pods to save time. Here, I kill my allies to save time. I think I need help.
Player (74)
Joined: 8/26/2015
Posts: 70
If I'm correct, MHS--L Spiro is a generic memory-hacking piece of software for any program, so the addresses you get are relative to the start of your emulator (BizHawk?)'s address space. However, the memory addresses in lua scripts are relative to the start of the game's memory as stored by the emulator. You'll need to use the built-in tools (Tools > RAM Search) to find the correct addresses relative to the game's memory. Edit: ninja'd by Mothrayas... *shrugs*
Joined: 8/29/2015
Posts: 2
Yes I'm using Bizhawk. Ah I see. So I should have been using the built in tools the entire time. Not an external program for memory hacking. I'll try that. Thanks for all your help guys.