Advertisement
Arnethegreat

Like this yo

Mar 5th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dofile("tablehandling.lua")
  2.  
  3. oldrecord = {}
  4. newrecord = {}
  5.  
  6. function nothingpressed()
  7.    local k = joypad.get(1)
  8.    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)
  9. end
  10.  
  11. mode = "recording"
  12.  
  13. --ENTER BIG OFFSETS MANUALLY HERE--
  14. offset = 0
  15. --ENTER BIG OFFSETS MANUALLY HERE--
  16.  
  17. while(true) do
  18.    emu.frameadvance()
  19.    keys = input.get()
  20.    if keys["R"] == true then
  21.       mode = "replay"
  22.    end
  23.    if keys["F11"] then
  24.       table.save(oldrecord,"recorded.txt")
  25.       gui.text(0,100,"current record saved to recorded.txt")
  26.    end
  27.    if keys["F12"] then
  28.       oldrecord = table.load("recorded.txt")
  29.       gui.text(0,105,"loaded record from recorded.txt")
  30.    end
  31.    --note: you will see the offset change one
  32.    --frame later than you expect.
  33.    if keys["NumberPadPlus"] then
  34.       offset = offset + 1
  35.    end
  36.    if keys["NumberPadMinus"] then
  37.       offset = offset - 1
  38.    end
  39.    if keys["NumberPad0"] then
  40.       offset = 0
  41.    end
  42.    -- "recording" mode records controller data (for first controller)
  43.    if mode == "recording" then
  44.       gui.text(180,10,"offset: " .. tostring(offset))
  45.       gui.text(180,0,"recording, press R to switch")
  46.       cf = emu.framecount()
  47.      
  48.          if oldrecord[cf] == nil then                                                       -- Check bounds
  49.             oldrecord[cf] = {}                                                              --
  50.          end
  51.        oldrecord[cf] = joypad.get(1)                                                        -- Log input to the table every frame
  52.    end
  53.    -- "replay" mode does the following:
  54.    -- _if the emulator is in "rerecording" mode, it will input
  55.    --   the previously recorded keys
  56.    -- _you can specify an offset for that by pressing
  57.    --   numpad+, numpad-, or numpad0_
  58.    --   or you can override it by entering some new input.
  59.    -- _if you want no input in the next frame,
  60.    --   use numpad*
  61.    if mode == "replay" then
  62.       gui.text(180,0,"replay mode (old minus new)")
  63.       cf = emu.framecount()                                                                 -- Pause the game
  64.       newrecord[cf] = {}                                                                    -- Useless
  65.       gui.text(180,10,"offset: " .. tostring(offset))                                       -- Display offset
  66.       keys = input.get()       
  67.       oldrecord[cf] = joypad.get(1)                                                         -- Load table of keyboard keys pressed
  68.       if oldrecord[cf+offset] ~= nil then                                                   -- If current input is within the bounds of the movie
  69.          --if not nothingpressed() and keys["NumberPadStar"] then                           -- If something on the controller is pressed and * is pressed...
  70.          if nothingpressed() and not keys["NumberPadStar"] then                             -- If nothing is pressed
  71.             --joypad.set(oldrecord[cf+offset],1)                                           
  72.             gui.text(0, 0, "RECORDED input used from frame " .. tostring(cf+offset))        -- Do nothing new
  73.          elseif not nothingpressed() and not keys["NumberPadStar"] then                 -- If something is pressed, but not *
  74.             joypad.set(oldrecord[cf+offset],1)         
  75.             gui.text(0, 0, "MANUAL input used")
  76.          elseif keys["NumberPadStar"] then
  77.             joypad.set(oldrecord[cf+offset],1)         
  78.             gui.text(0, 0, "MANUAL input used")
  79.          else
  80.             gui.text(0, 0, "Stop that")
  81.          end
  82.       else
  83.          gui.text(0,0,"no controller data available")
  84.       end
  85.    end
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement