Advertisement
Guest User

Mario & Luigi lua script Bizhawk TASing

a guest
Oct 9th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.17 KB | None | 0 0
  1. local ismovie= movie.isloaded
  2.  
  3.  
  4. local TblNextM= { -- Mario experience needed
  5.      7,   32,   68,  108,  218,  336,  470,  694,  962, 1254,  -- 1-10
  6.   1578, 1924, 2306, 2756, 3256, 3830, 4480, 5195, 5975, 6845   --11-20
  7. }
  8.  
  9. local TblNextL= { -- Luigi experience needed
  10.     10,   37,   77,  123,  233,  353,  493,  699,  969, 1272,  -- 1-10
  11.   1552, 1898, 2280, 2730, 3239, 3813, 4463, 5178, 5958, 6858   --11-20
  12. }
  13.  
  14. local itemsTbl = {
  15. [0] = "mushrooms",
  16. [1] = "supermushrooms",
  17. [2] = "ultramushrooms",
  18. [3] = "maxmushrooms",
  19. [4] = "nuts",
  20. [5] = "supernuts",
  21. [6] = "ultranuts",
  22. [7] = "maxnuts",
  23. [8] = "syrups",
  24. [9] = "supersyrups",
  25. [10] = "ultrasyrups",
  26. [11] = "maxsyrups",
  27. [12] = "1ups",
  28. [13] = "1ups DX",
  29. [14] = "goldmushrooms",
  30. [15] = "herbs",
  31. [16] = "redpeppers",
  32. [17] = "greenpeppers",
  33. [18] = "woohoo blends",
  34. [19] = "hoohoo blends",
  35. [20] = "chuckle blends",
  36. [21] = "teehee blends",
  37. [22] = "hoolumbians",
  38. [23] = "chuckoccinos",
  39. [24] = "teeheespressos",
  40. --[32] = "woo beans",
  41. --[33] = "hoo beans",
  42. --[34] = "chuckle beans",
  43. --[35] = "hee beans",
  44. [48] = "bean badges",
  45. [49] = "castle badges",
  46. [50] = "pea badges",
  47. [51] = "bean B. badges",
  48. [52] = "counter badges",
  49. [53] = "charity badges",
  50. [54] = "bros. badges",
  51. [55] = "miracle badges",
  52. [56] = "ohoracle badges",
  53. [57] = "mush badges",
  54. [58] = "mari-lui badges",
  55. [59] = "muscle badges",
  56. [60] = "spiny badges AA",
  57. [61] = "mush badges A",
  58. [62] = "grab badges",
  59. [63] = "mush badges AA",
  60. [64] = "power badges",
  61. [65] = "wonder badges",
  62. [66] = "beauty badges",
  63. [67] = "salvage badges",
  64. [68] = "oh-pah badges",
  65. [69] = "brilliant badges",
  66. [70] = "sarge badges",
  67. [71] = "general badges",
  68. [72] = "tank badges",
  69. [73] = "school emblem",
  70. [74] = "steady badges",
  71. [75] = "oho jee symbol",
  72. [76] = "spiny badges A",
  73. [77] = "bros. lifes",
  74. [78] = "piranha swings",
  75. [79] = "bros. rocks",
  76. [80] = "lucky ribbons",
  77. [81] = "mush badges A",
  78. [82] = "soulful bros.",
  79. [83] = "high-end badges",
  80. [84] = "hand auras",
  81. [85] = "sledge hearts",
  82. [86] = "lucky bros.",
  83. [87] = "bros. respects",
  84. [88] = "bowser fists",
  85. [89] = "bowser fangs",
  86. [90] = "spike badges",
  87. [91] = "chuckola badges",
  88. [104] = "work pants",
  89. [105] = "work jeans",
  90. [106] = "bean pants",
  91. [107] = "blue jeans",
  92. [108] = "parasol pants",
  93. [109] = "hard pants",
  94. [110] = "heart jeans",
  95. [111] = "plaid trousers",
  96. [112] = "#1 trousers",
  97. [113] = "safety slacks",
  98. [114] = "shroom pants",
  99. [115] = "shroom bells",
  100. [116] = "shroom slacks",
  101. [117] = "peachy jeans",
  102. [118] = "mushwin pants",
  103. [119] = "mushluck pants",
  104. [120] = "scandal jeans",
  105. [121] = "street jeans",
  106. [122] = "tropic jeans",
  107. [123] = "hermetic jeans",
  108. [124] = "beanstar pants",
  109. [125] = "peasley slacks",
  110. [126] = "queen B. slacks",
  111. [127] = "B. brand jeans",
  112. [128] = "heart slacks",
  113. [129] = "casual slacks",
  114. [130] = "bubble's gears",
  115. [131] = "chuckola pants",
  116. [132] = "smart pants",
  117. [133] = "school slacks",
  118. [134] = "oho jee wears",
  119. [135] = "oho gears",
  120. [136] = "casual corals",
  121. [137] = "piranha suits",
  122. [138] = "anuboo jeans",
  123. [139] = "ancient pants",
  124. [140] = "heavy slacks",
  125. [141] = "light slacks",
  126. [142] = "harhall's pants",
  127. [143] = "jeanie jeans",
  128. [144] = "wool trousers",
  129. [145] = "random slacks",
  130. [146] = "jeaniest jeans",
  131. [147] = "safe guards",
  132. [148] = "iron pants"
  133. }
  134.  
  135. --** switch ** --
  136.  
  137. clicked=false
  138.  
  139. --** MOVE EVERYTHING AROUND **--
  140. x =0
  141. y = 0
  142.  
  143. --*****************************************************************************
  144. while true do
  145. --*****************************************************************************
  146.  
  147. -- WHEN MOVIE IS NOT ACTIVE, DISPLAY NOTE
  148. if ismovie()~=true then
  149.  
  150.   gui.text(14,60, "MOVIE NOT", 0x00000000, 0xFFFF0000)
  151.   gui.text(14,74, "RECORDING", 0x00000000, 0xFFFF0000)
  152. end
  153.  
  154. memory.usememorydomain("EWRAM")
  155.  
  156. --- SEPARATION LINES
  157.   gui.text(80,-2, "|", 0x00000000, 0x4FFFFFFF)
  158.   gui.text(81,-2, "|", 0x00000000, 0x4FFFFFFF)
  159.   gui.text(80,11, "|", 0x00000000, 0x4FFFFFFF)
  160.   gui.text(81,11, "|", 0x00000000, 0x4FFFFFFF)
  161.   gui.text(80,24, "|", 0x00000000, 0x4FFFFFFF)
  162.   gui.text(81,24, "|", 0x00000000, 0x4FFFFFFF)
  163.   gui.text(80,37, "|", 0x00000000, 0x4FFFFFFF)
  164.   gui.text(81,37, "|", 0x00000000, 0x4FFFFFFF)
  165.  
  166.   gui.text(309,-2, "|", 0x00000000, 0x4FFFFFFF)
  167.   gui.text(310,-2, "|", 0x00000000, 0x4FFFFFFF)
  168.   gui.text(309,11, "|", 0x00000000, 0x4FFFFFFF)
  169.   gui.text(310,11, "|", 0x00000000, 0x4FFFFFFF)
  170.   gui.text(309,24, "|", 0x00000000, 0x4FFFFFFF)
  171.   gui.text(310,24, "|", 0x00000000, 0x4FFFFFFF)
  172.   gui.text(309,37, "|", 0x00000000, 0x4FFFFFFF)
  173.   gui.text(310,37, "|", 0x00000000, 0x4FFFFFFF)
  174.  
  175.   gui.text(232,-2, "|", 0x00000000, 0x4FFFFFFF)
  176.   gui.text(233,-2, "|", 0x00000000, 0x4FFFFFFF)
  177.   gui.text(232,11, "|", 0x00000000, 0x4FFFFFFF)
  178.   gui.text(233,11, "|", 0x00000000, 0x4FFFFFFF)
  179.   gui.text(232,24, "|", 0x00000000, 0x4FFFFFFF)
  180.   gui.text(233,24, "|", 0x00000000, 0x4FFFFFFF)
  181.   gui.text(232,37, "|", 0x00000000, 0x4FFFFFFF)
  182.   gui.text(233,37, "|", 0x00000000, 0x4FFFFFFF)
  183.  
  184.  
  185. --MARIO
  186. HPM    = memory.read_s16_le(0x4866)
  187. HPmaxM = memory.read_s16_le(0x486A)
  188. BPM    = memory.read_s16_le(0x486c)
  189. BPmaxM = memory.read_s16_le(0x4870)
  190. PowM   = memory.read_s16_le(0x4874)
  191. DefM   = memory.read_s16_le(0x487c)
  192. SpeedM = memory.read_s16_le(0x4878)
  193. HigeM  = memory.read_s16_le(0x4880)
  194. levelM = memory.read_s8(0x4888)
  195. ExpM   = memory.read_s16_le(0x485c)
  196.  
  197. -- This calculates how much experience you have to get for the next level.
  198. -- The NextM/NextL values seem to be hardcoded into the game.
  199. NextM = TblNextM[levelM] or 0
  200. NextexpM = NextM - ExpM
  201.  
  202. --LUIGI
  203. HPL    = memory.read_s16_le(0x48a2)
  204. HPmaxL = memory.read_s16_le(0x48a6)
  205. BPL    = memory.read_s16_le(0x48a8)
  206. BPmaxL = memory.read_s16_le(0x48ac)
  207. PowL   = memory.read_s16_le(0x48b0)
  208. DefL   = memory.read_s16_le(0x48b8)
  209. SpeedL = memory.read_s16_le(0x48b4)
  210. HigeL  = memory.read_s16_le(0x48bc)
  211. levelL = memory.read_s8(0x48c4)
  212. ExpL   = memory.read_s16_le(0x4898)
  213.  
  214. -- 'Next' calculator
  215. NextL = TblNextL[levelL] or 0
  216. NextexpL = NextL - ExpL
  217.  
  218.  
  219. --Mushpower + Cash
  220. mush = memory.read_s8(0x48e2)
  221. supermush = memory.read_s8(0x48e3)
  222. ultramush = memory.read_s8(0x48e4)
  223. maxmush = memory.read_s8(0x48e5)
  224. if mush <0 then mush = 0 end
  225. if supermush <0 then supermush = 0 end
  226. if ultramush <0 then ultramush = 0 end
  227. if maxmush <0 then maxmush = 0 end
  228.  
  229. gui.text(12+x,25+y,  mush*0.078 + supermush*0.098 + ultramush*0.117 + maxmush*0.199 , 0x00000000, "yellow")
  230. gui.text(12+x, 38+y, memory.read_s16_le(0x48e0) .. " $", 0x00000000,"yellow")
  231.  
  232. --STATS
  233. gui.text( 122+x, 0+y, "Lv" .. levelM, 0x00000000,0xffEE9595)
  234. gui.text(184+x, 0+y, "Lv" .. levelL,0x00000000,0xff77EE77)
  235. gui.text( 88+x, 12+y, "BP ", 0x00000000,0xff777777)
  236. gui.text( 88+x, 25+y, "POW ", 0x00000000,0xff777777)
  237. gui.text( 89+x, 38+y, "HIGE ", 0x00000000,0xff777777)
  238.  
  239. gui.text( 120+x, 12+y, BPM .. "/" .. BPmaxM, 0x00000000, 0xFFFFFFFF)
  240. gui.text( 183+x, 12+y, BPL .. "/" .. BPmaxL,0x00000000, 0xFFFFFFFF)
  241. gui.text(140+x,25+y, PowM, 0x00000000,0xFFffffff)
  242. gui.text(204+x,25+y, PowL, 0x00000000,0xFFffffff)
  243. gui.text(140+x,37+y, HigeM,0x00000000,0xFFffffff)
  244. gui.text(204+x,37+y, HigeL,0x00000000,0xFFffffff)
  245.  
  246. --Bros Attacks counters
  247. gui.text( 12+x,0+y, "S".. math.max(20 - memory.read_s8(0x4684),0),0x000000,0xffEE9595)
  248. gui.text(-8+x,12+y,"  B".. math.max( 8 - memory.read_s8(0x468c),0),0x000000,0xff77EE77)
  249. gui.text(31+x,0+y,"  C".. math.max(32 - memory.read_s8(0x4686),0),0x000000,0xffEE9595)
  250. gui.text(31+x,12+y,"  K".. math.max(43 - memory.read_s8(0x468e),0),0x000000,0xff77EE77)
  251.  
  252. -- RNG
  253. gui.text(175+x,60+y, memory.read_u8(0x1e60),0x00000000,0xffffffff)  
  254. gui.text(175+x,73+y, memory.read_u8(0x1e64),0x00000000,0xffffffff)
  255.  
  256.  
  257. -- WHEN IT IS ACTIVE, DISPLAY LAGCOUNT,FRAMECOUNT,INPUT
  258. if ismovie() == true then
  259.  
  260. if emu.islagged()==true then gui.text(56,73, "*****", 0x00000000, 0xFFFFFF33) end
  261.  
  262. gui.text(12,60, emu.framecount(), 0xff000000, 0xFFFFFFFF) --white framecounttext
  263. gui.text(12,73, emu.lagcount(), 0xff000000, 0xFFFFFF33) --yellow lagcounttext
  264.  
  265. t = ""
  266. for key, value in pairs(joypad.get()) do
  267. --  if value ~= false then    t = t .." ".. tostring(key) end
  268.     if value ~= false then
  269.          if tostring(key)=="Up" then t = t .." ^"
  270.          elseif tostring(key)=="Down" then t = t .." v"
  271.          elseif tostring(key)=="Left" then t = t .." <"
  272.          elseif tostring(key)=="Right" then t = t .." >"
  273.          elseif tostring(key)=="Select" then t = t .." s"
  274.          elseif tostring(key)=="Start" then t = t .." S"
  275.          else t = t .." ".. tostring(key) end
  276.     end
  277. end
  278. gui.text(76,60,tostring(t), 0xff000000, 0xffffffff)
  279. end
  280.  
  281. ---- MOUSE CLICK EVENT
  282. mouseX=0
  283. mouseY=0
  284. for key, value in pairs(input.getmouse()) do
  285.  
  286.      if tostring(key) == "X" then mouseX = value end
  287.      if tostring(key) == "Y" then mouseY = value end
  288.      if tostring(key) =="Left" then mouseClicked = value end
  289.  
  290. end
  291.  
  292. --- CLICK ON BUTTON
  293.  
  294. if clicked == false then
  295.    if mouseX > 224 then
  296.        if mouseY < 10 then
  297.            if mouseClicked == true then clicked = true end
  298.        end
  299.    end
  300. end
  301.  
  302. if clicked == true then
  303.    if mouseX > 144 then
  304.        if mouseX < 159 then
  305.             if mouseY < 10 then
  306.                  if mouseClicked == true then clicked = false end
  307.             end
  308.         end
  309.     end
  310. end
  311.  
  312.  
  313. ---- ITEM DISPLAY
  314.  
  315. itempos = 0
  316. count=0
  317.  
  318.  
  319. if clicked==false then
  320. gui.drawBox(227,0,238,8, 0x000000, 0xaaff3300) --buttongraphic
  321. gui.drawLine(232,1,232,6, 0xAAFFFFFF)
  322. gui.drawLine(233,1,233,5, 0xAAFFFFFF)
  323. gui.drawLine(231,1,231,5, 0xAAFFFFFF)
  324. gui.drawLine(230,3,230,4, 0xAAFFFFFF)
  325. gui.drawLine(234,3,234,4, 0xAAFFFFFF)
  326. gui.drawPixel(235,3, 0xAAFFFFFF)
  327. gui.drawPixel(229,3, 0xAAFFFFFF)
  328. end
  329.  
  330. if clicked == true then
  331. gui.drawBox(147,0,158,8, 0x000000, 0xaaff3300) --buttongraphic
  332. gui.drawLine(152,1,152,6, 0xAAFFFFFF)
  333. gui.drawLine(153,2,153,6, 0xAAFFFFFF)
  334. gui.drawLine(151,2,151,6, 0xAAFFFFFF)
  335. gui.drawLine(150,3,150,4, 0xAAFFFFFF)
  336. gui.drawLine(154,3,154,4, 0xAAFFFFFF)
  337. gui.drawPixel(155,4, 0xAAFFFFFF)
  338. gui.drawPixel(149,4, 0xAAFFFFFF)
  339. end
  340.  
  341.  
  342. --****************************
  343.  
  344. if clicked==false then
  345.  
  346.    for offset = 0, 149 do
  347.        if itemsTbl[offset] then
  348.            amount = memory.read_s8(0x48E2 + offset)
  349.  
  350.            if count < 7 then
  351.            if (amount > 0) then
  352.                      if      string.len(itemsTbl[offset])> 12 then
  353.                      gui.text(320,0+itempos, amount, 0x00FFFFFF,0xFF777777)
  354.                      gui.text(350,0+itempos, bizstring.substring(itemsTbl[offset],0,10) .. "..", 0x00FFFFFF,0xFF777777)
  355.                      else  
  356.                      gui.text(320, 0 + itempos, amount, 0x00FFFFFF,0xFF777777)  
  357.                      gui.text(350, 0 + itempos, itemsTbl[offset], 0x00FFFFFF,0xFF777777)      
  358.                      end
  359.                      count=count+1
  360.                      itempos = count*12.5
  361.            end
  362.            end
  363.        end
  364.    end
  365. end
  366.  
  367. --***************************************
  368.  
  369. if clicked==true then
  370.  
  371. -- finding out how many entries 8~?
  372.  
  373.    for offset = 0, 149 do
  374.        if itemsTbl[offset] then
  375.            amount = memory.read_s8(0x48E2 + offset)
  376.          
  377.            if (amount > 0) then count=count+1 end
  378.        
  379.        end
  380.    end
  381.  
  382.         gui.drawBox(157,0,500, 3.4*count, 0xFF000000,0xFF000000)
  383.  
  384.  
  385. -- now adding a box based on the # of entries we found above
  386.  
  387.    for offset = 0, 149 do
  388.        if itemsTbl[offset] then
  389.            amount = memory.read_s8(0x48E2 + offset)
  390.          
  391.            if (amount > 0) then
  392.                      if      string.len(itemsTbl[offset])> 12 then
  393.                      gui.text(320,0+itempos, amount, 0x00FFFFFF,0xFF777777)
  394.                      gui.text(350,0+itempos, bizstring.substring(itemsTbl[offset],0,10) .. "..", 0x00FFFFFF,0xFF777777)
  395.                      else  
  396.                      gui.text(320, 0 + itempos, amount, 0x00FFFFFF,0xFF777777)  
  397.                      gui.text(350, 0 + itempos, itemsTbl[offset], 0x00FFFFFF,0xFF777777)      
  398.                      end
  399.                      itempos = itempos+12.5
  400.            end
  401.        end
  402.       end
  403. end
  404.  
  405. --*************************************
  406.  
  407. ---- POS
  408. gui.text(245+x,  1+y, memory.read_s24_le(0x6c14), 0x00000000,0xffEE9595)
  409. gui.text(245+x,  13+y, memory.read_s24_le(0x6c18), 0x00000000,0xffEE9595)
  410. gui.text(245+x, 25+y, memory.read_s24_le(0x6fb0), 0x00000000, 0xff77EE77)
  411. gui.text(245+x, 37+y, memory.read_s24_le(0x6fb4), 0x00000000,0xff77EE77)
  412.  
  413. ---- MISC
  414. --gui.text(10, 89, "rookie hp " ..R2u(0x8ce6)-5000, 0xE5FFFF00)
  415. --gui.text(10, 89, "Birdo hp "  ..R2u(0x8fe2), 0xE5FFFF00)
  416. --gui.text(10, 89, "head  "  ..R2u(0xaa42)-5000, 0xE5FFFF00)
  417. --gui.text(10, 98, "heart  " ..R2u(0xa912)-5000, 0xE5FFFF00)
  418. --gui.text(10,107, "left  "  ..R2u(0xab72)-5000, 0xE5FFFF00)
  419. --gui.text(10,116, "right  " ..R2u(0xaca2)-5000, 0xE5FFFF00)
  420.  
  421. --- COMMAND ID
  422. if     memory.read_s8(0x04f4c) == 0 then gui.text(216,73,"<", 0x00000000,0x5fFFFFFF)
  423. elseif memory.read_s8(0x4f4c) == 1 then gui.text(216,60,"<", 0x00000000,0x5fFFFFFF) end
  424.  
  425. memory.usememorydomain("IWRAM")
  426. gui.text(266+x, 60+y, memory.read_u8(0x2429), 0x00000000,0xffEE9595)
  427. gui.text(230+x, 60+y, memory.read_u8(0x2440), 0x00000000, 0xff77EE77)
  428.  
  429. gui.text(266+x, 73+y, memory.read_u8(0x2441), 0x00000000, 0xff77EE77)
  430. gui.text(230+x, 73+y, memory.read_u8(0x2428), 0x00000000,0xffEE9595)
  431.  
  432.  
  433. emu.frameadvance()
  434. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement