Advertisement
Guest User

katam lua 0.1

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