Advertisement
SethBling

StairClip.lua

Jan 2nd, 2015
1,041
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. --mode = "SuccessesOnly"
  2. --mode = "LeftDelayRight"
  3. --mode = "RightJump"
  4. mode = "DuckRun"
  5.  
  6. console.writeline("Starting StairClip")
  7.  
  8. noInput = 0;
  9. startDuck = 0
  10. holdDuck = 0
  11. startJump = 0
  12. runLeft = 0
  13. noInput = 0
  14.  
  15. if mode == "SuccessesOnly" then
  16. end
  17.  
  18. if mode == "LeftDelayRight" then
  19. LeftMin = 10;
  20. LeftMax = 30;
  21. DelayMin = 0;
  22. DelayMax = 10;
  23.  
  24. runLeft = LeftMin - 1;
  25. noInput = DelayMin;
  26. end
  27.  
  28. if mode == "RightJump" then
  29. StartJumpMin = 50
  30. StartJumpMax = 80
  31. startJump = StartJumpMin-1
  32. end
  33.  
  34. if mode == "DuckRun" then
  35. --[[
  36. StartDuckMin = 0
  37. StartDuckMax = 30
  38. HoldDuckMin = 1
  39. HoldDuckMax = 10
  40. ]]
  41. StartDuckMin = 0
  42. StartDuckMax = 1
  43. HoldDuckMin = 1
  44. HoldDuckMax = 50
  45.  
  46. startDuck = StartDuckMin-1
  47. holdDuck = HoldDuckMin
  48. end
  49.  
  50.  
  51. --[[
  52. LeftMin=10
  53. LeftMax=11
  54. JumpMin=20
  55. JumpMax=70
  56. ]]--
  57.  
  58. idx = 0;
  59.  
  60. successes = {
  61. {10, 5},
  62. {24, 7},
  63. {13, 5},
  64. {11, 6},
  65. {18, 6},
  66. {18, 5},
  67. {22, 2},
  68. {23, 7},
  69. {28, 5},
  70. {27, 3},
  71. {10, 6},
  72. {28, 3},
  73. {11, 3},
  74. {15, 3},
  75. {24, 0},
  76. {25, 0},
  77. {17, 3},
  78. {16, 4},
  79. {21, 4},
  80. {20, 5},
  81. {19, 0},
  82. }
  83.  
  84.  
  85.  
  86. function onFrame()
  87. frame = frame + 1;
  88.  
  89. buttons = joypad.get();
  90.  
  91. buttons["P1 Left"] = false
  92. buttons["P1 Right"] = false
  93. buttons["P1 Down"] = false
  94. buttons["P1 A"] = false
  95. buttons["P1 Y"] = true
  96.  
  97. vx = memory.read_s8(0x7B);
  98. vy = memory.read_s8(0x7D);
  99. x = memory.read_u16_le(0x94);
  100. y = memory.read_u16_le(0x96);
  101. xsub = memory.readbyte(0x13DA)/16;
  102. ysub = memory.readbyte(0x13DC)/16;
  103.  
  104. if frame == runLeft+noInput+1 then
  105. startV = vx;
  106. startXSub = xsub
  107. startFrame = frame
  108. end
  109.  
  110. if frame >= startJump then
  111. buttons["P1 A"] = true
  112. gui.drawText(10, 34, "A");
  113. end
  114.  
  115. if frame >= startDuck and frame < startDuck+holdDuck then
  116. buttons["P1 Down"] = true
  117. gui.drawText(10, 16, "Down")
  118. end
  119.  
  120. if frame <= runLeft then
  121. buttons["P1 Left"] = true;
  122. gui.drawText(10, 50, "Left");
  123. elseif frame > runLeft + noInput then
  124. buttons["P1 Right"] = true;
  125. gui.drawText(10, 50, "Right");
  126. end
  127.  
  128. gui.drawText(10, 66, "Left " .. runLeft)
  129. gui.drawText(10, 82, "Delay " .. noInput)
  130. gui.drawText(10, 98, "Jump " .. startJump)
  131. gui.drawText(10, 114, "Duck " .. startDuck)
  132. gui.drawText(10, 130, "HoldDuck " .. holdDuck)
  133.  
  134.  
  135. if vy == -20 and y > 230 and not displayed then
  136. console.writeline("Left " .. runLeft .. " Delay " .. noInput .. " Jump " .. startJump .. " Duck " .. startDuck .. " HoldDuck " .. holdDuck .. " clips at (" .. x .. "," .. y .. ") frame " .. frame);
  137. displayed = true;
  138. end
  139.  
  140. if frame > 170 then
  141. initializeAttempt();
  142. end
  143.  
  144. joypad.set(buttons);
  145.  
  146. end
  147.  
  148. function initializeAttempt()
  149. savestate.load("EnterDSH.State");
  150. frame = 0;
  151.  
  152. if mode == "SuccessesOnly" then
  153. idx = idx + 1
  154. attempt = successes[idx];
  155. if attempt ~= nil then
  156. runLeft = attempt[1];
  157. noInput = attempt[2];
  158. else
  159. client.pause();
  160. end
  161. end
  162.  
  163. if mode == "LeftDelayRight" then
  164. runLeft = runLeft+1;
  165.  
  166. if runLeft == LeftMax then
  167. runLeft = LeftMin
  168. noInput = noInput+1
  169. if noInput == DelayMax then
  170. client.pause();
  171. end
  172. end
  173. end
  174.  
  175. if mode == "RightJump" then
  176. startJump = startJump + 1
  177. if startJump == StartJumpMax then
  178. client.pause();
  179. end
  180. end
  181.  
  182. if mode == "DuckRun" then
  183. startDuck = startDuck+1
  184. if startDuck == StartDuckMax then
  185. startDuck = StartDuckMin
  186. holdDuck = holdDuck + 1
  187. if holdDuck == HoldDuckMax then
  188. client.pause()
  189. end
  190. end
  191. end
  192.  
  193. displayed = false;
  194. end
  195.  
  196. initializeAttempt();
  197.  
  198. while true do
  199. onFrame();
  200. emu.frameadvance();
  201. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement