1

When I run my code I get an error on this line:

personality = memory.readdwordunsigned(0x02024744)

This is the error message I am given by the console:

LuaInterface.LuaScriptException: [string "main"]:26: attempt to call field 'readdwordunsigned' (a nil value)

I have been doing some testing and researching around this for a while and I cannot get it to work despite this concept being used on several other projects such as this: https://projectpokemon.org/forums/showthread.php?16681-Gen-3-Lua-Scripts

Some other information:
1. I am running the lua script on the BizHawk emulator.
2. if I change the line to memory.readbyte() I receive a different message, which leads me to believe that the console does not recognise memory.readdwordunsigned() as a funciton.
3. The script is in the same folder as the executable file for the emulator.

Thank you in advance for any help

  • Just read through http://tasvideos.org/Bizhawk/LuaFunctions.html quickly. No such function exists. Maybe it was made for an old version of the emulator. Looks like you should replace it with a call to one of the `memory.read_?` operations. I don't know enough about the platform to tell you the size or endianness of a dword. – ktb Aug 13 '16 at 21:19
  • Ah, I was worried that this would be the case. I'll try the functions on this page an do some more research in hopes of finding the answer. If I can't I might just download an old version of the emulator. Thank you for your help! – Johnny Mitchell Aug 14 '16 at 15:02

1 Answers1

1

Turns out that support for memory.readdwordunsigned() is no longer supported in the BizHawk Emulator. After extensive research and help from a comment posted on my question I have managed to find a working alternative: memory.usememorydomain("System Bus") personality=memory.read_u32_le(0x02024744)

For anyone else who finds this answer useful, please note that a dword is unsigned and 4 bytes in size, hence the use of u32, because a dword is 32bits and unsigned. If you wanted to use a signed byte, for example, you would use s8 instead. le means little endien, be can be used instead for big endien.

It is important to state the memory domain before attempting to read from memory because the memory domain I was using (IWRAM) as well as all other memory domains except for the system bus would produce this error due to the size of the memory address.

  • you could also simply use, memory.read_u32_le(0x02024744, "System Bus") which allows you to easily change between domains. – Xitcod13 Nov 25 '18 at 16:01