Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ScriptInfo = {"KATAM Luascript by Mugg1991",
- "v0.1.1",
- "2nd Oct 2017",
- }
- --[[
- v0.1
- - Initial release
- v0.1.1
- - Fixed that the hitbox display wouldn't work.
- ]]
- local Settings = {
- ["Boolwin1"]=false, -- general
- ["win1x"]=40,
- ["win1y"]=40,
- ["Boolwin2"]=false, -- kirby
- ["win2x"]=40,
- ["win2y"]=40,
- ["Boolwin3"]=false, -- flags
- ["win3x"]=40,
- ["win3y"]=40,
- ["Boolwin4"]=false, -- yellow
- ["win4x"]=40,
- ["win4y"]=40,
- ["Boolwin5"]=false, -- red
- ["win5x"]=40,
- ["win5y"]=40,
- ["Boolwin6"]=false, -- green
- ["win6x"]=40,
- ["win6y"]=40,
- ["Boolwin7"]=false -- enemies
- }
- 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 AddressTableDisplayOffset = { -- the offset of the list entry
- ["win1"] =0,
- ["win2"] =0,
- ["win3"] =0,
- ["win4"] =0,
- ["win5"] =0,
- ["win6"] =0
- }
- local DisplayEditMode = {
- ["win1"] =false,
- ["win2"] =false,
- ["win3"] =false,
- ["win4"] =false,
- ["win5"] =false,
- ["win6"] =false
- }
- 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(posx,posy,stringx,stringy,width,height,bordercolor,color)
- 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
- if stringx~=nil then
- 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
- Settings[stringx]=posx
- Settings[stringy]=posy
- end
- end
- end
- end
- gui.drawBox(posx,posy,posx+width,posy+height,bordercolor,color)
- end
- function drawCloseButton(posx,posy,width,setting_id,clickedfunction)
- drawButton(posx+width-10,posy,10,10,"x",Color.Grey,15,function()
- Settings[setting_id] = false
- clickedfunction()
- end)
- end
- function drawEditButton(posx,posy,width,col,resetOffset,displaystring)
- drawButton(posx+width-25,posy,12,10,"e",col,15,function()
- DisplayEditMode[displaystring]=not DisplayEditMode[displaystring]
- if resetOffset then
- AddressTableDisplayOffset[displaystring]=0
- end
- 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)
- -- due to the implementation, z needs to be 2 for main menu buttons
- -- and 1 for sub menu buttons. Otherwise, you cannot properly open the menu.
- 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)
- -- draw the specified indicator:
- if drawindicator then
- if indicator then text(posx+width-10,posy,"o",0xFF80FF80)
- else text(posx+width-10,posy-1,"x",0xFFFF9090) end
- -- special case: this will be highlighted as a functionality
- -- that's not working yet. To draw no indicator at all, pass
- -- drawindicator as false and indicator as true.
- elseif drawindicator==false and indicator==false then
- text(posx+width-20,posy-1,"N/A",0xFFFFFF80)
- end
- end
- local toboolean = function(string)
- if string=="true" then
- string=true
- elseif string=="false" then
- string=false
- else
- string=nil
- end
- return string
- end
- local totime = function(frames,fps)
- hours = math.floor((frames/fps)/3600)
- mins = math.floor((frames/fps)/60)%60
- secs = math.floor(((frames/fps-mins*60)*100+0.5)/100) %60
- ms = (frames % fps)/60 * 100
- if hours==0 then
- returnvalue = string.format("%02d:%02d.%02d",mins,secs,ms)
- else
- returnvalue = string.format("%02d:%02d:%02d.%02d",hours,mins,secs,ms)
- end
- return returnvalue
- end
- local getChangeAmount = function(valueChangeAmount)
- if Mouse.clickedFrames>810 then
- valueChangeAmount=valueChangeAmount*1000000000
- elseif Mouse.clickedFrames>720 then
- valueChangeAmount=valueChangeAmount*100000000
- elseif Mouse.clickedFrames>630 then
- valueChangeAmount=valueChangeAmount*10000000
- elseif 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(inputTable,table_start,table_end,offset_id,slot,xpos,ypos,has_arrows,has_buttons,display_description,description_offset,arrows_offset,buttons_offset)
- memorydomainBefore=memory.getcurrentmemorydomain()
- tableEntries=table.getn(inputTable)
- table_iterations = 1
- offset=AddressTableDisplayOffset[offset_id]
- list_height = 8*(table_end - table_start)+14
- addressOffset=0
- --display arrows:
- if has_arrows then
- if (tableEntries - offset) > table_end then
- --bottom arrow button
- 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
- AddressTableDisplayOffset[offset_id]=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
- AddressTableDisplayOffset[offset_id]=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
- AddressTableDisplayOffset[offset_id]=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
- --display contents of table:
- -- 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]+addressOffset*slot
- 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]+addressOffset*slot
- 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=-1
- end
- if valueMaximum==nil then
- valueMaximum=-1
- end
- if contenttype==6 then -- show value as timer (framecount --> clock time)
- value = addressTableGetValue(address,addressSize,addressEndian, addressSigned)
- text(5+xpos,3+ypos+table_iterations*8,totime(value,60), textColor)
- elseif contenttype==8 then -- show value as timer (min,sec,ms --> clock time)
- minutes= memory.read_u8(address)
- seconds= memory.read_u8(address+1)
- ms= memory.read_u8(address+2)
- value = minutes*3600 + seconds*60 + ms
- text(5+xpos,3+ypos+table_iterations*8,totime(value,60), textColor)
- elseif contenttype==2 then -- direction
- local directionTable={[0]="Up",[1]="Upright",[2]="Right",[3]="Downright",[4]="Down",[5]="Downleft",[6]="Left",[7]="Leftup"}
- value = addressTableGetValue(address,addressSize,addressEndian, addressSigned)
- itemText = directionTable[value]
- text(5+xpos,3+ypos+table_iterations*8,itemText,textColor)
- else -- show value as is
- value = addressTableGetValue(address,addressSize,addressEndian, addressSigned)
- text(5+xpos,3+ypos+table_iterations*8,value, textColor)
- end
- 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==8 then -- min,sec,ms timer
- if value > valueMinimum
- or valueMininum==-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
- minutes=math.floor(newvalue/3600)
- seconds=math.floor((newvalue-minutes*3600)/60)
- ms=math.floor(newvalue-minutes*3600-seconds*60)
- memory.write_u8(address, minutes)
- memory.write_u8(address+1, seconds)
- memory.write_u8(address+2, ms)
- 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
- minutes=math.floor(newvalue/3600)
- seconds=math.floor((newvalue-minutes*3600)/60)
- ms=math.floor(newvalue-minutes*3600-seconds*60)
- memory.write_u8(address, minutes)
- memory.write_u8(address+1, seconds)
- memory.write_u8(address+2, ms)
- 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 drawWin1 = function() -- general
- win1x=Settings["win1x"]
- win1y=Settings["win1y"]
- width=138
- height=90
- drawDisplayBox(win1x, win1y, "win1x","win1y",width, height, 0xFF202020,0xA0000000)
- if DisplayEditMode["win1"] then
- DisplayAddressTable(AddressTableGeneral,1,2,"win1",0,win1x,win1y,true,true,true,72,124,46)
- else
- DisplayAddressTable(AddressTableGeneral,1,2,"win1",0,win1x,win1y,true,false,true,56,124,0)
- end
- drawCloseButton(win1x,win1y,width,"Boolwin1",function()
- end)
- if DisplayEditMode["win1"] then
- editButtonCol = Color.Selected
- else
- editButtonCol = Color.Normal
- end
- drawEditButton(win1x,win1y,width,editButtonCol,false,"win1")
- text(win1x+3,win1y-1,"General Memory",0xFF808080)
- end
- local drawWin2 = function() -- kirby
- win2x=Settings["win2x"]
- win2y=Settings["win2y"]
- width=150
- height=74
- drawDisplayBox(win2x, win2y, "win2x","win2y",width, height, 0xFF202020,0xA0000000)
- if DisplayEditMode["win2"] then
- DisplayAddressTable(AddressTableKirby,1,7,"win2",0,win2x,win2y,true,true,true,72,136,46)
- else
- DisplayAddressTable(AddressTableKirby,1,7,"win2",0,win2x,win2y,true,false,true,56,136,0)
- end
- drawCloseButton(win2x,win2y,width,"Boolwin2",function()
- end)
- if DisplayEditMode["win2"] then
- editButtonCol = Color.Selected
- else
- editButtonCol = Color.Normal
- end
- drawEditButton(win2x,win2y,width,editButtonCol,false,"win2")
- text(win2x+3,win2y-1,"Kirby",0xFF808080)
- end
- local drawWin4 = function() -- yellow
- win4x=Settings["win4x"]
- win4y=Settings["win4y"]
- width=150
- height=82
- drawDisplayBox(win4x, win4y, "win4x","win4y",width, height, 0xFF202020,0xA0000000)
- if DisplayEditMode["win4"] then
- DisplayAddressTable(AddressTableYellow,1,8,"win4",0,win4x,win4y,true,true,true,72,136,46)
- else
- DisplayAddressTable(AddressTableYellow,1,8,"win4",0,win4x,win4y,true,false,true,56,136,0)
- end
- drawCloseButton(win4x,win4y,width,"Boolwin4",function()
- end)
- if DisplayEditMode["win4"] then
- editButtonCol = Color.Selected
- else
- editButtonCol = Color.Normal
- end
- drawEditButton(win4x,win4y,width,editButtonCol,false,"win4")
- text(win4x+3,win4y-1,"Yellow",0xFF808080)
- end
- local drawWin5 = function() -- red
- win5x=Settings["win5x"]
- win5y=Settings["win5y"]
- width=150
- height=82
- drawDisplayBox(win5x, win5y, "win5x","win5y",width, height, 0xFF202020,0xA0000000)
- if DisplayEditMode["win5"] then
- DisplayAddressTable(AddressTableRed,1,8,"win5",0,win5x,win5y,true,true,true,72,136,46)
- else
- DisplayAddressTable(AddressTableRed,1,8,"win5",0,win5x,win5y,true,false,true,56,136,0)
- end
- drawCloseButton(win5x,win5y,width,"Boolwin5",function()
- end)
- if DisplayEditMode["win5"] then
- editButtonCol = Color.Selected
- else
- editButtonCol = Color.Normal
- end
- drawEditButton(win5x,win5y,width,editButtonCol,false,"win5")
- text(win5x+3,win5y-1,"Red",0xFF808080)
- end
- local drawWin6 = function() -- green
- win6x=Settings["win6x"]
- win6y=Settings["win6y"]
- width=150
- height=82
- drawDisplayBox(win6x, win6y, "win6x","win6y",width, height, 0xFF202020,0xA0000000)
- if DisplayEditMode["win6"] then
- DisplayAddressTable(AddressTableGreen,1,8,"win6",0,win6x,win6y,true,true,true,72,136,46)
- else
- DisplayAddressTable(AddressTableGreen,1,8,"win6",0,win6x,win6y,true,false,true,56,136,0)
- end
- drawCloseButton(win6x,win6y,width,"Boolwin6",function()
- end)
- if DisplayEditMode["win6"] then
- editButtonCol = Color.Selected
- else
- editButtonCol = Color.Normal
- end
- drawEditButton(win6x,win6y,width,editButtonCol,false,"win6")
- text(win6x+3,win6y-1,"Kirby",0xFF808080)
- end
- Enemies = {}
- HelperKirby = {
- [1]={"Yellow",0xFFFFE060},
- [2]={"Red",0xFFFF9090},
- [3]={"Green",0xFFC0FF80}
- }
- local drawEnemies = function() -- Enemies
- local color,subcolor,verticalOffset=0
- local info=""
- if frames%7==0 then
- count=1
- Enemies = {}
- memory.usememorydomain("EWRAM")
- for i=0x000,0x700,0x1 do
- if memory.read_u32_le(i)== 0x1FFFFFF then
- if memory.read_u8(i-1) ~= 255 then
- Enemies[count]=i
- count=count+1
- end
- end
- end
- end
- enemyTableSize = table.getn(Enemies)
- cameraX = memory.read_u16_le(0x23660)
- cameraY = memory.read_u16_le(0x23662)
- 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(190,0,"loaded: " .. enemyTableSize .. " ." ,0xFFFFFF00,0x80000000)
- end
- local drawWin3 = function() -- flags
- win3x=Settings["win3x"]
- win3y=Settings["win3y"]
- width=140
- height=90
- drawDisplayBox(win3x, win3y, "win3x","win3y",width, height, 0xFF202020,0xA0000000)
- if DisplayEditMode["win3"] then
- DisplayAddressTable(AddressTableFlags,1,9,"win3",0,win3x,win3y,true,true,true,56,126,32)
- else
- DisplayAddressTable(AddressTableFlags,1,9,"win3",0,win3x,win3y,true,false,true,36,126,0)
- end
- drawCloseButton(win3x,win3y,width,"Boolwin3",function()
- end)
- if DisplayEditMode["win3"] then
- editButtonCol = Color.Selected
- else
- editButtonCol = Color.Normal
- end
- drawEditButton(win3x,win3y,width,editButtonCol,false,"win3")
- text(win3x+3,win3y-1,"Flags",0xFF808080)
- end
- local Menu = {
- --display name, col, indicator, drawindicator, works in prototype?, openingfunction, closingfunction
- [1] = { [0] = "Memory",
- [1] = {"Kirby", 0xFFFFB0C0, true, "Boolwin2", true, nil,nil},
- [2] = {"Yellow", 0xFFFFE060, true, "Boolwin4", true, nil,nil},
- [3] = {"Red", 0xFFFF9090, true, "Boolwin5", true, nil,nil},
- [4] = {"Green", 0xFFC0FF80, true, "Boolwin6", true, nil,nil},
- [5] = {"General", 0xFFFFE0A0, true, "Boolwin1", true, nil,nil},
- [6] = {"Flags", 0xFFFFE0A0, true, "Boolwin3", true, nil,nil},
- [7] = {"Enemies", 0xFFFFE0A0, true, "Boolwin7", true, nil,nil},
- }
- }
- 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
- title = Menu[a][b][1]
- col = Menu[a][b][2]
- drawindicator = Menu[a][b][3]
- settingtext = Menu[a][b][4]
- worksInBeta = Menu[a][b][5]
- openingfunction = Menu[a][b][6]
- closingfunction = Menu[a][b][7]
- indicator = false
- if type(settingtext)=="string" then
- indicator = Settings[settingtext]
- else
- indicator = settingtext
- end
- drawMenuButton(5,34+verticalOffset*10,80,10,title,1,drawindicator,indicator,col,function()
- if not indicator and not drawindicator then -- not added yet
- Mouse.clickedFrames=2
- extrascreen=4
- else -- open/close the display
- --custom functions
- if indicator then
- if closingfunction ~= nil then
- closingfunction()
- end
- else
- if openingfunction ~= nil then
- openingfunction()
- end
- end
- --setting the setting boolean
- if type(settingtext)=="string" then
- Settings[settingtext] = not indicator
- end
- end
- end)
- verticalOffset=verticalOffset+1
- end
- end
- end
- if Mouse.clicked and Mouse.clickedFrames==1 then
- menuscreen = 0
- end
- 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
- if Settings["Boolwin7"] then drawEnemies() end
- if Settings["Boolwin1"] then drawWin1() end
- if Settings["Boolwin2"] then drawWin2() end
- if Settings["Boolwin3"] then drawWin3() end
- if Settings["Boolwin4"] then drawWin4() end
- if Settings["Boolwin5"] then drawWin5() end
- if Settings["Boolwin6"] then drawWin6() end
- drawMenu()
- Mouse.XBefore=Mouse.X -- update mouse
- 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