Posts for ctgraham

Joined: 3/26/2014
Posts: 2
Ah, that makes sense. I hadn't tried using nil instead of "False", that should work for me. Thanks!
Post subject: Lua Script: How to reset joypad to normal
Joined: 3/26/2014
Posts: 2
I'm writing a lua script that sends joypad input during parts of the game and returns control back to me during other parts of the game. I can't figure out how to do this though based on the joypad documentation. Here is an example script:
function testing(allow)
    local keytable = joypad.get()

    if allow then
        for key, _ in pairs(keytable) do
            keytable[key] = nil
        end
    else
        keytable["P1 Left"] = "False"
        keytable["P1 Right"] = "True"
    end
    
    joypad.set(keytable)
end

framecount = 0
while true do
    if framecount > 100 then
        testing(true)
    else
        testing(false)
        framecount = framecount + 1
    end
	emu.frameadvance()
end
What I expect this script to do: Hold right on the joypad for 100 frames, then allow manual control on every frame after that. What it actually does: Holds right for 100 frames, then only allows manually moving right on every frame after that. Also, even if I stop the script, I still don't have full control back, I have to restart BizHawk completely. What am I doing wrong here?