Post subject: How do I use lua memory.register()
Editor, Emulator Coder, Site Developer
Joined: 5/11/2011
Posts: 1108
Location: Murka
Because I apparently can't figure it out. I run this script, and player HP immediately changes to 68... but it doesn't stay there. I'm pretty sure I have the right memory address; and I see the values at that address changing in memory watch, but my callback never gets called.
Language: lua

-- this sucessfully changes player HP once memory.writeshort (0x00097ba0, 68) -- this does not sucessfully freeze player HP memory.register (0x00097ba0, function () memory.writeshort (0x00097ba0, 68) end)
Editor, Skilled player (1941)
Joined: 6/15/2005
Posts: 3247
Works for me in pcsx-rr v0.1.3a. Which version are you using? Edit: Note that some addresses act as mirrors of others, and that changing them may have no effect on gameplay.
Joined: 2/15/2009
Posts: 329
FractalFusion wrote:
Works for me in pcsx-rr v0.1.3a. Which version are you using?
PSXjin 2.0.2
Working on: Legend of Legaia, Vagrant Story
Editor, Emulator Coder, Site Developer
Joined: 5/11/2011
Posts: 1108
Location: Murka
FractalFusion wrote:
Edit: Note that some addresses act as mirrors of others, and that changing them may have no effect on gameplay.
It should stay the same in memory watch though, right? Whether or not that has any effect on gameplay?
Lil_Gecko
He/Him
Player (94)
Joined: 4/7/2011
Posts: 520
I have never used memory.register and I know this doesn't answer your question but why not simply use while true do memory.writeshort (0x00097ba0, 68); emu.frameadvance(); end; ?
Editor, Emulator Coder, Site Developer
Joined: 5/11/2011
Posts: 1108
Location: Murka
Lil_Gecko wrote:
I have never used memory.register and I know this doesn't answer your question but why not simply use while true do memory.writeshort (0x00097ba0, 68); emu.frameadvance(); end; ?
That sets the value once per frame to what I want. If that value gets changed and then read out at a different point during the frame, then it can still be wrong. What you posted is enough for many purposes though.
Editor, Emulator Coder, Site Developer
Joined: 5/11/2011
Posts: 1108
Location: Murka
Solved (thanks to Ilari) Because psxjin is junkus, your lua script ceases to exist once the interpreter hits the end of the file. This is in contrast to emulators like VBA, where the script stays running until you stop it, and so can still do stuff if it has hooks registered. This fully freezes the value in question:
Language: lua

memory.writeshort (0x00097ba0, 68) print ("initial set") memory.registerwrite (0x00097ba0, function () print ("hook hit") memory.writeshort (0x00097ba0, 68) end) print ("hook installed") while true do emu.frameadvance() end
Joined: 1/26/2009
Posts: 558
Location: Canada - Québec
FractalFusion wrote:
Works for me in pcsx-rr v0.1.3a. Which version are you using? Edit: Note that some addresses act as mirrors of others, and that changing them may have no effect on gameplay.
I'll just like to point out that there used to be a pcsx-rr v0.1.3c version(I think gotcha provided this build on google code), it used to have a lua console, just like psxjin... why the build isn't avalaible now?