Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dofile("tablehandling.lua")
- oldrecord = {}
- newrecord = {}
- function nothingpressed()
- local k = joypad.get(1)
- 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)
- end
- mode = "recording"
- --ENTER BIG OFFSETS MANUALLY HERE--
- offset = 0
- --ENTER BIG OFFSETS MANUALLY HERE--
- while(true) do
- emu.frameadvance()
- keys = input.get()
- if keys["R"] == true then
- mode = "replay"
- end
- if keys["F11"] then
- table.save(oldrecord,"recorded.txt")
- gui.text(0,100,"current record saved to recorded.txt")
- end
- if keys["F12"] then
- oldrecord = table.load("recorded.txt")
- gui.text(0,105,"loaded record from recorded.txt")
- end
- --note: you will see the offset change one
- --frame later than you expect.
- if keys["NumberPadPlus"] then
- offset = offset + 1
- end
- if keys["NumberPadMinus"] then
- offset = offset - 1
- end
- if keys["NumberPad0"] then
- offset = 0
- end
- -- "recording" mode records controller data (for first controller)
- if mode == "recording" then
- gui.text(180,10,"offset: " .. tostring(offset))
- gui.text(180,0,"recording, press R to switch")
- cf = emu.framecount()
- if oldrecord[cf] == nil then -- Check bounds
- oldrecord[cf] = {} --
- end
- oldrecord[cf] = joypad.get(1) -- Log input to the table every frame
- end
- -- "replay" mode does the following:
- -- _if the emulator is in "rerecording" mode, it will input
- -- the previously recorded keys
- -- _you can specify an offset for that by pressing
- -- numpad+, numpad-, or numpad0_
- -- or you can override it by entering some new input.
- -- _if you want no input in the next frame,
- -- use numpad*
- if mode == "replay" then
- gui.text(180,0,"replay mode (old minus new)")
- cf = emu.framecount() -- Pause the game
- newrecord[cf] = {} -- Useless
- gui.text(180,10,"offset: " .. tostring(offset)) -- Display offset
- keys = input.get()
- oldrecord[cf] = joypad.get(1) -- Load table of keyboard keys pressed
- if oldrecord[cf+offset] ~= nil then -- If current input is within the bounds of the movie
- --if not nothingpressed() and keys["NumberPadStar"] then -- If something on the controller is pressed and * is pressed...
- if nothingpressed() and not keys["NumberPadStar"] then -- If nothing is pressed
- --joypad.set(oldrecord[cf+offset],1)
- gui.text(0, 0, "RECORDED input used from frame " .. tostring(cf+offset)) -- Do nothing new
- else if not nothingpressed() and not keys["NumberPadStar"] then -- If something is pressed, but not *
- joypad.set(oldrecord[cf+offset],1)
- gui.text(0, 0, "MANUAL input used")
- else if keys["NumberPadStar"] then
- joypad.set(oldrecord[cf+offset],1)
- gui.text(0, 0, "MANUAL input used")
- else
- gui.text(0, 0, "Stop that")
- end
- else
- gui.text(0,0,"no controller data available")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement