Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ScriptInfo = {"KATAM Luascript by Mugg1991",
- "v0.2",
- "3rd Oct 2017",}
- --[[
- v0.1
- - Initial release
- v0.1.1
- - Fixed that the hitbox display wouldn't work.
- v0.2
- - Improved hitbox display, more performance and actually displaying all the slots.
- - Improved code.
- ]]
- local AddressTableGeneral= {
- [1] = {1,"Camera X",0xFFFFE0A0,"EWRAM",0x23660,2,true,nil,nil,nil},
- [2] = {1,"Camera Y",0xFFFFE0A0,"EWRAM",0x23662,2,true,nil,nil,nil},
- [3] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil},
- [4] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil},
- [5] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil},
- [6] = {1,"-",0xFFFFE0A0,"EWRAM",0x0,1,true,nil,nil,nil}
- }
- local AddressTableFlags= {
- [1] = {0,"Mirror Shards",0xFFB0B0B0},
- [2] = {7,"Kracko",0xFFFFE0A0,"EWRAM",0x38970,0,true,nil,nil,nil},
- [3] = {7,"King Golem",0xFFFFE0A0,"EWRAM",0x38970,1,true,nil,nil,nil},
- [4] = {7,"Master Hand",0xFFFFE0A0,"EWRAM",0x38970,2,true,nil,nil,nil},
- [5] = {7,"Gobbler",0xFFFFE0A0,"EWRAM",0x38970,3,true,nil,nil,nil},
- [6] = {7,"Wiz",0xFFFFE0A0,"EWRAM",0x38970,4,true,nil,nil,nil},
- [7] = {7,"Moley",0xFFFFE0A0,"EWRAM",0x38970,5,true,nil,nil,nil},
- [8] = {7,"Mega Titan",0xFFFFE0A0,"EWRAM",0x38970,6,true,nil,nil,nil},
- [9] = {7,"D. Metaknight",0xFFFFE0A0,"EWRAM",0x38970,7,true,nil,nil,nil},
- [10] = {0,"Misc",0xFFB0B0B0},
- [11] = {7,"Ability Room",0xFFFFE0A0,"EWRAM",0x28C58,0,true,nil,nil,nil},
- [12] = {0,"Area 1",0xFFB0B0B0},
- [13] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C18,0,true,nil,nil,nil},
- [14] = {7,"Big Chest",0xFFFFE0A0,"EWRAM",0x38960,5,true,nil,nil,nil},
- [15] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38960,3,true,nil,nil,nil},
- [16] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38961,0,true,nil,nil,nil},
- [17] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38961,1,true,nil,nil,nil},
- [18] = {0,"Area 2",0xFFB0B0B0},
- [19] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C14,0,true,nil,nil,nil},
- [20] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38962,2,true,nil,nil,nil},
- [21] = {7,"Big Chest",0xFFFFE0A0,"EWRAM",0x38961,7,true,nil,nil,nil},
- [22] = {7,"Chest",0xFFFFE0A0,"EWRAM",0x38962,1,true,nil,nil,nil},
- [23] = {0,"Area 3",0xFFB0B0B0},
- [24] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C28,0,true,nil,nil,nil},
- [25] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C24,0,true,nil,nil,nil},
- [26] = {0,"Area 4",0xFFB0B0B0},
- [27] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C44,0,true,nil,nil,nil},
- [28] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C4C,0,true,nil,nil,nil},
- [29] = {0,"Area 5",0xFFB0B0B0},
- [30] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C34,0,true,nil,nil,nil},
- [31] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C38,0,true,nil,nil,nil},
- [32] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38969,5,true,nil,nil,nil},
- [33] = {0,"Area 6",0xFFB0B0B0},
- [34] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C1C,0,true,nil,nil,nil},
- [35] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C20,0,true,nil,nil,nil},
- [36] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38968,1,true,nil,nil,nil},
- [37] = {0,"Area 7",0xFFB0B0B0},
- [38] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C3C,0,true,nil,nil,nil},
- [39] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C40,0,true,nil,nil,nil},
- [40] = {0,"Area 8",0xFFB0B0B0},
- [41] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C2C,0,true,nil,nil,nil},
- [42] = {7,"Switch 2",0xFFFFE0A0,"EWRAM",0x28C30,0,true,nil,nil,nil},
- [43] = {7,"Lever",0xFFFFE0A0,"EWRAM",0x38969,2,true,nil,nil,nil},
- [44] = {0,"Area 9",0xFFB0B0B0},
- [45] = {7,"Switch 1",0xFFFFE0A0,"EWRAM",0x28C48,0,true,nil,nil,nil},
- }
- local AddressTableKirby= {
- [1] = {1,"X",0xFFFFB0C0,"EWRAM",0x020F20,4,true,nil,nil,nil,false},
- [2] = {1,"Y",0xFFFFB0C0,"EWRAM",0x020F24,4,true,nil,nil,nil,false},
- [3] = {1,"X Speed",0xFFFFB0C0,"EWRAM",0x020F30,2,true,nil,nil,nil,true},
- [4] = {1,"Y Speed",0xFFFFB0C0,"EWRAM",0x020F32,2,true,nil,nil,nil,true},
- [5] = {1,"Ability",0xFFFFB0C0,"EWRAM",0x020FE3,1,true,0,26,1,false},
- [6] = {1,"Health",0xFFFFB0C0,"EWRAM",0x020FE0,1,true,0,255,1,false},
- [7] = {1,"Max Health",0xFFFFB0C0,"EWRAM",0x020FE1,1,true,0,255,1,false},
- [8] = {1,"Lives",0xFFFFB0C0,"EWRAM",0x020FE2,1,true,0,255,1,false},
- [9] = {1,"Phone Battery",0xFFFFB0C0,"EWRAM",0x020FBC,1,true,0,255,1,false},
- [10] = {1,"Room",0xFFFFB0C0,"EWRAM",0x020FE6,2,true,101,970,1,false}
- }
- local AddressTableYellow= {
- [1] = {1,"X",0xFFFFE060,"EWRAM",0x0210C8,4,true,nil,nil,nil,false},
- [2] = {1,"Y",0xFFFFE060,"EWRAM",0x0210CC,4,true,nil,nil,nil,false},
- [3] = {1,"X Speed",0xFFFFE060,"EWRAM",0x0210D8,2,true,nil,nil,nil,true},
- [4] = {1,"Y Speed",0xFFFFE060,"EWRAM",0x0210DA,2,true,nil,nil,nil,true},
- [5] = {1,"Ability",0xFFFFE060,"EWRAM",0x02118B,1,true,0,26,1,false},
- [6] = {1,"Health",0xFFFFE060,"EWRAM",0x021188,1,true,0,255,1,false},
- [7] = {1,"Max Health",0xFFFFE060,"EWRAM",0x021189,1,true,0,255,1,false},
- [8] = {1,"Room",0xFFFFE060,"EWRAM",0x02118E,2,true,101,970,1,false}
- }
- local AddressTableRed= {
- [1] = {1,"X",0xFFFF9090,"EWRAM",0x021270,4,true,nil,nil,nil,false},
- [2] = {1,"Y",0xFFFF9090,"EWRAM",0x021274,4,true,nil,nil,nil,false},
- [3] = {1,"X Speed",0xFFFF9090,"EWRAM",0x021280,2,true,nil,nil,nil,true},
- [4] = {1,"Y Speed",0xFFFF9090,"EWRAM",0x021282,2,true,nil,nil,nil,true},
- [5] = {1,"Ability",0xFFFF9090,"EWRAM",0x021333,1,true,0,26,1,false},
- [6] = {1,"Health",0xFFFF9090,"EWRAM",0x021330,1,true,0,255,1,false},
- [7] = {1,"Max Health",0xFFFF9090,"EWRAM",0x021331,1,true,0,255,1,false},
- [8] = {1,"Room",0xFFFF9090,"EWRAM",0x021336,2,true,101,970,1,false}
- }
- local AddressTableGreen= {
- [1] = {1,"X",0xFFC0FF80,"EWRAM",0x021418,4,true,nil,nil,nil,false},
- [2] = {1,"Y",0xFFC0FF80,"EWRAM",0x02141C,4,true,nil,nil,nil,false},
- [3] = {1,"X Speed",0xFFC0FF80,"EWRAM",0x021428,2,true,nil,nil,nil,true},
- [4] = {1,"Y Speed",0xFFC0FF80,"EWRAM",0x02142A,2,true,nil,nil,nil,true},
- [5] = {1,"Ability",0xFFC0FF80,"EWRAM",0x0214DB,1,true,0,26,1,false},
- [6] = {1,"Health",0xFFC0FF80,"EWRAM",0x0214D8,1,true,0,255,1,false},
- [7] = {1,"Max Health",0xFFC0FF80,"EWRAM",0x0214D9,1,true,0,255,1,false},
- [8] = {1,"Room",0xFFC0FF80,"EWRAM",0x0214DE,2,true,101,970,1,false}
- }
- local Displays = {
- -- Name, active, col, x, y, width, height, offset of list, edit mode, table, entries shown
- [1]= {"General", false, 0xFFFFE0A0, 40, 40, 146, 34, 0, false, AddressTableGeneral,2},
- [2]= {"Kirby", false, 0xFFFFB0C0, 40, 40, 146, 66, 0, false, AddressTableKirby,6},
- [3]= {"Yellow", false, 0xFFFFE060, 40, 40, 146, 66, 0, false, AddressTableYellow,6},
- [4]= {"Red", false, 0xFFFF9090, 40, 40, 146, 66, 0, false, AddressTableRed,6},
- [5]= {"Green", false, 0xFFC0FF80, 40, 40, 146, 66, 0, false, AddressTableGreen,6},
- [6]= {"Flags", false, 0xFFFFE0A0, 40, 40, 146, 82, 0, false, AddressTableFlags,8},
- [7]= {"Enemies", false, 0xFFFFE0A0, nil}
- }
- Enemies = {}
- HelperKirby = {
- [1]={"Yellow",0xFFFFE060},
- [2]={"Red",0xFFFF9090},
- [3]={"Green",0xFFC0FF80}
- }
- local Mouse = {
- X = 0,
- Y = 0,
- XBefore = 0,
- YBefore = 0,
- clickedFrames = 0,
- clicked = false
- }
- local Color = {
- Selected = 0xB0A0A0A0,
- Normal = 0xA0303030,
- Grey = 0xA0C0C0C0
- }
- function text(x, y, text, color, backcolor)
- if backcolor==nil then backcolor=0x00000000 end
- gui.drawText(x, y, text,color,backcolor,10,"Arial")
- end
- function box(x,y,x2,y2)
- gui.drawBox(x,y,x2,y2,0x00000000,0xD0000000)
- end
- function boxNormal(x,y,x2,y2)
- gui.drawBox(x,y,x2,y2,0xFF000000,0xA0000000)
- end
- function boxSelected(x,y,x2,y2)
- gui.drawBox(x,y,x2,y2,0xFF000000,0xA0505050)
- end
- function arrowDown(xpos,ypos,col)
- gui.drawLine(xpos,ypos,xpos+6,ypos,col)
- gui.drawLine(xpos+1,ypos+1,xpos+5,ypos+1,col)
- gui.drawLine(xpos+2,ypos+2,xpos+4,ypos+2,col)
- gui.drawPixel(xpos+3,ypos+3,col)
- end
- function arrowUp(xpos,ypos,col)
- gui.drawLine(xpos,ypos,xpos+6,ypos,col)
- gui.drawLine(xpos+1,ypos-1,xpos+5,ypos-1,col)
- gui.drawLine(xpos+2,ypos-2,xpos+4,ypos-2,col)
- gui.drawPixel(xpos+3,ypos-3,col)
- end
- function drawDisplayBox(id,bordercolor,color)
- posx=Displays[id][4]
- posy=Displays[id][5]
- width=Displays[id][6]
- height=Displays[id][7]
- if Mouse.clicked then
- if Mouse.X > posx and Mouse.X < posx+width and Mouse.Y > posy and Mouse.Y < posy+height then
- if Mouse.clickedFrames > 0 then
- menuscreen=0 -- close menu
- posy = posy + (Mouse.Y-Mouse.YBefore) -- enables mouse drag
- posx = posx + (Mouse.X-Mouse.XBefore)
- if posy < 0 then posy=0 -- prevents display from going offscreen
- elseif posy > 159-height then posy=159-height end
- if posx < 0 then posx=0
- elseif posx > 239-width then posx=239-width end
- Displays[id][4]=posx
- Displays[id][5]=posy
- end
- end
- end
- gui.drawBox(posx,posy,posx+width,posy+height,bordercolor,color)
- text(posx+3,posy-1,Displays[id][1],0xFF808080)
- end
- function drawCloseButton(id)
- width=Displays[id][6]
- x=Displays[id][4]
- y=Displays[id][5]
- drawButton(x+width-10,y,10,10,"x",Color.Grey,15,function()
- Displays[id][2] = false
- end)
- end
- function drawEditButton(id)
- width=Displays[id][6]
- x=Displays[id][4]
- y=Displays[id][5]
- if Displays[id][9] then col=Color.Selected
- else col=Color.Normal end
- drawButton(x+width-25,y,12,10,"e",col,15,function()
- Displays[id][9]=not Displays[id][9]
- end)
- end
- function drawButton(posx,posy,width,height,label,color,frequency,clickedfunction)
- if Mouse.X>posx and Mouse.X<posx+width and Mouse.Y>posy and Mouse.Y<posy+height then
- if Mouse.clicked and Mouse.clickedFrames%frequency==1 then
- clickedfunction()
- end
- gui.drawBox(posx,posy,posx+width,posy+height,color-0x00303030,color+0x30303030)
- else
- gui.drawBox(posx,posy,posx+width,posy+height,color-0x00303030,color)
- end
- text(posx+1,posy-2,label,0xFFFFFFFF)
- end
- function drawMenuButton(posx,posy,width,height,label,z,drawindicator,indicator,col,clickedfunction)
- if Mouse.X>posx and Mouse.X<posx+width and Mouse.Y>posy and Mouse.Y<posy+height then
- if Mouse.clicked and Mouse.clickedFrames==z then
- menuscreen=0
- clickedfunction()
- end
- boxSelected(posx,posy,posx+width,posy+height)
- else
- boxNormal(posx,posy,posx+width,posy+height)
- end
- text(posx+2,posy-1,label,col)
- if drawindicator then
- if indicator then text(posx+width-10,posy,"o",0xFF80FF80)
- else text(posx+width-10,posy-1,"x",0xFFFF9090) end
- end
- end
- local getChangeAmount = function(valueChangeAmount)
- if Mouse.clickedFrames>540 then
- valueChangeAmount=valueChangeAmount*1000000
- elseif Mouse.clickedFrames>450 then
- valueChangeAmount=valueChangeAmount*100000
- elseif Mouse.clickedFrames>360 then
- valueChangeAmount=valueChangeAmount*10000
- elseif Mouse.clickedFrames>270 then
- valueChangeAmount=valueChangeAmount*1000
- elseif Mouse.clickedFrames>180 then
- valueChangeAmount=valueChangeAmount*100
- elseif Mouse.clickedFrames>90 then
- valueChangeAmount=valueChangeAmount*10
- end
- return valueChangeAmount
- end
- local addressTableSetValue = function(address, addressSize, addressEndian, newvalue)
- if addressSize==1 then
- memory.write_u8(address,newvalue)
- elseif addressSize==2 then
- if addressEndian then
- memory.write_u16_le(address,newvalue)
- else
- memory.write_u16_be(address,newvalue)
- end
- elseif addressSize==3 then
- if addressEndian then
- memory.write_u24_le(address,newvalue)
- else
- memory.write_u24_be(address,newvalue)
- end
- elseif addressSize==4 then
- if addressEndian then
- memory.write_u32_le(address,newvalue)
- else
- memory.write_u32_be(address,newvalue)
- end
- end
- end
- local addressTableGetValue = function(address, addressSize, addressEndian, addressSigned)
- if addressSigned then
- if addressSize==1 then
- value=memory.read_s8(address)
- elseif addressSize==2 then
- if addressEndian then
- value=memory.read_s16_le(address)
- else
- value=memory.read_s16_be(address)
- end
- elseif addressSize==3 then
- if addressEndian then
- value=memory.read_s24_le(address)
- else
- value=memory.read_s24_be(address)
- end
- elseif addressSize==4 then
- if addressEndian then
- value=memory.read_s32_le(address)
- else
- value=memory.read_s32_be(address)
- end
- end
- else
- if addressSize==1 then
- value=memory.read_u8(address)
- elseif addressSize==2 then
- if addressEndian then
- value=memory.read_u16_le(address)
- else
- value=memory.read_u16_be(address)
- end
- elseif addressSize==3 then
- if addressEndian then
- value=memory.read_u24_le(address)
- else
- value=memory.read_u24_be(address)
- end
- elseif addressSize==4 then
- if addressEndian then
- value=memory.read_u32_le(address)
- else
- value=memory.read_u32_be(address)
- end
- end
- end
- return value
- end
- local DisplayAddressTable = function(display_id, has_arrows, has_buttons, display_description, description_offset, arrows_offset, buttons_offset)
- inputTable=Displays[display_id][10]
- xpos=Displays[display_id][4]
- ypos=Displays[display_id][5]
- memorydomainBefore=memory.getcurrentmemorydomain()
- tableSize=table.getn(inputTable)
- table_start=1
- table_end=Displays[display_id][11]
- table_iterations = 1
- offset=Displays[display_id][8]
- list_height = 8*(table_end - table_start)+14
- --display arrows:
- if has_arrows then
- --bottom arrow button
- if (tableSize - offset) > table_end then
- 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
- if Mouse.clicked and Mouse.clickedFrames%3==1 then
- Displays[display_id][8]=offset+1
- end
- arrowDown(xpos+arrows_offset+2,ypos+list_height,0xFFFFFFFF)
- else
- arrowDown(xpos+arrows_offset+2,ypos+list_height,0xA0FFFFFF)
- end
- else
- if offset < 0 then
- Displays[display_id][8]=0
- end
- end
- --top arrow button
- if offset > 0 then
- 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
- if Mouse.clicked and Mouse.clickedFrames%3==1 then
- Displays[display_id][8]=offset-1
- end
- arrowUp(xpos+arrows_offset+2,ypos+list_height-6,0xFFFFFFFF)
- else
- arrowUp(xpos+arrows_offset+2,ypos+list_height-6,0xA0FFFFFF)
- end
- end
- end
- -- applying display offset
- table_start = table_start + offset
- table_end = table_end + offset
- -- going through the table
- for i=table_start,table_end do --show a part of the list
- contenttype=inputTable[i][1]
- description=inputTable[i][2]
- textColor=inputTable[i][3]
- memorydomain=inputTable[i][4]
- if contenttype==0 then -- TITLE
- gui.drawBox(5+xpos,4+ypos+table_iterations*8,arrows_offset+xpos,12+ypos+table_iterations*8,0x00000000,0xFF505050)
- elseif contenttype==7 then -- BINARY
- memory.usememorydomain(memorydomain)
- address=inputTable[i][5]
- currentbit=inputTable[i][6]
- value=memory.read_u8(address)
- value=bit.check(value, currentbit)
- if value then
- value="Yes"
- valueColor=0xFF80FF80
- else
- value="No"
- valueColor=0xFFFF9090
- end
- text(5+xpos,3+ypos+table_iterations*8,value,valueColor)
- else -- OTHER TYPES
- memory.usememorydomain(memorydomain)
- address=inputTable[i][5]
- addressSize=inputTable[i][6]
- addressEndian=inputTable[i][7] -- true:little endian, false:big endian
- addressSigned=inputTable[i][11]
- value=0
- valueMinimum=inputTable[i][8]
- valueMaximum=inputTable[i][9]
- valueChangeAmount=inputTable[i][10]
- if valueChangeAmount==nil then
- valueChangeAmount=1
- end
- if valueMinimum==nil then
- valueMinimum=0
- end
- if valueMaximum==nil then
- valueMaximum=256^addressSize - 1
- end
- value = addressTableGetValue(address,addressSize,addressEndian, addressSigned)
- text(5+xpos,3+ypos+table_iterations*8,value, textColor)
- end
- if display_description then
- text(xpos+description_offset,3+ypos+table_iterations*8,description, textColor)
- end
- if has_buttons then
- if contenttype==7 then -- binary
- drawButton(xpos+buttons_offset,4+ypos+table_iterations*8,21,8,"Set",Color.Normal,8,function()
- currentvalue=memory.read_u8(address)
- if bit.check(currentvalue,currentbit) then
- memory.write_u8(address, bit.clear(currentvalue,currentbit))
- else
- memory.write_u8(address, bit.set(currentvalue,currentbit))
- end
- end)
- elseif contenttype~=0 then -- normal values
- if value > valueMinimum
- or valueMinimum==-1 then
- drawButton(xpos+buttons_offset,4+ypos+table_iterations*8,9,8,"-",Color.Normal,5,function()
- valueChangeAmount = getChangeAmount(valueChangeAmount) -- increases when holding mouse key
- newvalue = value - valueChangeAmount
- if valueMinimum ~= -1 then
- if newvalue < valueMinimum then
- newvalue=valueMinimum
- elseif newvalue > valueMaximum then
- newvalue=valueMaximum
- end
- end
- addressTableSetValue(address,addressSize,addressEndian,newvalue)
- end)
- end
- if value < valueMaximum
- or valueMaximum==-1 then
- drawButton(12+xpos+buttons_offset,4+ypos+table_iterations*8,9,8,"+",Color.Normal,5,function()
- valueChangeAmount = getChangeAmount(valueChangeAmount) -- increases when holding mouse key
- newvalue = value + valueChangeAmount
- if valueMinimum~=-1 then
- if newvalue < valueMinimum then
- newvalue=valueMinimum
- elseif newvalue > valueMaximum then
- newvalue=valueMaximum
- end
- end
- addressTableSetValue(address,addressSize,addressEndian,newvalue)
- end)
- end
- end
- end
- table_iterations=table_iterations+1
- end
- memory.usememorydomain(memorydomainBefore)
- end
- local drawDisplay = function(id)
- if Displays[id][4]~=nil then
- drawDisplayBox(id, 0xFF202020,0xA0000000)
- drawCloseButton(id)
- drawEditButton(id)
- if Displays[id][9] then
- DisplayAddressTable(id,true,true,true,66,132,42)
- else
- DisplayAddressTable(id,true,false,true,46,132,0)
- end
- end
- end
- local updateEnemies = function(enemyTableSize)
- memory.usememorydomain("EWRAM")
- count=1
- Enemies = {}
- address=0x0
- end_address=enemyTableSize*0xBC + 0x2F0
- found=false
- while address < end_address do
- if memory.read_u32_le(address)== 0x1FFFFFF
- and memory.read_u8(address-1)~= 255 then
- Enemies[count]=address
- count=count+1
- found=true
- end
- if found then address=address+0x04
- else address=address+0x01
- end
- end
- end
- local drawEnemies = function() -- Enemies
- local color,subcolor,verticalOffset=0
- local info=""
- local enemyTableSize = table.getn(Enemies)
- local cameraX = memory.read_u16_le(0x23660)
- local cameraY = memory.read_u16_le(0x23662)
- --update
- if enemyTableSize==0
- or frames%12==0 then
- updateEnemies(enemyTableSize)
- end
- --display
- enemyTableSize = table.getn(Enemies)
- if enemyTableSize>0 then
- memory.usememorydomain("EWRAM")
- for s=1,enemyTableSize do
- offset = Enemies[s]
- extrainfo=""
- status = memory.read_u8(offset+0x32)
- enemyX = memory.read_u24_le(offset+0x44)
- enemyY = memory.read_u24_le(offset+0x48)
- hitboxX = memory.read_s8(offset+0x3B)
- hitboxY = memory.read_s8(offset+0x3C)
- width = memory.read_s8(offset+0x3D)
- height = memory.read_s8(offset+0x3E)
- heldAliveBy = memory.read_s8(offset+0x59)
- ID = memory.read_u8(offset+0x85)
- health = memory.read_u8(offset+0x83)
- x=enemyX-cameraX+hitboxX -- screen x
- y=enemyY-cameraY+hitboxY -- screen y
- x2=x+width*2
- y2=y+height*2
- x3=x+width -- center
- if Mouse.X > x-4 and Mouse.X < x2+4 and Mouse.Y > y-4 and Mouse.Y < y2+4 then
- color = 0xFFFFC020
- subcolor = 0x80000000
- verticalOffset = -36
- info = health .. " HP\n" ..enemyX .. " X\n" ..enemyY .. " Y"
- else
- color = 0xFF00FFFF
- subcolor = 0x80000000
- verticalOffset = -13
- info = health .. " HP"
- end
- if status==0 then
- color=color - 0x80000000
- subcolor=subcolor - 0x40000000
- if HelperKirby[heldAliveBy] ~= nil then
- text(x3-8,y2+2,">" .. HelperKirby[heldAliveBy][1],HelperKirby[heldAliveBy][2],subcolor) -- extra information
- end
- end
- -- text(x3-8,y-25,s .. " " .. string.format("%x",offset),color,0x80000000)
- text(x3-8,y+verticalOffset,info,color,subcolor) -- information
- gui.drawBox(x,y,x2,y2,color) -- hitbox rectangle
- end
- end
- text(186,0,"loaded: " .. enemyTableSize .. " ." ,0xFFFFFF00,0x80000000)
- end
- local Menu = {
- [1] = { [0] = "Script",
- [1] = 2,
- [2] = 3,
- [3] = 4,
- [4] = 5,
- [5] = 1,
- [6] = 6,
- [7] = 7
- }
- }
- local drawMenu = function()
- verticalOffset=0
- for a=1,table.getn(Menu),1 do
- drawMenuButton(-40+a*45,20,45,11,Menu[a][0],2,false,true,0xFFFFFFFF,function()
- menuscreen=a
- end)
- if menuscreen==a then
- for b=1,table.getn(Menu[a]),1 do
- id = Menu[a][b]
- title = Displays[id][1]
- indicator = Displays[id][2]
- col = Displays[id][3]
- drawMenuButton(5,34+verticalOffset*10,80,10,title,1,true,indicator,col,function()
- Displays[id][2] = not indicator
- end)
- verticalOffset=verticalOffset+1
- end
- end
- end
- if Mouse.clicked and Mouse.clickedFrames==1 then
- menuscreen = 0
- end
- end
- event.onloadstate(function()
- updateEnemies(3)
- end)
- menuscreen=0
- frames=0
- console.clear()
- for i=1,table.getn(ScriptInfo),1 do
- print(ScriptInfo[i])
- end
- while true do
- Mouse.X = input.getmouse().X
- Mouse.Y = input.getmouse().Y
- Mouse.clicked = input.getmouse().Left
- for i=1,table.getn(Displays) do -- all displays
- if Displays[i][2] then
- drawDisplay(i)
- end
- end
- if Displays[7][2] then -- enemies
- drawEnemies()
- end
- drawMenu() -- menu
- Mouse.XBefore=Mouse.X
- Mouse.YBefore=Mouse.Y
- if Mouse.clicked then Mouse.clickedFrames = Mouse.clickedFrames + 1
- else Mouse.clickedFrames = 0 end
- if client.ispaused() then
- gui.DrawFinish()
- emu.yield()
- else
- emu.frameadvance()
- end
- frames=frames+1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement