Posts for oddyman


oddyman
He/Him
Joined: 3/28/2017
Posts: 2
Ah... Now I understand... thanks. It seems my hunch about the non-constant facing left was wrong, but at least now I can experiment a bit more.
Pokota wrote:
Also, what purpose does the timer serve? You don't appear to compare anything to it or evaluate using it or anything. You just count backwards from 60 by one each frame the script is running...?
Oops, I forgot to remove that part when posting the code, it was originally for clearing the console window and display new information every 60th frame. But I decided to remove that part to shorten the code.
Post subject: emu.registerbefore()
oddyman
He/Him
Joined: 3/28/2017
Posts: 2
Okay! So after some checking, I've figured out this must be the place to post my first post on this forum. I couldn't find the answer anywhere so here goes. I'm running the BizHawk version 1.12.0 and emulating Sonic The Hedgehog for Genesis. At the moment my goal is to always force Sonic to face left, despite the input of left and right. There is but one hinch in my plan as of yet that bugs me, the fact that he is not consistently facing left. After some thinking and digging I've concluded that it's because it's updating after I've written to memory. But before the frame is emulated, I therefore tried using emu.registerbefore() to fix this... So first of all I should probably ask: will it actually fix it? If so, I'll have to ask what is wrong, because I cannot for the life of me get it to work. I'm starting to think that the emulator does not support it? This is the error message I get: LuaInterface.LuaScriptException: [string "main"]:5: attempt to call field 'registerbefore' (a nil value) It does not happen if I put it after the while true loop (but then again I suppose it never runs then) Here is the code (feel free to ignore the updateSonicFacing() in the while loop, but it's there to represent my earlier attempt)
Language: lua

local function updateSonicFacing() memory.writebyte(0xFFD022, bit.bor(memory.readbyte(0xFFD022), 0x01)) end emu.registerbefore(updateSonicFacing) --Here it begins memory.writebyte(0xFFFE1C, 0x1) -- Allows lives to be set local timer = 60 while true do -- Forces 4 lives if memory.readbyte(0xFFFE12) < 0x4 then memory.writebyte(0xFFFE12, 0x4) end updateSonicFacing() timer = timer - 1 emu.frameadvance() end