Advertisement
Guest User

katam lua 0.2

a guest
Oct 3rd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.82 KB | None | 0 0
  1. local ScriptInfo = {"KATAM Luascript by Mugg1991",
  2.                     "v0.2",
  3.                     "3rd Oct 2017",}
  4. --[[
  5.     v0.1
  6.     - Initial release
  7.     v0.1.1
  8.     - Fixed that the hitbox display wouldn't work.
  9.     v0.2
  10.     - Improved hitbox display, more performance and actually displaying all the slots.
  11.     - Improved code.
  12. ]]
  13.  
  14. local AddressTableGeneral= {
  15. [1] = {1,"Camera X",0xFFFFE0A0,"EWRAM",0x23660,2,true,nil,nil,nil},
  16. [2] = {1,"Camera Y",0xFFFFE0A0,"EWRAM",0x23662,2,true,nil,nil,nil},
  17. [3] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil},
  18. [4] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil},
  19. [5] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil},
  20. [6] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil}
  21. }
  22.  
  23. local AddressTableFlags= {
  24. [1] = {0,"Mirror Shards",0xFFB0B0B0},  
  25. [2] = {7,"Kracko",0xFFFFE0A0,"EWRAM",0x38970,0,true,nil,nil,nil},
  26. [3] = {7,"King Golem",0xFFFFE0A0,"EWRAM",0x38970,1,true,nil,nil,nil},
  27. [4] = {7,"Master Hand",0xFFFFE0A0,"EWRAM",0x38970,2,true,nil,nil,nil},
  28. [5] = {7,"Gobbler",0xFFFFE0A0,"EWRAM",0x38970,3,true,nil,nil,nil},
  29. [6] = {7,"Wiz",0xFFFFE0A0,"EWRAM",0x38970,4,true,nil,nil,nil},
  30. [7] = {7,"Moley",0xFFFFE0A0,"EWRAM",0x38970,5,true,nil,nil,nil},
  31. [8] = {7,"Mega Titan",0xFFFFE0A0,"EWRAM",0x38970,6,true,nil,nil,nil},
  32. [9] = {7,"D. Metaknight",0xFFFFE0A0,"EWRAM",0x38970,7,true,nil,nil,nil},
  33.  
  34. [10] = {0,"Misc",0xFFB0B0B0},  
  35. [11] = {7,"Ability Room",0xFFFFE0A0,"EWRAM",0x28C58,0,true,nil,nil,nil},
  36.  
  37. [12] = {0,"Area 1",0xFFB0B0B0},        
  38. [13] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C18,0,true,nil,nil,nil},
  39. [14] = {7,"Big Chest",0xFFFFE0A0,"EWRAM",0x38960,5,true,nil,nil,nil},
  40. [15] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38960,3,true,nil,nil,nil},
  41. [16] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38961,0,true,nil,nil,nil},
  42. [17] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38961,1,true,nil,nil,nil},
  43.  
  44. [18] = {0,"Area 2",0xFFB0B0B0},    
  45. [19] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C14,0,true,nil,nil,nil},
  46. [20] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38962,2,true,nil,nil,nil},  
  47. [21] = {7,"Big Chest",0xFFFFE0A0,"EWRAM",0x38961,7,true,nil,nil,nil},
  48. [22] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38962,1,true,nil,nil,nil},
  49.  
  50. [23] = {0,"Area 3",0xFFB0B0B0},    
  51. [24] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C28,0,true,nil,nil,nil},
  52. [25] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C24,0,true,nil,nil,nil},
  53.  
  54. [26] = {0,"Area 4",0xFFB0B0B0},    
  55. [27] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C44,0,true,nil,nil,nil},
  56. [28] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C4C,0,true,nil,nil,nil},   
  57.  
  58. [29] = {0,"Area 5",0xFFB0B0B0},
  59. [30] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C34,0,true,nil,nil,nil},
  60. [31] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C38,0,true,nil,nil,nil},
  61. [32] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38969,5,true,nil,nil,nil},      
  62.  
  63. [33] = {0,"Area 6",0xFFB0B0B0},    
  64. [34] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C1C,0,true,nil,nil,nil},
  65. [35] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C20,0,true,nil,nil,nil},
  66. [36] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38968,1,true,nil,nil,nil},
  67.  
  68. [37] = {0,"Area 7",0xFFB0B0B0},
  69. [38] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C3C,0,true,nil,nil,nil},
  70. [39] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C40,0,true,nil,nil,nil},       
  71.  
  72. [40] = {0,"Area 8",0xFFB0B0B0},
  73. [41] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C2C,0,true,nil,nil,nil},
  74. [42] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C30,0,true,nil,nil,nil},   
  75. [43] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38969,2,true,nil,nil,nil},  
  76.  
  77. [44] = {0,"Area 9",0xFFB0B0B0},
  78. [45] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C48,0,true,nil,nil,nil},   
  79. }
  80.  
  81. local AddressTableKirby= {
  82. [1] = {1,"X",0xFFFFB0C0,"EWRAM",0x020F20,4,true,nil,nil,nil,false},
  83. [2] = {1,"Y",0xFFFFB0C0,"EWRAM",0x020F24,4,true,nil,nil,nil,false},
  84. [3] = {1,"X Speed",0xFFFFB0C0,"EWRAM",0x020F30,2,true,nil,nil,nil,true},
  85. [4] = {1,"Y Speed",0xFFFFB0C0,"EWRAM",0x020F32,2,true,nil,nil,nil,true},
  86. [5] = {1,"Ability",0xFFFFB0C0,"EWRAM",0x020FE3,1,true,0,26,1,false},
  87. [6] = {1,"Health",0xFFFFB0C0,"EWRAM",0x020FE0,1,true,0,255,1,false},
  88. [7] = {1,"Max Health",0xFFFFB0C0,"EWRAM",0x020FE1,1,true,0,255,1,false},
  89. [8] = {1,"Lives",0xFFFFB0C0,"EWRAM",0x020FE2,1,true,0,255,1,false},
  90. [9] = {1,"Phone Battery",0xFFFFB0C0,"EWRAM",0x020FBC,1,true,0,255,1,false},
  91. [10] = {1,"Room",0xFFFFB0C0,"EWRAM",0x020FE6,2,true,101,970,1,false}
  92. }
  93.  
  94. local AddressTableYellow= {
  95. [1] = {1,"X",0xFFFFE060,"EWRAM",0x0210C8,4,true,nil,nil,nil,false},
  96. [2] = {1,"Y",0xFFFFE060,"EWRAM",0x0210CC,4,true,nil,nil,nil,false},
  97. [3] = {1,"X Speed",0xFFFFE060,"EWRAM",0x0210D8,2,true,nil,nil,nil,true},
  98. [4] = {1,"Y Speed",0xFFFFE060,"EWRAM",0x0210DA,2,true,nil,nil,nil,true},
  99. [5] = {1,"Ability",0xFFFFE060,"EWRAM",0x02118B,1,true,0,26,1,false},
  100. [6] = {1,"Health",0xFFFFE060,"EWRAM",0x021188,1,true,0,255,1,false},
  101. [7] = {1,"Max Health",0xFFFFE060,"EWRAM",0x021189,1,true,0,255,1,false},
  102. [8] = {1,"Room",0xFFFFE060,"EWRAM",0x02118E,2,true,101,970,1,false}
  103. }
  104.  
  105. local AddressTableRed= {
  106. [1] = {1,"X",0xFFFF9090,"EWRAM",0x021270,4,true,nil,nil,nil,false},
  107. [2] = {1,"Y",0xFFFF9090,"EWRAM",0x021274,4,true,nil,nil,nil,false},
  108. [3] = {1,"X Speed",0xFFFF9090,"EWRAM",0x021280,2,true,nil,nil,nil,true},
  109. [4] = {1,"Y Speed",0xFFFF9090,"EWRAM",0x021282,2,true,nil,nil,nil,true},
  110. [5] = {1,"Ability",0xFFFF9090,"EWRAM",0x021333,1,true,0,26,1,false},
  111. [6] = {1,"Health",0xFFFF9090,"EWRAM",0x021330,1,true,0,255,1,false},
  112. [7] = {1,"Max Health",0xFFFF9090,"EWRAM",0x021331,1,true,0,255,1,false},
  113. [8] = {1,"Room",0xFFFF9090,"EWRAM",0x021336,2,true,101,970,1,false}
  114. }
  115.  
  116. local AddressTableGreen= {
  117. [1] = {1,"X",0xFFC0FF80,"EWRAM",0x021418,4,true,nil,nil,nil,false},
  118. [2] = {1,"Y",0xFFC0FF80,"EWRAM",0x02141C,4,true,nil,nil,nil,false},
  119. [3] = {1,"X Speed",0xFFC0FF80,"EWRAM",0x021428,2,true,nil,nil,nil,true},
  120. [4] = {1,"Y Speed",0xFFC0FF80,"EWRAM",0x02142A,2,true,nil,nil,nil,true},
  121. [5] = {1,"Ability",0xFFC0FF80,"EWRAM",0x0214DB,1,true,0,26,1,false},
  122. [6] = {1,"Health",0xFFC0FF80,"EWRAM",0x0214D8,1,true,0,255,1,false},
  123. [7] = {1,"Max Health",0xFFC0FF80,"EWRAM",0x0214D9,1,true,0,255,1,false},
  124. [8] = {1,"Room",0xFFC0FF80,"EWRAM",0x0214DE,2,true,101,970,1,false}
  125. }
  126.  
  127. local Displays = {
  128.     -- Name, active, col, x, y, width, height, offset of list, edit mode, table, entries shown
  129.     [1]= {"General", false, 0xFFFFE0A0, 40, 40, 146, 34, 0, false, AddressTableGeneral,2},
  130.     [2]= {"Kirby", false, 0xFFFFB0C0, 40, 40, 146, 66, 0, false, AddressTableKirby,6},
  131.     [3]= {"Yellow", false, 0xFFFFE060, 40, 40, 146, 66, 0, false, AddressTableYellow,6},
  132.     [4]= {"Red", false, 0xFFFF9090, 40, 40, 146, 66, 0, false, AddressTableRed,6},
  133.     [5]= {"Green", false, 0xFFC0FF80, 40, 40, 146, 66, 0, false, AddressTableGreen,6},
  134.     [6]= {"Flags", false, 0xFFFFE0A0, 40, 40, 146, 82, 0, false, AddressTableFlags,8},
  135.     [7]= {"Enemies", false, 0xFFFFE0A0, nil}
  136. }
  137.  
  138. Enemies = {}
  139.  
  140. HelperKirby = {
  141.     [1]={"Yellow",0xFFFFE060},
  142.     [2]={"Red",0xFFFF9090},
  143.     [3]={"Green",0xFFC0FF80}
  144. }
  145.  
  146. local Mouse = {
  147.     X               = 0,
  148.     Y               = 0,
  149.     XBefore         = 0,
  150.     YBefore         = 0,
  151.     clickedFrames   = 0,
  152.     clicked         = false
  153. }
  154.  
  155. local Color = {
  156.     Selected    = 0xB0A0A0A0,
  157.     Normal      = 0xA0303030,
  158.     Grey        = 0xA0C0C0C0
  159. }
  160.  
  161. function text(x, y, text, color, backcolor)
  162.     if backcolor==nil then backcolor=0x00000000 end
  163.     gui.drawText(x, y, text,color,backcolor,10,"Arial")
  164. end
  165.  
  166. function box(x,y,x2,y2)
  167.     gui.drawBox(x,y,x2,y2,0x00000000,0xD0000000)
  168. end
  169.  
  170. function boxNormal(x,y,x2,y2)
  171.     gui.drawBox(x,y,x2,y2,0xFF000000,0xA0000000)
  172. end
  173.  
  174. function boxSelected(x,y,x2,y2)
  175.     gui.drawBox(x,y,x2,y2,0xFF000000,0xA0505050)
  176. end
  177.  
  178. function arrowDown(xpos,ypos,col)
  179.     gui.drawLine(xpos,ypos,xpos+6,ypos,col)
  180.     gui.drawLine(xpos+1,ypos+1,xpos+5,ypos+1,col)
  181.     gui.drawLine(xpos+2,ypos+2,xpos+4,ypos+2,col)
  182.     gui.drawPixel(xpos+3,ypos+3,col)
  183. end
  184.  
  185. function arrowUp(xpos,ypos,col)
  186.     gui.drawLine(xpos,ypos,xpos+6,ypos,col)
  187.     gui.drawLine(xpos+1,ypos-1,xpos+5,ypos-1,col)
  188.     gui.drawLine(xpos+2,ypos-2,xpos+4,ypos-2,col)
  189.     gui.drawPixel(xpos+3,ypos-3,col)
  190. end
  191.  
  192. function drawDisplayBox(id,bordercolor,color)
  193.     posx=Displays[id][4]
  194.     posy=Displays[id][5]
  195.     width=Displays[id][6]
  196.     height=Displays[id][7]
  197.    
  198.     if Mouse.clicked then
  199.  
  200.         if Mouse.X > posx and Mouse.X < posx+width and Mouse.Y > posy and Mouse.Y < posy+height then
  201.  
  202.             if Mouse.clickedFrames > 0 then
  203.                 menuscreen=0 -- close menu
  204.                
  205.                 posy = posy + (Mouse.Y-Mouse.YBefore) -- enables mouse drag
  206.                 posx = posx + (Mouse.X-Mouse.XBefore)
  207.  
  208.                 if posy < 0 then posy=0 -- prevents display from going offscreen
  209.                 elseif posy > 159-height then posy=159-height end
  210.                 if posx < 0 then posx=0
  211.                 elseif posx > 239-width then posx=239-width end
  212.            
  213.                 Displays[id][4]=posx
  214.                 Displays[id][5]=posy
  215.             end
  216.         end
  217.     end
  218.     gui.drawBox(posx,posy,posx+width,posy+height,bordercolor,color)
  219.     text(posx+3,posy-1,Displays[id][1],0xFF808080)
  220. end
  221.        
  222. function drawCloseButton(id)
  223.     width=Displays[id][6]
  224.     x=Displays[id][4]
  225.     y=Displays[id][5]
  226.    
  227.     drawButton(x+width-10,y,10,10,"x",Color.Grey,15,function()
  228.         Displays[id][2] = false
  229.     end)
  230. end
  231.  
  232. function drawEditButton(id)
  233.  
  234.     width=Displays[id][6]
  235.     x=Displays[id][4]
  236.     y=Displays[id][5]
  237.     if Displays[id][9] then col=Color.Selected
  238.     else col=Color.Normal end
  239.    
  240.     drawButton(x+width-25,y,12,10,"e",col,15,function()
  241.         Displays[id][9]=not Displays[id][9]
  242.     end)
  243. end
  244.  
  245. function drawButton(posx,posy,width,height,label,color,frequency,clickedfunction)
  246.     if Mouse.X>posx and Mouse.X<posx+width and Mouse.Y>posy and Mouse.Y<posy+height then
  247.             if Mouse.clicked and Mouse.clickedFrames%frequency==1 then  
  248.                 clickedfunction()
  249.             end
  250.         gui.drawBox(posx,posy,posx+width,posy+height,color-0x00303030,color+0x30303030)
  251.     else
  252.         gui.drawBox(posx,posy,posx+width,posy+height,color-0x00303030,color)
  253.     end
  254.     text(posx+1,posy-2,label,0xFFFFFFFF)
  255. end
  256.  
  257. function drawMenuButton(posx,posy,width,height,label,z,drawindicator,indicator,col,clickedfunction)
  258.     if Mouse.X>posx and Mouse.X<posx+width and Mouse.Y>posy and Mouse.Y<posy+height then
  259.         if Mouse.clicked and Mouse.clickedFrames==z then
  260.             menuscreen=0
  261.             clickedfunction()
  262.         end
  263.         boxSelected(posx,posy,posx+width,posy+height)
  264.     else
  265.         boxNormal(posx,posy,posx+width,posy+height)
  266.     end
  267.     text(posx+2,posy-1,label,col)
  268.    
  269.     if drawindicator then
  270.         if indicator then text(posx+width-10,posy,"o",0xFF80FF80)
  271.         else text(posx+width-10,posy-1,"x",0xFFFF9090) end
  272.     end
  273. end
  274.  
  275. local getChangeAmount = function(valueChangeAmount)
  276.     if Mouse.clickedFrames>540 then
  277.         valueChangeAmount=valueChangeAmount*1000000
  278.     elseif Mouse.clickedFrames>450 then
  279.         valueChangeAmount=valueChangeAmount*100000
  280.     elseif Mouse.clickedFrames>360 then
  281.         valueChangeAmount=valueChangeAmount*10000
  282.     elseif Mouse.clickedFrames>270 then
  283.         valueChangeAmount=valueChangeAmount*1000
  284.     elseif Mouse.clickedFrames>180 then
  285.         valueChangeAmount=valueChangeAmount*100
  286.     elseif Mouse.clickedFrames>90 then
  287.         valueChangeAmount=valueChangeAmount*10
  288.     end
  289.     return valueChangeAmount
  290. end
  291.  
  292. local addressTableSetValue = function(address, addressSize, addressEndian, newvalue)
  293.  
  294.     if addressSize==1 then
  295.         memory.write_u8(address,newvalue)
  296.     elseif addressSize==2 then
  297.         if addressEndian then
  298.             memory.write_u16_le(address,newvalue)
  299.         else
  300.             memory.write_u16_be(address,newvalue)
  301.         end            
  302.     elseif addressSize==3 then
  303.         if addressEndian then
  304.             memory.write_u24_le(address,newvalue)
  305.         else
  306.             memory.write_u24_be(address,newvalue)
  307.         end
  308.     elseif addressSize==4 then
  309.         if addressEndian then
  310.             memory.write_u32_le(address,newvalue)
  311.         else
  312.             memory.write_u32_be(address,newvalue)
  313.         end
  314.     end
  315. end
  316.  
  317. local addressTableGetValue = function(address, addressSize, addressEndian, addressSigned)
  318.  
  319.     if addressSigned then
  320.         if addressSize==1 then
  321.             value=memory.read_s8(address)
  322.         elseif addressSize==2 then
  323.             if addressEndian then
  324.                 value=memory.read_s16_le(address)
  325.             else
  326.                 value=memory.read_s16_be(address)
  327.             end            
  328.         elseif addressSize==3 then
  329.             if addressEndian then
  330.                 value=memory.read_s24_le(address)
  331.             else
  332.                 value=memory.read_s24_be(address)
  333.             end
  334.         elseif addressSize==4 then
  335.             if addressEndian then
  336.                 value=memory.read_s32_le(address)
  337.             else
  338.                 value=memory.read_s32_be(address)
  339.             end
  340.         end
  341.     else
  342.         if addressSize==1 then
  343.             value=memory.read_u8(address)
  344.         elseif addressSize==2 then
  345.             if addressEndian then
  346.                 value=memory.read_u16_le(address)
  347.             else
  348.                 value=memory.read_u16_be(address)
  349.             end            
  350.         elseif addressSize==3 then
  351.             if addressEndian then
  352.                 value=memory.read_u24_le(address)
  353.             else
  354.                 value=memory.read_u24_be(address)
  355.             end
  356.         elseif addressSize==4 then
  357.             if addressEndian then
  358.                 value=memory.read_u32_le(address)
  359.             else
  360.                 value=memory.read_u32_be(address)
  361.             end
  362.         end
  363.     end
  364.    
  365.     return value   
  366. end
  367.  
  368. local DisplayAddressTable = function(display_id, has_arrows,  has_buttons,  display_description,  description_offset,  arrows_offset,  buttons_offset)
  369.    
  370.     inputTable=Displays[display_id][10]
  371.     xpos=Displays[display_id][4]
  372.     ypos=Displays[display_id][5]
  373.     memorydomainBefore=memory.getcurrentmemorydomain()
  374.     tableSize=table.getn(inputTable)
  375.     table_start=1
  376.     table_end=Displays[display_id][11]
  377.     table_iterations = 1
  378.     offset=Displays[display_id][8]
  379.     list_height = 8*(table_end - table_start)+14
  380.  
  381.     --display arrows:
  382.     if has_arrows then
  383.         --bottom arrow button
  384.         if (tableSize - offset) > table_end then
  385.             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
  386.                 if Mouse.clicked and Mouse.clickedFrames%3==1 then
  387.                     Displays[display_id][8]=offset+1
  388.                 end
  389.                 arrowDown(xpos+arrows_offset+2,ypos+list_height,0xFFFFFFFF)
  390.             else
  391.                 arrowDown(xpos+arrows_offset+2,ypos+list_height,0xA0FFFFFF)
  392.             end
  393.         else
  394.             if offset < 0 then
  395.                 Displays[display_id][8]=0
  396.             end
  397.         end
  398.            
  399.         --top arrow button
  400.         if offset > 0 then
  401.             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
  402.                 if Mouse.clicked and Mouse.clickedFrames%3==1 then
  403.                     Displays[display_id][8]=offset-1
  404.                 end
  405.                 arrowUp(xpos+arrows_offset+2,ypos+list_height-6,0xFFFFFFFF)
  406.             else
  407.                 arrowUp(xpos+arrows_offset+2,ypos+list_height-6,0xA0FFFFFF)
  408.             end
  409.         end
  410.     end
  411.     -- applying display offset
  412.     table_start = table_start + offset
  413.     table_end   = table_end + offset
  414.  
  415.     -- going through the table
  416.     for i=table_start,table_end do --show a part of the list
  417.  
  418.         contenttype=inputTable[i][1]
  419.         description=inputTable[i][2]
  420.         textColor=inputTable[i][3]
  421.         memorydomain=inputTable[i][4]
  422.        
  423.         if contenttype==0 then  -- TITLE
  424.                
  425.             gui.drawBox(5+xpos,4+ypos+table_iterations*8,arrows_offset+xpos,12+ypos+table_iterations*8,0x00000000,0xFF505050)
  426.    
  427.         elseif contenttype==7 then -- BINARY
  428.            
  429.             memory.usememorydomain(memorydomain)
  430.             address=inputTable[i][5]
  431.             currentbit=inputTable[i][6]
  432.             value=memory.read_u8(address)
  433.  
  434.             value=bit.check(value, currentbit)
  435.            
  436.             if value then
  437.                 value="Yes"
  438.                 valueColor=0xFF80FF80
  439.             else
  440.                 value="No"
  441.                 valueColor=0xFFFF9090
  442.             end
  443.            
  444.             text(5+xpos,3+ypos+table_iterations*8,value,valueColor)
  445.        
  446.         else    -- OTHER TYPES
  447.            
  448.             memory.usememorydomain(memorydomain)
  449.             address=inputTable[i][5]
  450.             addressSize=inputTable[i][6]
  451.             addressEndian=inputTable[i][7] -- true:little endian, false:big endian
  452.             addressSigned=inputTable[i][11]
  453.             value=0
  454.             valueMinimum=inputTable[i][8]
  455.             valueMaximum=inputTable[i][9]
  456.             valueChangeAmount=inputTable[i][10]
  457.  
  458.             if valueChangeAmount==nil then
  459.                 valueChangeAmount=1
  460.             end
  461.            
  462.             if valueMinimum==nil then
  463.                 valueMinimum=0
  464.             end
  465.            
  466.             if valueMaximum==nil then
  467.                 valueMaximum=256^addressSize - 1
  468.             end
  469.                                  
  470.             value = addressTableGetValue(address,addressSize,addressEndian, addressSigned)
  471.             text(5+xpos,3+ypos+table_iterations*8,value, textColor)
  472.            
  473.         end
  474.        
  475.         if display_description then
  476.             text(xpos+description_offset,3+ypos+table_iterations*8,description, textColor)
  477.         end
  478.  
  479.         if has_buttons then
  480.            
  481.             if contenttype==7 then -- binary
  482.            
  483.                 drawButton(xpos+buttons_offset,4+ypos+table_iterations*8,21,8,"Set",Color.Normal,8,function()
  484.    
  485.                     currentvalue=memory.read_u8(address)
  486.  
  487.                     if bit.check(currentvalue,currentbit) then
  488.                         memory.write_u8(address, bit.clear(currentvalue,currentbit))
  489.                     else
  490.                         memory.write_u8(address, bit.set(currentvalue,currentbit)) 
  491.                     end
  492.                
  493.                 end)
  494.            
  495.             elseif contenttype~=0 then -- normal values
  496.            
  497.                 if value > valueMinimum
  498.                 or valueMinimum==-1 then
  499.                     drawButton(xpos+buttons_offset,4+ypos+table_iterations*8,9,8,"-",Color.Normal,5,function()
  500.  
  501.                         valueChangeAmount = getChangeAmount(valueChangeAmount) -- increases when holding mouse key 
  502.                        
  503.                         newvalue = value - valueChangeAmount
  504.                        
  505.                         if valueMinimum ~= -1 then
  506.                             if newvalue < valueMinimum then
  507.                                 newvalue=valueMinimum
  508.                             elseif newvalue > valueMaximum then
  509.                                 newvalue=valueMaximum
  510.                             end
  511.                         end
  512.                         addressTableSetValue(address,addressSize,addressEndian,newvalue)                   
  513.                     end)
  514.                 end
  515.                
  516.                 if value < valueMaximum
  517.                 or valueMaximum==-1 then
  518.                     drawButton(12+xpos+buttons_offset,4+ypos+table_iterations*8,9,8,"+",Color.Normal,5,function()
  519.                    
  520.                         valueChangeAmount = getChangeAmount(valueChangeAmount) -- increases when holding mouse key
  521.                        
  522.                         newvalue = value + valueChangeAmount
  523.                        
  524.                         if valueMinimum~=-1 then
  525.                             if newvalue < valueMinimum then
  526.                                 newvalue=valueMinimum
  527.                             elseif newvalue > valueMaximum then
  528.                                 newvalue=valueMaximum
  529.                             end
  530.                         end
  531.                         addressTableSetValue(address,addressSize,addressEndian,newvalue)               
  532.                     end)
  533.                 end
  534.             end        
  535.         end
  536.         table_iterations=table_iterations+1
  537.     end
  538.     memory.usememorydomain(memorydomainBefore)
  539. end
  540.    
  541. local drawDisplay = function(id)
  542.     if Displays[id][4]~=nil then
  543.         drawDisplayBox(id, 0xFF202020,0xA0000000)
  544.         drawCloseButton(id)
  545.         drawEditButton(id)
  546.         if Displays[id][9] then
  547.             DisplayAddressTable(id,true,true,true,66,132,42)   
  548.         else
  549.             DisplayAddressTable(id,true,false,true,46,132,0)
  550.         end
  551.     end
  552. end
  553.  
  554. local updateEnemies = function(enemyTableSize)
  555.  
  556.     memory.usememorydomain("EWRAM")
  557.     count=1
  558.     Enemies = {}
  559.     address=0x0
  560.     end_address=enemyTableSize*0xBC + 0x2F0
  561.     found=false
  562.    
  563.     while address < end_address do     
  564.         if memory.read_u32_le(address)== 0x1FFFFFF
  565.         and memory.read_u8(address-1)~= 255 then
  566.             Enemies[count]=address
  567.             count=count+1
  568.             found=true
  569.         end
  570.         if found then address=address+0x04
  571.                  else address=address+0x01
  572.         end
  573.     end
  574. end
  575.  
  576. local drawEnemies = function()  -- Enemies
  577.  
  578.     local color,subcolor,verticalOffset=0
  579.     local info=""
  580.     local enemyTableSize = table.getn(Enemies) 
  581.     local cameraX = memory.read_u16_le(0x23660)
  582.     local cameraY = memory.read_u16_le(0x23662)
  583.    
  584.     --update
  585.     if  enemyTableSize==0
  586.     or  frames%12==0 then
  587.         updateEnemies(enemyTableSize)
  588.     end
  589.  
  590.     --display
  591.     enemyTableSize = table.getn(Enemies)   
  592.     if enemyTableSize>0 then
  593.         memory.usememorydomain("EWRAM")
  594.         for s=1,enemyTableSize do
  595.  
  596.             offset = Enemies[s]
  597.             extrainfo=""           
  598.             status       = memory.read_u8(offset+0x32)
  599.             enemyX       = memory.read_u24_le(offset+0x44)
  600.             enemyY       = memory.read_u24_le(offset+0x48)
  601.             hitboxX      = memory.read_s8(offset+0x3B)
  602.             hitboxY      = memory.read_s8(offset+0x3C)
  603.             width  = memory.read_s8(offset+0x3D)
  604.             height = memory.read_s8(offset+0x3E)
  605.             heldAliveBy = memory.read_s8(offset+0x59)
  606.             ID = memory.read_u8(offset+0x85)
  607.             health = memory.read_u8(offset+0x83)
  608.             x=enemyX-cameraX+hitboxX    -- screen x
  609.             y=enemyY-cameraY+hitboxY    -- screen y
  610.             x2=x+width*2
  611.             y2=y+height*2
  612.             x3=x+width      -- center
  613.  
  614.             if Mouse.X > x-4 and Mouse.X < x2+4 and Mouse.Y > y-4 and Mouse.Y < y2+4 then
  615.                 color = 0xFFFFC020
  616.                 subcolor = 0x80000000
  617.                 verticalOffset = -36
  618.                 info = health .. " HP\n" ..enemyX .. " X\n" ..enemyY .. " Y"       
  619.             else
  620.                 color = 0xFF00FFFF
  621.                 subcolor = 0x80000000
  622.                 verticalOffset = -13
  623.                 info = health .. " HP"
  624.             end
  625.            
  626.             if status==0 then
  627.                 color=color - 0x80000000
  628.                 subcolor=subcolor - 0x40000000
  629.                 if HelperKirby[heldAliveBy] ~= nil then
  630.                     text(x3-8,y2+2,">" .. HelperKirby[heldAliveBy][1],HelperKirby[heldAliveBy][2],subcolor) -- extra information
  631.                 end
  632.             end
  633.            
  634.             --  text(x3-8,y-25,s .. " " .. string.format("%x",offset),color,0x80000000)
  635.             text(x3-8,y+verticalOffset,info,color,subcolor) -- information
  636.             gui.drawBox(x,y,x2,y2,color) -- hitbox rectangle
  637.        
  638.         end
  639.     end
  640.     text(186,0,"loaded: " .. enemyTableSize .. "   ." ,0xFFFFFF00,0x80000000)              
  641. end
  642.  
  643. local Menu = {
  644.     [1] =       {   [0] = "Script",
  645.                     [1] = 2,
  646.                     [2] = 3,
  647.                     [3] = 4,
  648.                     [4] = 5,
  649.                     [5] = 1,
  650.                     [6] = 6,
  651.                     [7] = 7
  652.                 }
  653. }
  654.  
  655. local drawMenu = function()
  656.  
  657.     verticalOffset=0
  658.  
  659.     for a=1,table.getn(Menu),1 do
  660.         drawMenuButton(-40+a*45,20,45,11,Menu[a][0],2,false,true,0xFFFFFFFF,function()
  661.             menuscreen=a
  662.         end)   
  663.        
  664.         if menuscreen==a then
  665.            
  666.             for b=1,table.getn(Menu[a]),1 do
  667.            
  668.                 id              = Menu[a][b]
  669.                 title           = Displays[id][1]
  670.                 indicator       = Displays[id][2]
  671.                 col             = Displays[id][3]
  672.                
  673.                 drawMenuButton(5,34+verticalOffset*10,80,10,title,1,true,indicator,col,function()
  674.                     Displays[id][2] = not indicator
  675.                 end)           
  676.                
  677.                 verticalOffset=verticalOffset+1
  678.             end        
  679.         end
  680.     end
  681.    
  682.     if Mouse.clicked and Mouse.clickedFrames==1 then
  683.            menuscreen = 0
  684.     end
  685. end
  686.  
  687. event.onloadstate(function()
  688.     updateEnemies(3)
  689. end)
  690.  
  691. menuscreen=0
  692. frames=0
  693.  
  694. console.clear()
  695. for i=1,table.getn(ScriptInfo),1 do
  696.     print(ScriptInfo[i])
  697. end
  698.  
  699. while true do
  700.  
  701.     Mouse.X = input.getmouse().X
  702.     Mouse.Y = input.getmouse().Y
  703.     Mouse.clicked = input.getmouse().Left
  704.    
  705.     for i=1,table.getn(Displays) do -- all displays
  706.         if Displays[i][2] then
  707.             drawDisplay(i)
  708.         end
  709.     end
  710.    
  711.     if Displays[7][2] then  -- enemies
  712.         drawEnemies()
  713.     end
  714.    
  715.     drawMenu() -- menu
  716.  
  717.     Mouse.XBefore=Mouse.X
  718.     Mouse.YBefore=Mouse.Y
  719.     if Mouse.clicked then Mouse.clickedFrames = Mouse.clickedFrames + 1
  720.     else Mouse.clickedFrames = 0 end
  721.    
  722.    if client.ispaused() then
  723.         gui.DrawFinish()
  724.         emu.yield()
  725.     else
  726.         emu.frameadvance()
  727.     end
  728.    
  729.     frames=frames+1
  730. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement