Advertisement
Kirkq

Lawn Mower Lua

Nov 18th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.69 KB | None | 0 0
  1. --Copy into file and save as LawnMowerScript.lua
  2. --Please disregard the fact that this is coded like trash.
  3. --Source code also exists for the game.  Rainbowism was messing around with it quite a bit.  I have it somewhere.
  4.  
  5. local Base1= 0x0000
  6. local Base2 = 0x0001 --Per pixel in bar
  7. local CurrFuelAd2 = 0x00CB  --Continuous
  8. local GrassesLeftAd = 0x00CC  --Continuous
  9.  
  10. local XAd = 0x00EA  --Also 0x00D8
  11. local XSubAd = 0x00E9
  12. local YAd = 0x00E8  --Also 0x00D2, 0x00D7
  13. local YSubAd = 0x00E7
  14.  
  15. local VelocityAd = 0x00D4
  16. local DoubleSubPxAd = 0x00D9
  17.  
  18. local Percentage = 0x00B2
  19. local Percentage2 = 0x00D1
  20. local NextFuelYAd = 0x00B7
  21. local NextFuelXAd = 0x00B8
  22. local FuelCounterAd = 0x00BC
  23.  
  24. local WHERETOGETAD = 0x00B5  -- Locking all two of these locks the fuel spawn, it sometimes goes invis as a side effect.
  25. local WHERETOGETAD2 = 0x00B6
  26.  
  27. local WHERETOGETAD3 = 0x00E3
  28.  
  29. local CurrFuelYAd = 0x00C0
  30. local CurrFuelXAd = 0x00C1
  31.  
  32. local GAME_CAM_X = 0x00D5
  33.  
  34. local CuttingGrassAnimAd = 0x00FD
  35. local Counter1 = 0x00FE  -- This causes you to stop every 5th frame.
  36. local Counter2 = 0x00FF  -- This is related to draining fuel. Locking it locks fuel.
  37.  
  38. local RandSeedAd = 0x00FD
  39.  
  40. local FuelHackThing = 0x00BE  --Invisible Fuel Hack?  Bad
  41.  
  42. local Grass1Ad = 0x40A  --These are grass sprites, i think there are two types
  43. local Grass2Ad = 0x40B
  44. local Grass3Ad = 0x40C
  45. local Grass4Ad = 0x40D
  46.  
  47. local GAME_MAP_WDT = 0x00C9
  48.  
  49. local XX
  50. local YY
  51.  
  52. local x = {}
  53. local y = {}
  54.  
  55. local i
  56.  
  57. x[1]=8
  58. y[1]=8
  59. x[2]=9
  60. y[2]=7
  61. x[3]=6
  62. y[3]=9
  63. x[4]=6
  64. y[4]=8
  65. x[5]=9
  66. y[5]=3
  67. x[6]=13
  68. y[6]=3
  69. x[7]=3
  70. y[7]=3
  71. x[8]=7
  72. y[8]=6
  73. x[9]=1
  74. y[9]=4
  75. x[10]=1
  76. y[10]=7
  77. x[11]=9
  78. y[11]=4
  79. x[12]=1
  80. y[12]=11
  81. x[13]=14
  82. y[13]=8
  83. x[14]=11
  84. y[14]=7
  85. x[15]=7
  86. y[15]=4
  87. x[16]=10
  88. y[16]=5
  89. x[17]=3
  90. y[17]=7
  91. x[18]=5
  92. y[18]=11
  93. x[19]=3
  94. y[19]=4
  95. x[20]=1
  96. y[20]=10
  97. x[21]=1
  98. y[21]=3
  99. x[22]=10
  100. y[22]=6
  101. x[23]=4
  102. y[23]=4
  103. x[24]=4
  104. y[24]=5
  105. x[25]=10
  106. y[25]=4
  107. x[26]=2
  108. y[26]=13
  109. x[27]=8
  110. y[27]=13
  111. x[28]=1
  112. y[28]=6
  113. x[29]=6
  114. y[29]=13
  115. x[30]=14
  116. y[30]=12
  117. x[31]=9
  118. y[31]=6
  119. x[32]=8
  120. y[32]=6
  121. x[33]=6
  122. y[33]=12
  123. x[34]=1
  124. y[34]=10
  125. x[35]=2
  126. y[35]=8
  127. x[36]=12
  128. y[36]=5
  129. x[37]=13
  130. y[37]=10
  131. x[38]=13
  132. y[38]=7
  133. x[39]=2
  134. y[39]=6
  135. x[40]=4
  136. y[40]=9
  137. x[41]=3
  138. y[41]=6
  139. x[42]=5
  140. y[42]=10
  141. x[43]=11
  142. y[43]=3
  143. x[44]=2
  144. y[44]=5
  145. local N=44
  146.  
  147.  
  148. local RNGArray = {}
  149.  
  150. RNGArray[1] = 246
  151. RNGArray[2] = 35
  152. RNGArray[3] = 70
  153. RNGArray[4] = 140
  154. RNGArray[5] = 215
  155. RNGArray[6] = 97
  156. RNGArray[7] = 194
  157. RNGArray[8] = 75
  158. RNGArray[9] = 150
  159. RNGArray[10] = 227
  160. RNGArray[11] = 9
  161. RNGArray[12] = 18
  162. RNGArray[13] = 36
  163. RNGArray[14] = 72
  164. RNGArray[15] = 144
  165. RNGArray[16] = 239
  166. RNGArray[17] = 17
  167. RNGArray[18] = 34
  168. RNGArray[19] = 68
  169. RNGArray[20] = 136
  170. RNGArray[21] = 223
  171. RNGArray[22] = 113
  172. RNGArray[23] = 226
  173. RNGArray[24] = 11
  174. RNGArray[25] = 22
  175. RNGArray[26] = 44
  176. RNGArray[27] = 88
  177. RNGArray[28] = 176
  178. RNGArray[29] = 175
  179. RNGArray[30] = 145
  180. RNGArray[31] = 237
  181. RNGArray[32] = 21
  182. RNGArray[33] = 42
  183. RNGArray[34] = 84
  184. RNGArray[35] = 168
  185. RNGArray[36] = 159
  186. RNGArray[37] = 241
  187. RNGArray[38] = 45
  188. RNGArray[39] = 90
  189. RNGArray[40] = 180
  190. RNGArray[41] = 167
  191. RNGArray[42] = 129
  192. RNGArray[43] = 205
  193. RNGArray[44] = 85
  194. RNGArray[45] = 170
  195. RNGArray[46] = 155
  196. RNGArray[47] = 249
  197. RNGArray[48] = 61
  198. RNGArray[49] = 122
  199. RNGArray[50] = 244
  200. RNGArray[51] = 39
  201. RNGArray[52] = 78
  202. RNGArray[53] = 156
  203. RNGArray[54] = 247
  204. RNGArray[55] = 33
  205. RNGArray[56] = 66
  206. RNGArray[57] = 132
  207. RNGArray[58] = 199
  208. RNGArray[59] = 65
  209. RNGArray[60] = 130
  210. RNGArray[61] = 203
  211. RNGArray[62] = 89
  212. RNGArray[63] = 178
  213. RNGArray[64] = 171
  214. RNGArray[65] = 153
  215. RNGArray[66] = 253
  216. RNGArray[67] = 53
  217. RNGArray[68] = 106
  218. RNGArray[69] = 212
  219. RNGArray[70] = 103
  220. RNGArray[71] = 206
  221. RNGArray[72] = 83
  222. RNGArray[73] = 166
  223. RNGArray[74] = 131
  224. RNGArray[75] = 201
  225. RNGArray[76] = 93
  226. RNGArray[77] = 186
  227. RNGArray[78] = 187
  228. RNGArray[79] = 185
  229. RNGArray[80] = 189
  230. RNGArray[81] = 181
  231. RNGArray[82] = 165
  232. RNGArray[83] = 133
  233. RNGArray[84] = 197
  234. RNGArray[85] = 69
  235. RNGArray[86] = 138
  236. RNGArray[87] = 219
  237. RNGArray[88] = 121
  238. RNGArray[89] = 242
  239. RNGArray[90] = 43
  240. RNGArray[91] = 86
  241. RNGArray[92] = 172
  242. RNGArray[93] = 151
  243. RNGArray[94] = 225
  244. RNGArray[95] = 13
  245. RNGArray[96] = 26
  246. RNGArray[97] = 52
  247. RNGArray[98] = 104
  248. RNGArray[99] = 208
  249. RNGArray[100] = 111
  250. RNGArray[101] = 222
  251. RNGArray[102] = 115
  252. RNGArray[103] = 230
  253. RNGArray[104] = 3
  254. RNGArray[105] = 6
  255. RNGArray[106] = 12
  256. RNGArray[107] = 24
  257. RNGArray[108] = 48
  258. RNGArray[109] = 96
  259. RNGArray[110] = 192
  260. RNGArray[111] = 79
  261. RNGArray[112] = 158
  262. RNGArray[113] = 243
  263. RNGArray[114] = 41
  264. RNGArray[115] = 82
  265. RNGArray[116] = 164
  266. RNGArray[117] = 135
  267. RNGArray[118] = 193
  268. RNGArray[119] = 77
  269. RNGArray[120] = 154
  270. RNGArray[121] = 251
  271. RNGArray[122] = 57
  272. RNGArray[123] = 114
  273. RNGArray[124] = 228
  274. RNGArray[125] = 7
  275. RNGArray[126] = 14
  276. RNGArray[127] = 28
  277. RNGArray[128] = 56
  278. RNGArray[129] = 112
  279. RNGArray[130] = 224
  280. RNGArray[131] = 15
  281. RNGArray[132] = 30
  282. RNGArray[133] = 60
  283. RNGArray[134] = 120
  284. RNGArray[135] = 240
  285. RNGArray[136] = 47
  286. RNGArray[137] = 94
  287. RNGArray[138] = 188
  288. RNGArray[139] = 183
  289. RNGArray[140] = 161
  290. RNGArray[141] = 141
  291. RNGArray[142] = 213
  292. RNGArray[143] = 101
  293. RNGArray[144] = 202
  294. RNGArray[145] = 91
  295. RNGArray[146] = 182
  296. RNGArray[147] = 163
  297. RNGArray[148] = 137
  298. RNGArray[149] = 221
  299. RNGArray[150] = 117
  300. RNGArray[151] = 234
  301. RNGArray[152] = 27
  302. RNGArray[153] = 54
  303. RNGArray[154] = 108
  304. RNGArray[155] = 216
  305. RNGArray[156] = 127
  306. RNGArray[157] = 254
  307. RNGArray[158] = 51
  308. RNGArray[159] = 102
  309. RNGArray[160] = 204
  310. RNGArray[161] = 87
  311. RNGArray[162] = 174
  312. RNGArray[163] = 147
  313. RNGArray[164] = 233
  314. RNGArray[165] = 29
  315. RNGArray[166] = 58
  316. RNGArray[167] = 116
  317. RNGArray[168] = 232
  318. RNGArray[169] = 31
  319. RNGArray[170] = 62
  320. RNGArray[171] = 124
  321. RNGArray[172] = 248
  322. RNGArray[173] = 63
  323. RNGArray[174] = 126
  324. RNGArray[175] = 252
  325. RNGArray[176] = 55
  326. RNGArray[177] = 110
  327. RNGArray[178] = 220
  328. RNGArray[179] = 119
  329. RNGArray[180] = 238
  330. RNGArray[181] = 19
  331. RNGArray[182] = 38
  332. RNGArray[183] = 76
  333. RNGArray[184] = 152
  334. RNGArray[185] = 255
  335. RNGArray[186] = 49
  336. RNGArray[187] = 98
  337. RNGArray[188] = 196
  338. RNGArray[189] = 71
  339. RNGArray[190] = 142
  340. RNGArray[191] = 211
  341. RNGArray[192] = 105
  342. RNGArray[193] = 210
  343. RNGArray[194] = 107
  344. RNGArray[195] = 214
  345. RNGArray[196] = 99
  346. RNGArray[197] = 198
  347. RNGArray[198] = 67
  348. RNGArray[199] = 134
  349. RNGArray[200] = 195
  350. RNGArray[201] = 73
  351. RNGArray[202] = 146
  352. RNGArray[203] = 235
  353. RNGArray[204] = 25
  354. RNGArray[205] = 50
  355. RNGArray[206] = 100
  356. RNGArray[207] = 200
  357. RNGArray[208] = 95
  358. RNGArray[209] = 190
  359. RNGArray[210] = 179
  360. RNGArray[211] = 169
  361. RNGArray[212] = 157
  362. RNGArray[213] = 245
  363. RNGArray[214] = 37
  364. RNGArray[215] = 74
  365. RNGArray[216] = 148
  366. RNGArray[217] = 231
  367. RNGArray[218] = 1
  368. RNGArray[219] = 2
  369. RNGArray[220] = 4
  370. RNGArray[221] = 8
  371. RNGArray[222] = 16
  372. RNGArray[223] = 32
  373. RNGArray[224] = 64
  374. RNGArray[225] = 128
  375. RNGArray[226] = 207
  376. RNGArray[227] = 81
  377. RNGArray[228] = 162
  378. RNGArray[229] = 139
  379. RNGArray[230] = 217
  380. RNGArray[231] = 125
  381. RNGArray[232] = 250
  382. RNGArray[233] = 59
  383. RNGArray[234] = 118
  384. RNGArray[235] = 236
  385. RNGArray[236] = 23
  386. RNGArray[237] = 46
  387. RNGArray[238] = 92
  388. RNGArray[239] = 184
  389. RNGArray[240] = 191
  390. RNGArray[241] = 177
  391. RNGArray[242] = 173
  392. RNGArray[243] = 149
  393. RNGArray[244] = 229
  394. RNGArray[245] = 5
  395. RNGArray[246] = 10
  396. RNGArray[247] = 20
  397. RNGArray[248] = 40
  398. RNGArray[249] = 80
  399. RNGArray[250] = 160
  400. RNGArray[251] = 143
  401. RNGArray[252] = 209
  402. RNGArray[253] = 109
  403. RNGArray[254] = 218
  404. RNGArray[255] = 123
  405. RNGArray[256] = 246
  406.  
  407. local XArray = {}
  408. local YArray = {}
  409. local XSeed = 0
  410. local YSeed = 0
  411.  
  412. local XMax = 0
  413. local XMaxPrev = 0
  414. local YMax
  415.  
  416. YMax = 11
  417.  
  418. --maybe 13 on the grass means fuelable?
  419.  
  420. while true do
  421.  
  422. XMaxPrev = XMax
  423. XMax = memory.readbyte(GAME_MAP_WDT)   -- Script must be reset each level currently.
  424.  
  425. if(XMax<14) then
  426. XMax = 14
  427. end
  428. if(XMax ~= XMaxPrev) then
  429. for i = 1, 255 do
  430.  
  431. XSeed = RNGArray[i]
  432. YSeed = RNGArray[i+1]
  433.  
  434. while XSeed >= 32 do
  435. XSeed = XSeed - 32
  436. end
  437. while YSeed >= 16 do
  438. YSeed = YSeed - 16
  439. end
  440. while XSeed >= XMax do  -- outputs 0 to max-1
  441. XSeed = XSeed - XMax
  442. end
  443. while YSeed >= YMax do  -- outputs 0 to max-1
  444. YSeed = YSeed - YMax
  445. end
  446.  
  447. x[i]=XSeed + 1
  448. y[i]=YSeed + 3
  449.  
  450. N=i
  451.  
  452. end
  453. end
  454.  
  455.  
  456. FuelX = memory.readbyte(NextFuelXAd)
  457. FuelY = memory.readbyte(NextFuelYAd)
  458.  
  459. RandSeed = memory.readbyte(RandSeedAd)
  460.  
  461. XVal = memory.readbyte(XAd)
  462. YVal =  memory.readbyte(YAd)
  463. XSub = memory.readbyte(XSubAd)
  464. YSub = memory.readbyte(YSubAd)
  465. RealSub = memory.readbyte(DoubleSubPxAd)
  466.  
  467. WHERETOGET = memory.readbyte(WHERETOGETAD)
  468. WHERETOGET2 = memory.readbyte(WHERETOGETAD2)
  469. WHERETOGET3 = memory.readbyte(WHERETOGETAD3)
  470.  
  471. Velocity = memory.readbyte(VelocityAd)
  472.  
  473. CurrFuel = memory.readbyte(CurrFuelAd2)
  474. FuelCounter = memory.readbyte(FuelCounterAd)
  475. GrassesLeft = memory.readbyte(GrassesLeftAd)
  476.  
  477. gui.text(45,0,"X: " .. XVal .. " " .. XSub)
  478. gui.text(100,0,RealSub)
  479. gui.text(45,10,"Y: " .. YVal .. " " .. YSub)
  480. gui.text(45,20,"Fuel X: " .. FuelX)
  481. gui.text(45,30,"Fuel Y: " .. FuelY)
  482. gui.text(45,40,"Fuel in " .. FuelCounter)
  483. gui.text(45,50,"Speed " .. Velocity)
  484. gui.text(55,60,"Seed " .. RandSeed)
  485. gui.text(108,20,CurrFuel)
  486. gui.text(185,22,"Remaining: " .. GrassesLeft)
  487. --gui.text(170,42,"B5: " .. WHERETOGET)
  488. --gui.text(170,52,"B6: " .. WHERETOGET2)
  489. --gui.text(170,62,"E3: " .. WHERETOGET3)
  490. --gui.text(170,72,"31: " .. memory.readbyte(0x00C9))
  491. --gui.text(170,82,"XCAM:" .. memory.readbyte(GAME_CAM_X))
  492.  
  493. --------------------------memory.writebyte(WHERETOGETAD3,233)
  494. --memory.writebyte(WHERETOGETAD2,3)
  495. --memory.writebyte(WHERETOGETAD,235)
  496. --memory.writebyte(Grass2Ad,12)
  497. --memory.writebyte(Grass3Ad,13)
  498. --memory.writebyte(Grass4Ad,13)
  499. --memory.writebyte(Base2,1)
  500. --memory.writebyte(Counter2,1)
  501.  
  502. for i=1,N do
  503. XX=16*(x[i]-1)+24 - memory.readbyte(GAME_CAM_X)
  504. YY=16*(y[i]-3)+48
  505. gui.drawbox(XX-3, YY-3, XX+3, YY+3, "red")
  506. end
  507.  
  508. FCEU.frameadvance()
  509.  
  510. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement