Advertisement
Guest User

katam lua 0.1.1

a guest
Oct 2nd, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.98 KB | None | 0 0
  1. local ScriptInfo = {"KATAM Luascript by Mugg1991",
  2.                     "v0.1.1",  
  3.                     "2nd Oct 2017",
  4. }
  5.  
  6. --[[
  7.     v0.1
  8.     - Initial release
  9.     v0.1.1
  10.     - Fixed that the hitbox display wouldn't work.
  11. ]]
  12.  
  13. local Settings = {
  14.     ["Boolwin1"]=false, -- general
  15.     ["win1x"]=40,
  16.     ["win1y"]=40,
  17.     ["Boolwin2"]=false, -- kirby
  18.     ["win2x"]=40,
  19.     ["win2y"]=40,
  20.     ["Boolwin3"]=false, -- flags
  21.     ["win3x"]=40,
  22.     ["win3y"]=40,
  23.     ["Boolwin4"]=false, -- yellow
  24.     ["win4x"]=40,
  25.     ["win4y"]=40,
  26.     ["Boolwin5"]=false, -- red
  27.     ["win5x"]=40,
  28.     ["win5y"]=40,
  29.     ["Boolwin6"]=false, -- green
  30.     ["win6x"]=40,
  31.     ["win6y"]=40,
  32.     ["Boolwin7"]=false  -- enemies
  33. }
  34.  
  35. local AddressTableGeneral= {
  36. [1] = {1,"Camera X",0xFFFFE0A0,"EWRAM",0x23660,2,true,nil,nil,nil},
  37. [2] = {1,"Camera Y",0xFFFFE0A0,"EWRAM",0x23662,2,true,nil,nil,nil},
  38. [3] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil},
  39. [4] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil},
  40. [5] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil},
  41. [6] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil}
  42. }
  43.  
  44. local AddressTableFlags= {
  45. [1] = {0,"Mirror Shards",0xFFB0B0B0},  
  46. [2] = {7,"Kracko",0xFFFFE0A0,"EWRAM",0x38970,0,true,nil,nil,nil},
  47. [3] = {7,"King Golem",0xFFFFE0A0,"EWRAM",0x38970,1,true,nil,nil,nil},
  48. [4] = {7,"Master Hand",0xFFFFE0A0,"EWRAM",0x38970,2,true,nil,nil,nil},
  49. [5] = {7,"Gobbler",0xFFFFE0A0,"EWRAM",0x38970,3,true,nil,nil,nil},
  50. [6] = {7,"Wiz",0xFFFFE0A0,"EWRAM",0x38970,4,true,nil,nil,nil},
  51. [7] = {7,"Moley",0xFFFFE0A0,"EWRAM",0x38970,5,true,nil,nil,nil},
  52. [8] = {7,"Mega Titan",0xFFFFE0A0,"EWRAM",0x38970,6,true,nil,nil,nil},
  53. [9] = {7,"D. Metaknight",0xFFFFE0A0,"EWRAM",0x38970,7,true,nil,nil,nil},
  54.  
  55. [10] = {0,"Misc",0xFFB0B0B0},  
  56. [11] = {7,"Ability Room",0xFFFFE0A0,"EWRAM",0x28C58,0,true,nil,nil,nil},
  57.  
  58. [12] = {0,"Area 1",0xFFB0B0B0},        
  59. [13] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C18,0,true,nil,nil,nil},
  60. [14] = {7,"Big Chest",0xFFFFE0A0,"EWRAM",0x38960,5,true,nil,nil,nil},
  61. [15] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38960,3,true,nil,nil,nil},
  62. [16] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38961,0,true,nil,nil,nil},
  63. [17] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38961,1,true,nil,nil,nil},
  64.  
  65. [18] = {0,"Area 2",0xFFB0B0B0},    
  66. [19] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C14,0,true,nil,nil,nil},
  67. [20] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38962,2,true,nil,nil,nil},  
  68. [21] = {7,"Big Chest",0xFFFFE0A0,"EWRAM",0x38961,7,true,nil,nil,nil},
  69. [22] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38962,1,true,nil,nil,nil},
  70.  
  71. [23] = {0,"Area 3",0xFFB0B0B0},    
  72. [24] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C28,0,true,nil,nil,nil},
  73. [25] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C24,0,true,nil,nil,nil},
  74.  
  75. [26] = {0,"Area 4",0xFFB0B0B0},    
  76. [27] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C44,0,true,nil,nil,nil},
  77. [28] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C4C,0,true,nil,nil,nil},   
  78.  
  79. [29] = {0,"Area 5",0xFFB0B0B0},
  80. [30] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C34,0,true,nil,nil,nil},
  81. [31] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C38,0,true,nil,nil,nil},
  82. [32] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38969,5,true,nil,nil,nil},      
  83.  
  84. [33] = {0,"Area 6",0xFFB0B0B0},    
  85. [34] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C1C,0,true,nil,nil,nil},
  86. [35] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C20,0,true,nil,nil,nil},
  87. [36] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38968,1,true,nil,nil,nil},
  88.  
  89. [37] = {0,"Area 7",0xFFB0B0B0},
  90. [38] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C3C,0,true,nil,nil,nil},
  91. [39] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C40,0,true,nil,nil,nil},       
  92.  
  93. [40] = {0,"Area 8",0xFFB0B0B0},
  94. [41] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C2C,0,true,nil,nil,nil},
  95. [42] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C30,0,true,nil,nil,nil},   
  96. [43] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38969,2,true,nil,nil,nil},  
  97.  
  98. [44] = {0,"Area 9",0xFFB0B0B0},
  99. [45] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C48,0,true,nil,nil,nil},   
  100. }
  101.  
  102. local AddressTableKirby= {
  103. [1] = {1,"X",0xFFFFB0C0,"EWRAM",0x020F20,4,true,nil,nil,nil,false},
  104. [2] = {1,"Y",0xFFFFB0C0,"EWRAM",0x020F24,4,true,nil,nil,nil,false},
  105. [3] = {1,"X Speed",0xFFFFB0C0,"EWRAM",0x020F30,2,true,nil,nil,nil,true},
  106. [4] = {1,"Y Speed",0xFFFFB0C0,"EWRAM",0x020F32,2,true,nil,nil,nil,true},
  107. [5] = {1,"Ability",0xFFFFB0C0,"EWRAM",0x020FE3,1,true,0,26,1,false},
  108. [6] = {1,"Health",0xFFFFB0C0,"EWRAM",0x020FE0,1,true,0,255,1,false},
  109. [7] = {1,"Max Health",0xFFFFB0C0,"EWRAM",0x020FE1,1,true,0,255,1,false},
  110. [8] = {1,"Lives",0xFFFFB0C0,"EWRAM",0x020FE2,1,true,0,255,1,false},
  111. [9] = {1,"Phone Battery",0xFFFFB0C0,"EWRAM",0x020FBC,1,true,0,255,1,false},
  112. [10] = {1,"Room",0xFFFFB0C0,"EWRAM",0x020FE6,2,true,101,970,1,false}
  113. }
  114.  
  115. local AddressTableYellow= {
  116. [1] = {1,"X",0xFFFFE060,"EWRAM",0x0210C8,4,true,nil,nil,nil,false},
  117. [2] = {1,"Y",0xFFFFE060,"EWRAM",0x0210CC,4,true,nil,nil,nil,false},
  118. [3] = {1,"X Speed",0xFFFFE060,"EWRAM",0x0210D8,2,true,nil,nil,nil,true},
  119. [4] = {1,"Y Speed",0xFFFFE060,"EWRAM",0x0210DA,2,true,nil,nil,nil,true},
  120. [5] = {1,"Ability",0xFFFFE060,"EWRAM",0x02118B,1,true,0,26,1,false},
  121. [6] = {1,"Health",0xFFFFE060,"EWRAM",0x021188,1,true,0,255,1,false},
  122. [7] = {1,"Max Health",0xFFFFE060,"EWRAM",0x021189,1,true,0,255,1,false},
  123. [8] = {1,"Room",0xFFFFE060,"EWRAM",0x02118E,2,true,101,970,1,false}
  124. }
  125.  
  126. local AddressTableRed= {
  127. [1] = {1,"X",0xFFFF9090,"EWRAM",0x021270,4,true,nil,nil,nil,false},
  128. [2] = {1,"Y",0xFFFF9090,"EWRAM",0x021274,4,true,nil,nil,nil,false},
  129. [3] = {1,"X Speed",0xFFFF9090,"EWRAM",0x021280,2,true,nil,nil,nil,true},
  130. [4] = {1,"Y Speed",0xFFFF9090,"EWRAM",0x021282,2,true,nil,nil,nil,true},
  131. [5] = {1,"Ability",0xFFFF9090,"EWRAM",0x021333,1,true,0,26,1,false},
  132. [6] = {1,"Health",0xFFFF9090,"EWRAM",0x021330,1,true,0,255,1,false},
  133. [7] = {1,"Max Health",0xFFFF9090,"EWRAM",0x021331,1,true,0,255,1,false},
  134. [8] = {1,"Room",0xFFFF9090,"EWRAM",0x021336,2,true,101,970,1,false}
  135. }
  136.  
  137. local AddressTableGreen= {
  138. [1] = {1,"X",0xFFC0FF80,"EWRAM",0x021418,4,true,nil,nil,nil,false},
  139. [2] = {1,"Y",0xFFC0FF80,"EWRAM",0x02141C,4,true,nil,nil,nil,false},
  140. [3] = {1,"X Speed",0xFFC0FF80,"EWRAM",0x021428,2,true,nil,nil,nil,true},
  141. [4] = {1,"Y Speed",0xFFC0FF80,"EWRAM",0x02142A,2,true,nil,nil,nil,true},
  142. [5] = {1,"Ability",0xFFC0FF80,"EWRAM",0x0214DB,1,true,0,26,1,false},
  143. [6] = {1,"Health",0xFFC0FF80,"EWRAM",0x0214D8,1,true,0,255,1,false},
  144. [7] = {1,"Max Health",0xFFC0FF80,"EWRAM",0x0214D9,1,true,0,255,1,false},
  145. [8] = {1,"Room",0xFFC0FF80,"EWRAM",0x0214DE,2,true,101,970,1,false}
  146. }
  147.  
  148. local AddressTableDisplayOffset = { -- the offset of the list entry
  149.     ["win1"]        =0,
  150.     ["win2"]        =0,
  151.     ["win3"]        =0,
  152.     ["win4"]        =0,
  153.     ["win5"]        =0,
  154.     ["win6"]        =0
  155. }
  156.  
  157. local DisplayEditMode = {
  158.     ["win1"]        =false,
  159.     ["win2"]        =false,
  160.     ["win3"]        =false,
  161.     ["win4"]        =false,
  162.     ["win5"]        =false,
  163.     ["win6"]        =false
  164. }
  165.  
  166. local Mouse = {
  167.     X               = 0,
  168.     Y               = 0,
  169.     XBefore         = 0,
  170.     YBefore         = 0,
  171.     clickedFrames   = 0,
  172.     clicked         = false
  173. }
  174.  
  175. local Color = {
  176.     Selected    = 0xB0A0A0A0,
  177.     Normal      = 0xA0303030,
  178.     Grey        = 0xA0C0C0C0
  179. }
  180.  
  181. function text(x, y, text, color, backcolor)
  182.     if backcolor==nil then backcolor=0x00000000 end
  183.     gui.drawText(x, y, text,color,backcolor,10,"Arial")
  184. end
  185.  
  186. function box(x,y,x2,y2)
  187.     gui.drawBox(x,y,x2,y2,0x00000000,0xD0000000)
  188. end
  189.  
  190. function boxNormal(x,y,x2,y2)
  191.     gui.drawBox(x,y,x2,y2,0xFF000000,0xA0000000)
  192. end
  193.  
  194. function boxSelected(x,y,x2,y2)
  195.     gui.drawBox(x,y,x2,y2,0xFF000000,0xA0505050)
  196. end
  197.  
  198. function arrowDown(xpos,ypos,col)
  199.     gui.drawLine(xpos,ypos,xpos+6,ypos,col)
  200.     gui.drawLine(xpos+1,ypos+1,xpos+5,ypos+1,col)
  201.     gui.drawLine(xpos+2,ypos+2,xpos+4,ypos+2,col)
  202.     gui.drawPixel(xpos+3,ypos+3,col)
  203. end
  204.  
  205. function arrowUp(xpos,ypos,col)
  206.     gui.drawLine(xpos,ypos,xpos+6,ypos,col)
  207.     gui.drawLine(xpos+1,ypos-1,xpos+5,ypos-1,col)
  208.     gui.drawLine(xpos+2,ypos-2,xpos+4,ypos-2,col)
  209.     gui.drawPixel(xpos+3,ypos-3,col)
  210. end
  211.  
  212.  
  213. function drawDisplayBox(posx,posy,stringx,stringy,width,height,bordercolor,color)
  214.  
  215.     if Mouse.clicked then
  216.  
  217.         if Mouse.X > posx and Mouse.X < posx+width and Mouse.Y > posy and Mouse.Y < posy+height then
  218.  
  219.             if Mouse.clickedFrames > 0 then
  220.                 menuscreen=0 -- close menu
  221.                
  222.                 if stringx~=nil then
  223.                     posy = posy + (Mouse.Y-Mouse.YBefore) -- enables mouse drag
  224.                     posx = posx + (Mouse.X-Mouse.XBefore)
  225.  
  226.                     if posy < 0 then posy=0 -- prevents display from going offscreen
  227.                     elseif posy > 159-height then posy=159-height end
  228.                     if posx < 0 then posx=0
  229.                     elseif posx > 239-width then posx=239-width end
  230.                
  231.                     Settings[stringx]=posx
  232.                     Settings[stringy]=posy
  233.        
  234.                 end
  235.                
  236.             end
  237.  
  238.         end
  239.        
  240.     end
  241.    
  242.     gui.drawBox(posx,posy,posx+width,posy+height,bordercolor,color)
  243.        
  244. end
  245.        
  246. function drawCloseButton(posx,posy,width,setting_id,clickedfunction)
  247.     drawButton(posx+width-10,posy,10,10,"x",Color.Grey,15,function()
  248.         Settings[setting_id] = false
  249.         clickedfunction()
  250.     end)
  251. end
  252.  
  253. function drawEditButton(posx,posy,width,col,resetOffset,displaystring)
  254.     drawButton(posx+width-25,posy,12,10,"e",col,15,function()
  255.         DisplayEditMode[displaystring]=not DisplayEditMode[displaystring]
  256.         if resetOffset then
  257.             AddressTableDisplayOffset[displaystring]=0
  258.         end
  259.     end)
  260. end
  261.  
  262. function drawButton(posx,posy,width,height,label,color,frequency,clickedfunction)
  263.     if Mouse.X>posx and Mouse.X<posx+width and Mouse.Y>posy and Mouse.Y<posy+height then
  264.             if Mouse.clicked and Mouse.clickedFrames%frequency==1 then  
  265.                 clickedfunction()
  266.             end
  267.         gui.drawBox(posx,posy,posx+width,posy+height,color-0x00303030,color+0x30303030)
  268.     else
  269.         gui.drawBox(posx,posy,posx+width,posy+height,color-0x00303030,color)
  270.     end
  271.     text(posx+1,posy-2,label,0xFFFFFFFF)
  272. end
  273.  
  274. function drawMenuButton(posx,posy,width,height,label,z,drawindicator,indicator,col,clickedfunction)
  275.     -- due to the implementation, z needs to be 2 for main menu buttons
  276.     -- and 1 for sub menu buttons. Otherwise, you cannot properly open the menu.
  277.     if Mouse.X>posx and Mouse.X<posx+width and Mouse.Y>posy and Mouse.Y<posy+height then
  278.         if Mouse.clicked and Mouse.clickedFrames==z then
  279.             menuscreen=0
  280.             clickedfunction()
  281.         end
  282.         boxSelected(posx,posy,posx+width,posy+height)
  283.     else
  284.         boxNormal(posx,posy,posx+width,posy+height)
  285.     end
  286.     text(posx+2,posy-1,label,col)
  287.    
  288.     -- draw the specified indicator:
  289.     if drawindicator then
  290.         if indicator then text(posx+width-10,posy,"o",0xFF80FF80)
  291.         else text(posx+width-10,posy-1,"x",0xFFFF9090) end
  292.        
  293.     -- special case: this will be highlighted as a functionality
  294.     -- that's not working yet. To draw no indicator at all, pass
  295.     -- drawindicator as false and indicator as true.
  296.     elseif drawindicator==false and indicator==false then
  297.         text(posx+width-20,posy-1,"N/A",0xFFFFFF80)
  298.     end
  299. end
  300.  
  301. local toboolean = function(string)
  302.     if string=="true" then
  303.         string=true
  304.     elseif string=="false" then
  305.         string=false
  306.     else
  307.         string=nil
  308.     end
  309.    
  310.     return string
  311. end
  312.  
  313. local totime = function(frames,fps)
  314.     hours = math.floor((frames/fps)/3600)
  315.     mins = math.floor((frames/fps)/60)%60
  316.     secs = math.floor(((frames/fps-mins*60)*100+0.5)/100) %60
  317.     ms = (frames % fps)/60 * 100
  318.     if hours==0 then
  319.         returnvalue = string.format("%02d:%02d.%02d",mins,secs,ms)
  320.     else
  321.         returnvalue = string.format("%02d:%02d:%02d.%02d",hours,mins,secs,ms)
  322.     end
  323.     return returnvalue
  324. end
  325.  
  326.  
  327. local getChangeAmount = function(valueChangeAmount)
  328.  
  329.     if Mouse.clickedFrames>810 then
  330.         valueChangeAmount=valueChangeAmount*1000000000
  331.     elseif Mouse.clickedFrames>720 then
  332.         valueChangeAmount=valueChangeAmount*100000000
  333.     elseif Mouse.clickedFrames>630 then
  334.         valueChangeAmount=valueChangeAmount*10000000
  335.     elseif Mouse.clickedFrames>540 then
  336.         valueChangeAmount=valueChangeAmount*1000000
  337.     elseif Mouse.clickedFrames>450 then
  338.         valueChangeAmount=valueChangeAmount*100000
  339.     elseif Mouse.clickedFrames>360 then
  340.         valueChangeAmount=valueChangeAmount*10000
  341.     elseif Mouse.clickedFrames>270 then
  342.         valueChangeAmount=valueChangeAmount*1000
  343.     elseif Mouse.clickedFrames>180 then
  344.         valueChangeAmount=valueChangeAmount*100
  345.     elseif Mouse.clickedFrames>90 then
  346.         valueChangeAmount=valueChangeAmount*10
  347.     end
  348.  
  349.     return valueChangeAmount
  350. end
  351.  
  352. local addressTableSetValue = function(address, addressSize, addressEndian, newvalue)
  353.  
  354.     if addressSize==1 then
  355.         memory.write_u8(address,newvalue)
  356.     elseif addressSize==2 then
  357.         if addressEndian then
  358.             memory.write_u16_le(address,newvalue)
  359.         else
  360.             memory.write_u16_be(address,newvalue)
  361.         end            
  362.     elseif addressSize==3 then
  363.         if addressEndian then
  364.             memory.write_u24_le(address,newvalue)
  365.         else
  366.             memory.write_u24_be(address,newvalue)
  367.         end
  368.     elseif addressSize==4 then
  369.         if addressEndian then
  370.             memory.write_u32_le(address,newvalue)
  371.         else
  372.             memory.write_u32_be(address,newvalue)
  373.         end
  374.     end
  375. end
  376.  
  377. local addressTableGetValue = function(address, addressSize, addressEndian, addressSigned)
  378.  
  379.     if addressSigned then
  380.         if addressSize==1 then
  381.             value=memory.read_s8(address)
  382.         elseif addressSize==2 then
  383.             if addressEndian then
  384.                 value=memory.read_s16_le(address)
  385.             else
  386.                 value=memory.read_s16_be(address)
  387.             end            
  388.         elseif addressSize==3 then
  389.             if addressEndian then
  390.                 value=memory.read_s24_le(address)
  391.             else
  392.                 value=memory.read_s24_be(address)
  393.             end
  394.         elseif addressSize==4 then
  395.             if addressEndian then
  396.                 value=memory.read_s32_le(address)
  397.             else
  398.                 value=memory.read_s32_be(address)
  399.             end
  400.         end
  401.     else
  402.         if addressSize==1 then
  403.             value=memory.read_u8(address)
  404.         elseif addressSize==2 then
  405.             if addressEndian then
  406.                 value=memory.read_u16_le(address)
  407.             else
  408.                 value=memory.read_u16_be(address)
  409.             end            
  410.         elseif addressSize==3 then
  411.             if addressEndian then
  412.                 value=memory.read_u24_le(address)
  413.             else
  414.                 value=memory.read_u24_be(address)
  415.             end
  416.         elseif addressSize==4 then
  417.             if addressEndian then
  418.                 value=memory.read_u32_le(address)
  419.             else
  420.                 value=memory.read_u32_be(address)
  421.             end
  422.         end
  423.     end
  424.    
  425.     return value   
  426. end
  427.  
  428. local DisplayAddressTable = function(inputTable,table_start,table_end,offset_id,slot,xpos,ypos,has_arrows,has_buttons,display_description,description_offset,arrows_offset,buttons_offset)
  429.    
  430.     memorydomainBefore=memory.getcurrentmemorydomain()
  431.     tableEntries=table.getn(inputTable)
  432.     table_iterations = 1
  433.     offset=AddressTableDisplayOffset[offset_id]
  434.     list_height = 8*(table_end - table_start)+14
  435.     addressOffset=0
  436.    
  437.     --display arrows:
  438.     if has_arrows then
  439.         if (tableEntries - offset) > table_end then
  440.        
  441.             --bottom arrow button
  442.             if Mouse.X>xpos+arrows_offset and Mouse.X<xpos+arrows_offset+12 and Mouse.Y>ypos+list_height and Mouse.Y<ypos+list_height+6 then
  443.                 if Mouse.clicked and Mouse.clickedFrames%3==1 then
  444.                     AddressTableDisplayOffset[offset_id]=offset+1
  445.                 end
  446.        
  447.             arrowDown(xpos+arrows_offset+2,ypos+list_height,0xFFFFFFFF)
  448.            
  449.             else
  450.        
  451.             arrowDown(xpos+arrows_offset+2,ypos+list_height,0xA0FFFFFF)
  452.  
  453.             end
  454.            
  455.         else
  456.        
  457.             if offset < 0 then
  458.                 AddressTableDisplayOffset[offset_id]=0
  459.             end
  460.        
  461.         end
  462.            
  463.         --top arrow button
  464.         if offset > 0 then
  465.        
  466.             if Mouse.X>xpos+arrows_offset and Mouse.X<xpos+arrows_offset+12 and Mouse.Y>ypos+list_height-10 and Mouse.Y<ypos+list_height-4 then
  467.                 if Mouse.clicked and Mouse.clickedFrames%3==1 then
  468.                     AddressTableDisplayOffset[offset_id]=offset-1
  469.                 end
  470.  
  471.             arrowUp(xpos+arrows_offset+2,ypos+list_height-6,0xFFFFFFFF)
  472.                
  473.             else
  474.            
  475.             arrowUp(xpos+arrows_offset+2,ypos+list_height-6,0xA0FFFFFF)
  476.  
  477.             end
  478.            
  479.         end
  480.        
  481.     end
  482.  
  483.     --display contents of table:   
  484.    
  485.     -- applying display offset
  486.     table_start = table_start + offset
  487.     table_end   = table_end + offset
  488.                
  489.     -- going through the table
  490.     for i=table_start,table_end do --show a part of the list
  491.  
  492.         contenttype=inputTable[i][1]
  493.         description=inputTable[i][2]
  494.         textColor=inputTable[i][3]
  495.         memorydomain=inputTable[i][4]
  496.  
  497.         if contenttype==0 then  -- TITLE
  498.                
  499.             gui.drawBox(5+xpos,4+ypos+table_iterations*8,arrows_offset+xpos,12+ypos+table_iterations*8,0x00000000,0xFF505050)
  500.    
  501.         elseif contenttype==7 then -- BINARY
  502.            
  503.             memory.usememorydomain(memorydomain)
  504.             address=inputTable[i][5]+addressOffset*slot
  505.             currentbit=inputTable[i][6]
  506.             value=memory.read_u8(address)
  507.  
  508.             value=bit.check(value, currentbit)
  509.            
  510.             if value then
  511.                 value="Yes"
  512.                 valueColor=0xFF80FF80
  513.             else
  514.                 value="No"
  515.                 valueColor=0xFFFF9090
  516.             end
  517.            
  518.             text(5+xpos,3+ypos+table_iterations*8,value,valueColor)
  519.        
  520.         else    -- OTHER TYPES
  521.            
  522.             memory.usememorydomain(memorydomain)
  523.             address=inputTable[i][5]+addressOffset*slot
  524.             addressSize=inputTable[i][6]
  525.             addressEndian=inputTable[i][7] -- true:little endian, false:big endian
  526.             addressSigned=inputTable[i][11]
  527.             value=0
  528.             valueMinimum=inputTable[i][8]
  529.             valueMaximum=inputTable[i][9]
  530.             valueChangeAmount=inputTable[i][10]
  531.  
  532.             if valueChangeAmount==nil then
  533.                 valueChangeAmount=1
  534.             end
  535.            
  536.             if valueMinimum==nil then
  537.                 valueMinimum=-1
  538.             end
  539.            
  540.             if valueMaximum==nil then
  541.                 valueMaximum=-1
  542.             end
  543.                                  
  544.             if contenttype==6 then  -- show value as timer (framecount --> clock time)
  545.                 value = addressTableGetValue(address,addressSize,addressEndian, addressSigned)
  546.                 text(5+xpos,3+ypos+table_iterations*8,totime(value,60), textColor)         
  547.             elseif contenttype==8 then -- show value as timer (min,sec,ms --> clock time)
  548.                 minutes=    memory.read_u8(address)
  549.                 seconds=    memory.read_u8(address+1)
  550.                 ms=         memory.read_u8(address+2)          
  551.                 value = minutes*3600 + seconds*60 + ms
  552.                 text(5+xpos,3+ypos+table_iterations*8,totime(value,60), textColor)
  553.             elseif contenttype==2 then -- direction            
  554.                 local directionTable={[0]="Up",[1]="Upright",[2]="Right",[3]="Downright",[4]="Down",[5]="Downleft",[6]="Left",[7]="Leftup"}
  555.                 value = addressTableGetValue(address,addressSize,addressEndian, addressSigned)
  556.                 itemText = directionTable[value]
  557.                 text(5+xpos,3+ypos+table_iterations*8,itemText,textColor)  
  558.             else                    -- show value as is
  559.                 value = addressTableGetValue(address,addressSize,addressEndian, addressSigned)
  560.                 text(5+xpos,3+ypos+table_iterations*8,value, textColor)
  561.             end
  562.            
  563.         end
  564.        
  565.         if display_description then
  566.             text(xpos+description_offset,3+ypos+table_iterations*8,description, textColor)
  567.         end
  568.  
  569.         if has_buttons then
  570.            
  571.             if contenttype==7 then -- binary
  572.            
  573.                 drawButton(xpos+buttons_offset,4+ypos+table_iterations*8,21,8,"Set",Color.Normal,8,function()
  574.    
  575.                     currentvalue=memory.read_u8(address)
  576.  
  577.                     if bit.check(currentvalue,currentbit) then
  578.                         memory.write_u8(address, bit.clear(currentvalue,currentbit))
  579.                     else
  580.                         memory.write_u8(address, bit.set(currentvalue,currentbit)) 
  581.                     end
  582.                
  583.                 end)
  584.            
  585.             elseif contenttype==8 then -- min,sec,ms timer
  586.                
  587.                     if value > valueMinimum
  588.                     or valueMininum==-1 then
  589.                         drawButton(xpos+buttons_offset,4+ypos+table_iterations*8,9,8,"-",Color.Normal,5,function()
  590.  
  591.                             valueChangeAmount = getChangeAmount(valueChangeAmount) -- increases when holding mouse key
  592.                            
  593.                             newvalue = value - valueChangeAmount
  594.                            
  595.                             if valueMinimum~=-1 then
  596.                                 if newvalue < valueMinimum then
  597.                                     newvalue=valueMinimum
  598.                                 elseif newvalue > valueMaximum then
  599.                                     newvalue=valueMaximum
  600.                                 end
  601.                             end
  602.                            
  603.                             minutes=math.floor(newvalue/3600)
  604.                             seconds=math.floor((newvalue-minutes*3600)/60)
  605.                             ms=math.floor(newvalue-minutes*3600-seconds*60)
  606.                            
  607.                             memory.write_u8(address, minutes)
  608.                             memory.write_u8(address+1, seconds)
  609.                             memory.write_u8(address+2, ms)     
  610.                            
  611.                         end)
  612.                     end
  613.            
  614.                     if value < valueMaximum
  615.                     or valueMaximum==-1 then
  616.                         drawButton(12+xpos+buttons_offset,4+ypos+table_iterations*8,9,8,"+",Color.Normal,5,function()
  617.    
  618.                             valueChangeAmount = getChangeAmount(valueChangeAmount) -- increases when holding mouse key
  619.                            
  620.                             newvalue = value + valueChangeAmount
  621.                            
  622.                             if valueMinimum~=-1 then
  623.                                 if newvalue < valueMinimum then
  624.                                     newvalue=valueMinimum
  625.                                 elseif newvalue > valueMaximum then
  626.                                     newvalue=valueMaximum
  627.                                 end
  628.                             end
  629.                            
  630.                             minutes=math.floor(newvalue/3600)
  631.                             seconds=math.floor((newvalue-minutes*3600)/60)
  632.                             ms=math.floor(newvalue-minutes*3600-seconds*60)
  633.                            
  634.                             memory.write_u8(address, minutes)
  635.                             memory.write_u8(address+1, seconds)
  636.                             memory.write_u8(address+2, ms) 
  637.                            
  638.                         end)
  639.                     end
  640.            
  641.             elseif contenttype~=0 then -- normal values
  642.            
  643.                 if value > valueMinimum
  644.                 or valueMinimum==-1 then
  645.                     drawButton(xpos+buttons_offset,4+ypos+table_iterations*8,9,8,"-",Color.Normal,5,function()
  646.                    
  647.                         valueChangeAmount = getChangeAmount(valueChangeAmount) -- increases when holding mouse key 
  648.                        
  649.                         newvalue = value - valueChangeAmount
  650.                        
  651.                         if valueMinimum ~= -1 then
  652.                             if newvalue < valueMinimum then
  653.                                 newvalue=valueMinimum
  654.                             elseif newvalue > valueMaximum then
  655.                                 newvalue=valueMaximum
  656.                             end
  657.                         end
  658.                        
  659.                         addressTableSetValue(address,addressSize,addressEndian,newvalue)
  660.                        
  661.                     end)
  662.                 end
  663.                
  664.                 if value < valueMaximum
  665.                 or valueMaximum==-1 then
  666.                     drawButton(12+xpos+buttons_offset,4+ypos+table_iterations*8,9,8,"+",Color.Normal,5,function()
  667.                    
  668.                         valueChangeAmount = getChangeAmount(valueChangeAmount) -- increases when holding mouse key
  669.                        
  670.                         newvalue = value + valueChangeAmount
  671.                        
  672.                         if valueMinimum~=-1 then
  673.                             if newvalue < valueMinimum then
  674.                                 newvalue=valueMinimum
  675.                             elseif newvalue > valueMaximum then
  676.                                 newvalue=valueMaximum
  677.                             end
  678.                         end
  679.                        
  680.                         addressTableSetValue(address,addressSize,addressEndian,newvalue)
  681.                        
  682.                     end)
  683.                 end
  684.            
  685.             end
  686.                
  687.         end
  688.        
  689.         table_iterations=table_iterations+1
  690.        
  691.     end
  692.    
  693.     memory.usememorydomain(memorydomainBefore)
  694. end
  695.  
  696. local drawWin1 = function() -- general
  697.  
  698.     win1x=Settings["win1x"]
  699.     win1y=Settings["win1y"]
  700.     width=138
  701.     height=90
  702.  
  703.     drawDisplayBox(win1x, win1y, "win1x","win1y",width, height, 0xFF202020,0xA0000000)
  704.    
  705.     if DisplayEditMode["win1"] then
  706.         DisplayAddressTable(AddressTableGeneral,1,2,"win1",0,win1x,win1y,true,true,true,72,124,46) 
  707.     else
  708.         DisplayAddressTable(AddressTableGeneral,1,2,"win1",0,win1x,win1y,true,false,true,56,124,0)
  709.     end
  710.    
  711.     drawCloseButton(win1x,win1y,width,"Boolwin1",function()
  712.     end)
  713.    
  714.     if DisplayEditMode["win1"] then
  715.         editButtonCol = Color.Selected
  716.     else
  717.         editButtonCol = Color.Normal
  718.     end
  719.     drawEditButton(win1x,win1y,width,editButtonCol,false,"win1")
  720.    
  721.     text(win1x+3,win1y-1,"General Memory",0xFF808080)
  722.  
  723. end
  724.  
  725. local drawWin2 = function() -- kirby
  726.  
  727.     win2x=Settings["win2x"]
  728.     win2y=Settings["win2y"]
  729.     width=150
  730.     height=74
  731.  
  732.     drawDisplayBox(win2x, win2y, "win2x","win2y",width, height, 0xFF202020,0xA0000000)
  733.    
  734.     if DisplayEditMode["win2"] then
  735.         DisplayAddressTable(AddressTableKirby,1,7,"win2",0,win2x,win2y,true,true,true,72,136,46)   
  736.     else
  737.         DisplayAddressTable(AddressTableKirby,1,7,"win2",0,win2x,win2y,true,false,true,56,136,0)
  738.     end
  739.    
  740.     drawCloseButton(win2x,win2y,width,"Boolwin2",function()
  741.     end)
  742.    
  743.     if DisplayEditMode["win2"] then
  744.         editButtonCol = Color.Selected
  745.     else
  746.         editButtonCol = Color.Normal
  747.     end
  748.     drawEditButton(win2x,win2y,width,editButtonCol,false,"win2")
  749.    
  750.     text(win2x+3,win2y-1,"Kirby",0xFF808080)
  751.  
  752. end
  753.  
  754. local drawWin4 = function() -- yellow
  755.  
  756.     win4x=Settings["win4x"]
  757.     win4y=Settings["win4y"]
  758.     width=150
  759.     height=82
  760.  
  761.     drawDisplayBox(win4x, win4y, "win4x","win4y",width, height, 0xFF202020,0xA0000000)
  762.    
  763.     if DisplayEditMode["win4"] then
  764.         DisplayAddressTable(AddressTableYellow,1,8,"win4",0,win4x,win4y,true,true,true,72,136,46)  
  765.     else
  766.         DisplayAddressTable(AddressTableYellow,1,8,"win4",0,win4x,win4y,true,false,true,56,136,0)
  767.     end
  768.    
  769.     drawCloseButton(win4x,win4y,width,"Boolwin4",function()
  770.     end)
  771.    
  772.     if DisplayEditMode["win4"] then
  773.         editButtonCol = Color.Selected
  774.     else
  775.         editButtonCol = Color.Normal
  776.     end
  777.     drawEditButton(win4x,win4y,width,editButtonCol,false,"win4")
  778.    
  779.     text(win4x+3,win4y-1,"Yellow",0xFF808080)
  780.  
  781. end
  782.  
  783. local drawWin5 = function() -- red
  784.  
  785.     win5x=Settings["win5x"]
  786.     win5y=Settings["win5y"]
  787.     width=150
  788.     height=82
  789.  
  790.     drawDisplayBox(win5x, win5y, "win5x","win5y",width, height, 0xFF202020,0xA0000000)
  791.    
  792.     if DisplayEditMode["win5"] then
  793.         DisplayAddressTable(AddressTableRed,1,8,"win5",0,win5x,win5y,true,true,true,72,136,46) 
  794.     else
  795.         DisplayAddressTable(AddressTableRed,1,8,"win5",0,win5x,win5y,true,false,true,56,136,0)
  796.     end
  797.    
  798.     drawCloseButton(win5x,win5y,width,"Boolwin5",function()
  799.     end)
  800.    
  801.     if DisplayEditMode["win5"] then
  802.         editButtonCol = Color.Selected
  803.     else
  804.         editButtonCol = Color.Normal
  805.     end
  806.     drawEditButton(win5x,win5y,width,editButtonCol,false,"win5")
  807.    
  808.     text(win5x+3,win5y-1,"Red",0xFF808080)
  809.  
  810. end
  811.  
  812. local drawWin6 = function() -- green
  813.  
  814.     win6x=Settings["win6x"]
  815.     win6y=Settings["win6y"]
  816.     width=150
  817.     height=82
  818.  
  819.     drawDisplayBox(win6x, win6y, "win6x","win6y",width, height, 0xFF202020,0xA0000000)
  820.    
  821.     if DisplayEditMode["win6"] then
  822.         DisplayAddressTable(AddressTableGreen,1,8,"win6",0,win6x,win6y,true,true,true,72,136,46)   
  823.     else
  824.         DisplayAddressTable(AddressTableGreen,1,8,"win6",0,win6x,win6y,true,false,true,56,136,0)
  825.     end
  826.    
  827.     drawCloseButton(win6x,win6y,width,"Boolwin6",function()
  828.     end)
  829.    
  830.     if DisplayEditMode["win6"] then
  831.         editButtonCol = Color.Selected
  832.     else
  833.         editButtonCol = Color.Normal
  834.     end
  835.     drawEditButton(win6x,win6y,width,editButtonCol,false,"win6")
  836.    
  837.     text(win6x+3,win6y-1,"Kirby",0xFF808080)
  838.  
  839. end
  840.  
  841. Enemies = {}
  842.  
  843. HelperKirby = {
  844.     [1]={"Yellow",0xFFFFE060},
  845.     [2]={"Red",0xFFFF9090},
  846.     [3]={"Green",0xFFC0FF80}
  847. }
  848.  
  849. local drawEnemies = function()  -- Enemies
  850.  
  851.     local color,subcolor,verticalOffset=0
  852.     local info=""
  853.  
  854.     if frames%7==0 then
  855.         count=1
  856.         Enemies = {}
  857.         memory.usememorydomain("EWRAM")
  858.         for i=0x000,0x700,0x1 do
  859.             if memory.read_u32_le(i)== 0x1FFFFFF then
  860.                 if memory.read_u8(i-1) ~= 255 then
  861.                     Enemies[count]=i
  862.                     count=count+1
  863.                 end
  864.             end
  865.         end
  866.     end
  867.  
  868.     enemyTableSize = table.getn(Enemies)
  869.     cameraX = memory.read_u16_le(0x23660)
  870.     cameraY = memory.read_u16_le(0x23662)
  871.  
  872.     if enemyTableSize>0 then
  873.         memory.usememorydomain("EWRAM")
  874.         for s=1,enemyTableSize do
  875.  
  876.             offset = Enemies[s]
  877.             extrainfo=""
  878.            
  879.             status       = memory.read_u8(offset+0x32)
  880.             enemyX       = memory.read_u24_le(offset+0x44)
  881.             enemyY       = memory.read_u24_le(offset+0x48)
  882.             hitboxX      = memory.read_s8(offset+0x3B)
  883.             hitboxY      = memory.read_s8(offset+0x3C)
  884.             width  = memory.read_s8(offset+0x3D)
  885.             height = memory.read_s8(offset+0x3E)
  886.             heldAliveBy = memory.read_s8(offset+0x59)
  887.             ID = memory.read_u8(offset+0x85)
  888.             health = memory.read_u8(offset+0x83)
  889.             x=enemyX-cameraX+hitboxX    -- screen x
  890.             y=enemyY-cameraY+hitboxY    -- screen y
  891.             x2=x+width*2
  892.             y2=y+height*2
  893.             x3=x+width      -- center
  894.  
  895.             if Mouse.X > x-4 and Mouse.X < x2+4 and Mouse.Y > y-4 and Mouse.Y < y2+4 then
  896.                 color = 0xFFFFC020
  897.                 subcolor = 0x80000000
  898.                 verticalOffset = -36
  899.                 info = health .. " HP\n" ..enemyX .. " X\n" ..enemyY .. " Y"       
  900.             else
  901.                 color = 0xFF00FFFF
  902.                 subcolor = 0x80000000
  903.                 verticalOffset = -13
  904.                 info = health .. " HP"
  905.             end
  906.            
  907.             if status==0 then
  908.                 color=color - 0x80000000
  909.                 subcolor=subcolor - 0x40000000
  910.                 if HelperKirby[heldAliveBy] ~= nil then
  911.                     text(x3-8,y2+2,">" .. HelperKirby[heldAliveBy][1],HelperKirby[heldAliveBy][2],subcolor) -- extra information
  912.                 end
  913.             end
  914.            
  915.             --  text(x3-8,y-25,s .. " " .. string.format("%x",offset),color,0x80000000)
  916.             text(x3-8,y+verticalOffset,info,color,subcolor) -- information
  917.             gui.drawBox(x,y,x2,y2,color) -- hitbox rectangle
  918.        
  919.         end
  920.     end
  921.     text(190,0,"loaded: " .. enemyTableSize .. "  ." ,0xFFFFFF00,0x80000000)               
  922. end
  923.  
  924. local drawWin3 = function() -- flags
  925.  
  926.     win3x=Settings["win3x"]
  927.     win3y=Settings["win3y"]
  928.     width=140
  929.     height=90
  930.  
  931.     drawDisplayBox(win3x, win3y, "win3x","win3y",width, height, 0xFF202020,0xA0000000)
  932.    
  933.     if DisplayEditMode["win3"] then
  934.         DisplayAddressTable(AddressTableFlags,1,9,"win3",0,win3x,win3y,true,true,true,56,126,32)   
  935.     else
  936.         DisplayAddressTable(AddressTableFlags,1,9,"win3",0,win3x,win3y,true,false,true,36,126,0)
  937.     end
  938.  
  939.     drawCloseButton(win3x,win3y,width,"Boolwin3",function()
  940.     end)
  941.    
  942.     if DisplayEditMode["win3"] then
  943.         editButtonCol = Color.Selected
  944.     else
  945.         editButtonCol = Color.Normal
  946.     end
  947.     drawEditButton(win3x,win3y,width,editButtonCol,false,"win3")
  948.    
  949.     text(win3x+3,win3y-1,"Flags",0xFF808080)
  950.  
  951. end
  952.  
  953. local Menu = {
  954.                    --display name, col, indicator, drawindicator,  works in prototype?, openingfunction, closingfunction
  955.     [1] =       {   [0] = "Memory",
  956.                     [1] = {"Kirby",     0xFFFFB0C0, true,   "Boolwin2", true,   nil,nil},
  957.                     [2] = {"Yellow",    0xFFFFE060, true,   "Boolwin4", true,   nil,nil},
  958.                     [3] = {"Red",       0xFFFF9090, true,   "Boolwin5", true,   nil,nil},
  959.                     [4] = {"Green",     0xFFC0FF80, true,   "Boolwin6", true,   nil,nil},
  960.                     [5] = {"General",   0xFFFFE0A0, true,   "Boolwin1", true,   nil,nil},
  961.                     [6] = {"Flags",     0xFFFFE0A0, true,   "Boolwin3", true,   nil,nil},
  962.                     [7] = {"Enemies",   0xFFFFE0A0, true,   "Boolwin7", true,   nil,nil},
  963.                 }
  964. }
  965.  
  966. local drawMenu = function()
  967.  
  968.     verticalOffset=0
  969.  
  970.     for a=1,table.getn(Menu),1 do
  971.         drawMenuButton(-40+a*45,20,45,11,Menu[a][0],2,false,true,0xFFFFFFFF,function()
  972.             menuscreen=a
  973.         end)   
  974.        
  975.         if menuscreen==a then
  976.            
  977.             for b=1,table.getn(Menu[a]),1 do
  978.            
  979.                 title           = Menu[a][b][1]
  980.                 col             = Menu[a][b][2]
  981.                 drawindicator   = Menu[a][b][3]
  982.                 settingtext     = Menu[a][b][4]
  983.                 worksInBeta     = Menu[a][b][5]
  984.                 openingfunction = Menu[a][b][6]
  985.                 closingfunction = Menu[a][b][7]
  986.                 indicator       = false
  987.                 if type(settingtext)=="string" then
  988.                     indicator = Settings[settingtext]
  989.                 else
  990.                     indicator = settingtext
  991.                 end
  992.  
  993.                     drawMenuButton(5,34+verticalOffset*10,80,10,title,1,drawindicator,indicator,col,function()
  994.  
  995.                         if not indicator and not drawindicator then -- not added yet
  996.                        
  997.                             Mouse.clickedFrames=2
  998.                             extrascreen=4
  999.                            
  1000.                         else -- open/close the display
  1001.                            
  1002.                             --custom functions
  1003.                             if indicator then
  1004.                                 if closingfunction ~= nil then
  1005.                                     closingfunction()
  1006.                                 end
  1007.                             else
  1008.                                 if openingfunction ~= nil then
  1009.                                     openingfunction()
  1010.                                 end
  1011.                             end
  1012.                            
  1013.                             --setting the setting boolean
  1014.                             if type(settingtext)=="string" then
  1015.                                 Settings[settingtext] = not indicator
  1016.                             end        
  1017.                            
  1018.                         end
  1019.  
  1020.                     end)
  1021.                    
  1022.                     verticalOffset=verticalOffset+1
  1023.                
  1024.             end
  1025.                
  1026.         end
  1027.     end
  1028.    
  1029.     if Mouse.clicked and Mouse.clickedFrames==1 then
  1030.            menuscreen = 0
  1031.     end
  1032. end
  1033.  
  1034. menuscreen=0
  1035. frames=0
  1036. console.clear()
  1037. for i=1,table.getn(ScriptInfo),1 do
  1038.     print(ScriptInfo[i])
  1039. end
  1040.  
  1041. while true do
  1042.  
  1043.     Mouse.X = input.getmouse().X
  1044.     Mouse.Y = input.getmouse().Y
  1045.     Mouse.clicked = input.getmouse().Left
  1046.    
  1047.     if Settings["Boolwin7"] then drawEnemies() end
  1048.     if Settings["Boolwin1"] then drawWin1() end
  1049.     if Settings["Boolwin2"] then drawWin2() end
  1050.     if Settings["Boolwin3"] then drawWin3() end
  1051.     if Settings["Boolwin4"] then drawWin4() end
  1052.     if Settings["Boolwin5"] then drawWin5() end
  1053.     if Settings["Boolwin6"] then drawWin6() end
  1054.     drawMenu()
  1055.  
  1056.     Mouse.XBefore=Mouse.X -- update mouse
  1057.     Mouse.YBefore=Mouse.Y
  1058.     if Mouse.clicked then Mouse.clickedFrames = Mouse.clickedFrames + 1
  1059.     else Mouse.clickedFrames = 0 end
  1060.    
  1061.    if client.ispaused() then
  1062.         gui.DrawFinish()
  1063.         emu.yield()
  1064.     else
  1065.         emu.frameadvance()
  1066.     end
  1067.    
  1068.     frames=frames+1
  1069.  
  1070. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement