Advertisement
Arnethegreat

Seems to work?!

Nov 29th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.38 KB | None | 0 0
  1. -- BizHawk Hexing thingy?
  2.  
  3. dofile("tablehandling.lua")
  4.  
  5. oldrecord = {}
  6. newrecord = {}
  7.  
  8. function nothingpressed()
  9.    local k = joypad.get(1)
  10.    return not(k.left or k.right or k.up or k.down or k.A or k.B or k.X or k.Y or k.L or k.R or k.start or k.select)
  11. end
  12.  
  13. mode = "recording"
  14.  
  15. --ENTER BIG OFFSETS MANUALLY HERE--
  16. offset = 0
  17. --ENTER BIG OFFSETS MANUALLY HERE--
  18.  
  19. while(true) do
  20.    emu.frameadvance()
  21.    keys = input.get()
  22.    if keys["R"] == true then
  23.       mode = "replay"
  24.    end
  25.    if keys["F11"] then
  26.       table.save(oldrecord,"recorded.txt")
  27.       gui.text(0,100,"current record saved to recorded.txt")
  28.    end
  29.    if keys["F12"] then
  30.       oldrecord = table.load("recorded.txt")
  31.       gui.text(0,105,"loaded record from recorded.txt")
  32.    end
  33.    --note: you will see the offset change one
  34.    --frame later than you expect.
  35.    if keys["numpad+"] then
  36.       offset = offset + 1
  37.    end
  38.    if keys["numpad-"] then
  39.       offset = offset - 1
  40.    end
  41.    if keys["numpad0"] then
  42.       offset = 0
  43.    end
  44.    -- "recording" mode records controller data (for first controller)
  45.    if mode == "recording" then
  46.       gui.text(180,20,"offset: " .. tostring(offset))
  47.       gui.text(180,0,"recording, press R to switch")
  48.       cf = emu.framecount()
  49.      
  50.          if oldrecord[cf] == nil then
  51.             oldrecord[cf] = {}
  52.          end
  53.        oldrecord[cf] = joypad.get(1)
  54.    end
  55.    -- "replay" mode does the following:
  56.    -- _if the emulator is in "rerecording" mode, it will input
  57.    --   the previously recorded keys
  58.    -- _you can specify an offset for that by pressing
  59.    --   numpad+, numpad-, or numpad0_
  60.    --   or you can override it by entering some new input.
  61.    -- _if you want no input in the next frame,
  62.    --   use numpad*
  63.    if mode == "replay" then
  64.       gui.text(180,0,"replay mode (old minus new)")
  65.       cf = emu.framecount()
  66.       newrecord[cf] = {}
  67.       gui.text(180,20,"offset: " .. tostring(offset))
  68.       keys = input.get()
  69.       if oldrecord[cf+offset] ~= nil and oldrecord[cf+offset] ~= nil then
  70.          if nothingpressed() and not keys["numpad*"] then
  71.             joypad.set(oldrecord[cf+offset], 1)
  72.             gui.text(0, 0, "RECORDED input used from frame " .. tostring(cf+offset))
  73.          else
  74.             gui.text(0, 0, "MANUAL input used")
  75.          end
  76.       else
  77.          gui.text(0,0,"no controller data available")
  78.       end
  79.    end
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement