Advertisement
Kirkq

Dragster Lua v2

Sep 9th, 2017
932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.02 KB | None | 0 0
  1. -- Dragster lua Stepmania-style script by Kirkq
  2.  
  3. ---- Written in haste, so the code looks pretty bad. I got a 5.64 (while cheating, so not legit) with this after a couple hours.
  4.  
  5. -- For learning or for a Stepmania chart, up to you.
  6.  
  7. -- For practice only, times aren't legit if you're using this script live. The script cheats for practice purposes.
  8. -- If you want to record a video file to play along with, that seems fine to me at least, others' opinions may vary.
  9. -- If you want to try the input from a video, I'd recommend turning on the "random frame shifter" 3 lines from the bottom and recording a
  10. -- long video to play in the background.
  11. -- Having this running on any emulator while you're also playing even on a separate emulator is pretty shady in my opinion.
  12. -- If you're gonna post a 5.57, make it legit.
  13.  
  14. -- To my understanding, the game only reads input every other frame at 60 fps, correct me if I'm wrong.
  15. -- This means every button must be held two frames. This is why it seems like inputs drop sometimes.
  16. -- Buttons need held the frame they are on the line, and the frame after.
  17.  
  18. -- The practicing of the start sequence may be more useful via audio cues,
  19. -- but the feedback here with green and red text on the first three shifts is very useful.
  20. -- The first three shifts are almost everything in achieving a 5.57 vs a 5.61.
  21.  
  22. -- The press of the right button keeps you 1/8 frame aligned while the script is running. Reminder: This is for PRACTICE ONLY.
  23. -- I slid most of the wider frame windows one frame from the end to make them wider.
  24. -- The first three shifts are extremely tight, most of the rest is 3-5 frame windows.
  25. -- You can let go of B slightly early on the last hold of left. If you're a frame late you blow your engine.
  26. -- Review Omni's sheet for frame windows.
  27.  
  28. --Button Array
  29. --L D U R B
  30.  
  31. NUM_BUTTONS=5
  32. NUM_ROWS=300
  33. NUM_SHOWN=50
  34.  
  35. START_FRAME=120
  36. SHIFT_OFFSET=0 -- Shift one frame prior to sheet
  37.  
  38. LEFT=1
  39. DOWN=2
  40. UP=3
  41. RIGHT=4
  42. B=5
  43.  
  44. function printMemoryDomains(x,y)
  45. local list = {}
  46. list = memory.getmemorydomainlist()
  47. local curr = memory.getcurrentmemorydomain()
  48. local num = table.getn(list)
  49. local i
  50. gui.text(x,y,"Current: " .. curr)
  51. for i=0,num do
  52. gui.text(x,y + 15*(i+1),list[i])
  53. end
  54. end
  55.  
  56. --Init Array - Create and zero the array
  57. --i is buttons
  58. --j is frame number
  59. --0 is no hit, 1 is hit
  60. array = {}
  61. for i = 1,NUM_BUTTONS do
  62. array[i] = {}
  63. for j = -200,NUM_ROWS+200 do
  64. array[i][j] = 0
  65. end
  66. end
  67.  
  68. array[RIGHT][START_FRAME - 79 + SHIFT_OFFSET]=1
  69.  
  70. --Left is Shift, B is gas
  71.  
  72. -- Shift
  73. array[LEFT][START_FRAME + 0 + SHIFT_OFFSET]=1
  74. array[LEFT][START_FRAME +15 + SHIFT_OFFSET]=1 -- 3 Frame Window
  75. array[LEFT][START_FRAME +33 + SHIFT_OFFSET]=1
  76. array[LEFT][START_FRAME +52 + SHIFT_OFFSET]=1 -- Frame Perfect
  77. array[LEFT][START_FRAME +81 + SHIFT_OFFSET-1]=1 -- 5 frame window
  78. array[LEFT][START_FRAME +92 + SHIFT_OFFSET]=1 -- 2 frame window
  79. array[LEFT][START_FRAME +105 + SHIFT_OFFSET-1]=1 -- 6 frame window
  80. array[LEFT][START_FRAME +114 + SHIFT_OFFSET-1]=1 -- 7 frame window
  81. array[LEFT][START_FRAME +123 + SHIFT_OFFSET-1]=1 -- 6 frame window
  82. array[LEFT][START_FRAME +137 + SHIFT_OFFSET+2]=1 -- 5 frame window
  83. -- The earlier you go in the frame windows, the more distance you lose. So you need to at least be generally towards the end of them.
  84. -- The last clutch 5 frame window doesn't affect distance
  85.  
  86. --137 to 167 it is required, holding shift freezes your speed, so you no longer have to maintain TACH at all
  87. for n = 137+2,167 do
  88. array[LEFT][START_FRAME+ n + SHIFT_OFFSET]=1
  89. end
  90.  
  91. -- Gas
  92. for n = -3,139 do
  93. array[B][START_FRAME + n] = 1
  94. end
  95. array[B][START_FRAME + 16] = 0 --3 Frame Window
  96. array[B][START_FRAME + 34] = 0
  97. --array[B][START_FRAME + 150] = 1
  98. --array[B][START_FRAME + 158] = 1
  99. --array[B][START_FRAME + 166] = 1
  100. --array[B][START_FRAME + 174] = 1
  101. --array[B][START_FRAME + 182] = 1
  102.  
  103. currframe=0
  104. even = 0
  105. odd = 1
  106.  
  107. textfile = "DragsterDump2"
  108. dumpfile = textfile..".txt"
  109. io.output(dumpfile)
  110.  
  111. dumpflag=1
  112. --memory.writebyte(0x01,2,"Main RAM")
  113.  
  114. speed2tachs = 999
  115. speed2frame = 999
  116. speed2timerB = 999
  117. speed3tachs = 999
  118. speed3frame = 999
  119. speed3timerB = 999
  120. speed4tachs = 999
  121. speed4frame = 999
  122. speed4timerB = 999
  123. --savestate.loadslot(1)
  124. memory.writebyte(0x01,0x02,"Main RAM") -- Set frame rule
  125. while true do
  126. --memory.writebyte(0x01,7) --Set optimal start
  127. --memory.writebyte(0x0D,159) --Set optimal start
  128. --printMemoryDomains(400,400)
  129. px=memory.readbyte(0x3A,"Main RAM")
  130. spx=memory.readbyte(0x42,"Main RAM")
  131. speed=memory.readbyte(0x40,"Main RAM")
  132. tach=memory.readbyte(0x28,"Main RAM")
  133. frame=memory.readbyte(0x01,"Main RAM")
  134. timerA=memory.readbyte(0x33,"Main RAM")
  135. timerB=memory.readbyte(0x35,"Main RAM")
  136. countdown=memory.readbyte(0x0D,"Main RAM")
  137. frame = frame % 16
  138. gui.text(400,200,"Currframe:" .. currframe)
  139. gui.text(400,215,"Countdown:" .. countdown)
  140. gui.text(400,230,"Speed:" .. speed)
  141. gui.text(400,245,"Tach:" .. tach)
  142. gui.text(400,260,"Frame:" .. frame)
  143. gui.text(400,275,"TimerA:" .. timerA)
  144. gui.text(400,290,"TimerB:" .. timerB)
  145. gui.text(400,305,px)
  146. gui.text(400,320,spx/256)
  147.  
  148. if countdown == 158 then
  149. currframe=43
  150. memory.writebyte(0x01,0x08,"Main RAM") -- Set frame rule
  151. speed2tachs = 999
  152. speed2frame = 999
  153. speed2timerB = 999
  154. speed3tachs = 999
  155. speed3frame = 999
  156. speed3timerB = 999
  157. speed4tachs = 999
  158. speed4frame = 999
  159. speed4timerB = 999
  160. end
  161.  
  162. if speed == 2 then
  163. speed2tachs=tach --15 or 18
  164. speed2frame=frame --14
  165. speed2timerB=timerB --6
  166. end
  167. if speed == 32 or speed == 33 then
  168. speed3tachs=tach --26 or 24
  169. speed3frame=frame --10
  170. speed3timerB=timerB --96
  171. end
  172. if speed == 70 or speed == 71 then
  173. speed4tachs=tach --26 or 24
  174. speed4frame=frame --2
  175. speed4timerB=timerB --38
  176. end
  177.  
  178. if speed2tachs ~= 999 then
  179. if (speed2tachs == 15 or speed2tachs == 18) then
  180. gui.text(400,160,speed2tachs, "green")
  181. else
  182. gui.text(400,160,speed2tachs, "red")
  183. end
  184. end
  185. if speed2frame ~= 999 then
  186. if speed2frame == 10 then
  187. gui.text(400,175,speed2frame, "green")
  188. else
  189. gui.text(400,175,speed2frame, "red")
  190. end
  191. end
  192. if speed2timerB ~= 999 then
  193. if speed2timerB == 6 then
  194. gui.text(400,190,speed2timerB, "green")
  195. else
  196. gui.text(400,190,speed2timerB, "red")
  197. end
  198. end
  199.  
  200. if speed3tachs ~= 999 then
  201. if (speed3tachs == 26 or speed3tachs == 24 or speed3tachs == 23) then
  202. gui.text(440,160,speed3tachs, "green")
  203. else
  204. gui.text(440,160,speed3tachs, "red")
  205. end
  206. end
  207.  
  208. if speed3frame ~= 999 then
  209. if speed3frame == 10 then
  210. gui.text(440,175,speed3frame, "green")
  211. else
  212. gui.text(440,175,speed3frame, "red")
  213. end
  214. end
  215. if speed3timerB ~= 999 then
  216. if speed3timerB == 96 then
  217. gui.text(440,190,speed3timerB, "green")
  218. else
  219. gui.text(440,190,speed3timerB, "red")
  220. end
  221. end
  222.  
  223. if speed4tachs ~= 999 then
  224. if (speed4tachs == 26 or speed4tachs == 24) then
  225. gui.text(480,160,speed4tachs, "green")
  226. else
  227. gui.text(480,160,speed4tachs, "red")
  228. end
  229. end
  230.  
  231. if speed4frame ~= 999 then
  232. if speed4frame == 2 then
  233. gui.text(480,175,speed4frame, "green")
  234. else
  235. gui.text(480,175,speed4frame, "red")
  236. end
  237. end
  238. if speed4timerB ~= 999 then
  239. if speed4timerB == 38 then
  240. gui.text(480,190,speed4timerB, "green")
  241. else
  242. gui.text(480,190,speed4timerB, "red")
  243. end
  244. end
  245.  
  246. --if dumpflag == 1 then
  247. -- if speed > 0 then
  248. -- io.write(speed .. " " .. tach .. " " .. frame)
  249. -- io.write("\n")
  250. -- end
  251. -- end
  252.  
  253. --gui.text(30,45,"Currframe: " .. currframe)
  254. basex=20
  255. basey=100
  256. flag = 0
  257. for n=-10,NUM_SHOWN do
  258. if n==0 then
  259. --gui.text(basex+0,basey, "-------------------------------")
  260. gui.text(basex,basey-8, "========================")
  261. end
  262. for m=1,NUM_BUTTONS do
  263. if array[m][currframe+n] == 1 then
  264. if m == LEFT then
  265. if array[m][currframe+n-1] == 1 then
  266. disp = "|"
  267. else
  268. disp = "L"
  269. if n==0 then
  270. flag = 1
  271. end
  272. end
  273. elseif m == B then
  274. if array[m][currframe+n-1] == 1 then
  275. disp = "|"
  276. else
  277. disp = "B"
  278. if n==0 then
  279. flag = 1
  280. end
  281. end
  282. elseif m == RIGHT then
  283. disp = "R"
  284. if n==0 then
  285. flag = 1
  286. end
  287. end
  288. if even == 1 then
  289. offset2 = 0
  290. else
  291. offset2 = 8
  292. end
  293. --if n==0 then
  294. -- if flag == 1 and even == 1 then
  295. -- gui.text(basex+0,basey, "-------------------------------", "green")
  296. -- end
  297. --end
  298. if disp ~= "|" then
  299. gui.text(basex+m*20,basey+n*16+offset2,disp)
  300. end
  301. end
  302. end
  303. end
  304. if flag == 1 then
  305. --for q=1,60 do
  306. -- gui.text(270,20+q*16,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
  307. --end
  308. if even == 1 then
  309. even = 1
  310. --os.execute("echo \7") -- Make windows beep, but steal control of window.
  311. end
  312. end
  313. emu.frameadvance()
  314. -- 60 fps vs 30 fps
  315. if even == 1 then
  316. currframe=currframe+1
  317. even = 0
  318. odd = 1
  319. elseif odd == 1 then
  320. even = 1
  321. odd = 0
  322. end
  323. if currframe > NUM_ROWS then
  324. dumpflag=0
  325. --io.output():close()
  326. currframe=13
  327. speed2tachs = 999
  328. speed2frame = 999
  329. speed2timerB = 999
  330. speed3tachs = 999
  331. speed3frame = 999
  332. speed3timerB = 999
  333. speed4tachs = 999
  334. speed4frame = 999
  335. speed4timerB = 999
  336. --currframe = math.random(0, 7) -- Slide frame number
  337. end
  338. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement