Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- states:
- 1: start
- 100: fastest
- 101: main superswim states
- 102: down 1 frame
- ]]
- fastestFrame = 10000000000
- fastestSpeed = 0
- function checkAir()
- checkFinished()
- print(tonumber(memory.readfloat(0xac0444))) --speed address, changes every map
- if memory.readword(0x3bdc62) == 0 then --air address, shouldn't ever change
- return false
- end
- if tonumber(memory.readfloat(0xac0444)) > -50 then --speed address, changes every map
- return false
- end
- return true
- end
- function keepSwimming()
- while checkAir() do
- joypad.joystick(128,128) -- neutral stick
- emu.frameadvance()
- end
- end
- function getToSpeed(x)
- while tonumber(memory.readfloat(0xac0444)) > -x do --speed address, changes every map
- if math.mod(emu.framecount(), 2) ~= 0 then --if odd frame, stick down right
- joypad.joystick(0,186) --right
- emu.frameadvance()
- else --if even frame, stick down left
- joypad.joystick(255,186) --left
- emu.frameadvance()
- end
- end
- end
- function getToFrame(x)
- while emu.framecount() < x do
- if math.mod(emu.framecount(), 2) ~= 0 then --if odd frame, stick down right
- joypad.joystick(0,186) --right
- emu.frameadvance()
- else --if even frame, stick down left
- joypad.joystick(255,186) --left
- emu.frameadvance()
- end
- end
- end
- function checkFinished()
- if tonumber(memory.readfloat(0xac0444)) > -1 then --speed address, changes every map
- if emu.framecount() < fastestFrame then
- savestate.save(100)
- fastestFrame = emu.framecount()
- end
- end
- end
- running = true
- while running do
- if emu.framecount() == 900 then --load state late so it won't mess up audio or crash
- savestate.load(1)
- startFrame = emu.framecount() --get start frame for comparisons
- end
- if emu.framecount() > 1000 then getToSpeed(1450) end --use getToFrame or getToSpeed so you don't waste an hour of failing a ton of superswims
- while (emu.framecount() > 1000) and running do --start after loading the first state
- if emu.framecount() > fastestFrame then running = false end
- if math.mod(emu.framecount(), 2) ~= 0 then --if odd frame, stick down right
- joypad.joystick(0,186) --right
- emu.frameadvance()
- savestate.save(101)
- joypad.joystick(228,0) --first turn around, not straight to where you wannna go, based on previous input
- else --if even frame, stick down left
- joypad.joystick(255,186) --left
- emu.frameadvance()
- savestate.save(101)
- joypad.joystick(10,0) --first turn around, not straight to where you wannna go, based on previous input
- end
- emu.frameadvance()
- joypad.joystick(128,255) --opposite of direction you want to go
- emu.frameadvance()
- savestate.save(102)
- keepSwimming() --first frame leaving
- savestate.load(102)
- joypad.joystick(128,255) --opposite of direction you want to go
- emu.frameadvance()
- emu.frameadvance()
- -- savestate.save(103)
- keepSwimming() --second frame leaving
- savestate.load(101) --restart loop
- end
- emu.frameadvance()
- if running == false then emu.message("OH MAN, WE IN THERE!") end --most important line in the code, do not remove.
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement