I have already the key code set for right or left and locked player position, but in your code i'm not sure why ( local graphic = ) is on the same line?
the thing I can't get working is when the sprite highlighted I cant have the value of the sprite hovered. or to send it to a table to know on wich power name I have selected. and also I want 5 row of 6 powerups like in the original smb3 stored in a table and gathered in a random way.
I can give you the code i have so far now , but sorry if is hard to read, it's my 1st time in Lua
Code: Select all
local __title = "SMB Test Menu Navigator";
local __version = "0.0.1";
local __description = "Debug Menu + Cheats Menu Test";
local __author = "Lotus006";
local __url = "https://github.com/";
local DebugMenuTest_API = {} --instance
local debugenabled = 1 ;
local debugPOSMisc = 0 ;
local debugtimer = 1 ;
local CheatsMenuEnabled = 0 ; -- 0= Off, 1= On
local MenuInvEnabled = 1 ; -- 0= Off, 1= On
local debugpage = 3 ; -- 0= Off, 1= Page 1, 2= Page 2
local EnableAnimHandX = 1 ; -- 0= Hand Not Moving PosX, 1= Hand Moving PosX
local SelMushroom = { }
local UnSelMushroom = { }
local Selflower = { }
local UnSelflower = { }
local SelIceflower = { }
local UnSelIceflower = { }
-- setmetatable(SelMushroomA, {__index = _G})
local resPath = getSMBXPath() .. "\\LuaScriptsLib\\DebugCheatsMenu"; --res path
local arrow = Graphics.loadImage(resPath .. "\\arrow.png"); -- Stuff
local inv = Graphics.loadImage(resPath .. "\\inv.png"); -- Stuff
local inv2 = Graphics.loadImage(resPath .. "\\inv2.png"); -- Stuff
for d=1, 7 do
table.insert(SelMushroom, Graphics.loadImage(resPath .. "\\SelMushroom.png") );
end
for d=1, 7 do
table.insert(UnSelMushroom, Graphics.loadImage(resPath .. "\\UnSelMushroom.png") );
end
for d=1, 7 do
table.insert(Selflower, Graphics.loadImage(resPath .. "\\Selflower.png") );
end
for d=1, 7 do
table.insert(UnSelflower, Graphics.loadImage(resPath .. "\\UnSelflower.png") );
end
for d=1, 7 do
table.insert(SelIceflower, Graphics.loadImage(resPath .. "\\SelIceflower.png") );
end
for d=1, 7 do
table.insert(UnSelIceflower, Graphics.loadImage(resPath .. "\\UnSelflower.png") );
end
local Selleafsmb3 = Graphics.loadImage(resPath .. "\\Selleafsmb3.png"); -- Stuff
local UnSelleafsmb3 = Graphics.loadImage(resPath .. "\\UnSelleafsmb3.png"); -- Stuff
-- local SelMushroom = Graphics.loadImage(resPath .. "\\SelMushroom.png"); -- Stuff
-- local UnSelMushroom = Graphics.loadImage(resPath .. "\\UnSelMushroom.png"); -- Stuff
-- local Selflower = Graphics.loadImage(resPath .. "\\Selflower.png"); -- Stuff
local flower = Graphics.loadImage(resPath .. "\\flower.png"); -- Stuff
-- local UnSelflower = Graphics.loadImage(resPath .. "\\UnSelflower.png"); -- Stuff
-- local UnSelIceflower = Graphics.loadImage(resPath .. "\\UnSelflower.png"); -- Stuff
-- local SelIceflower = Graphics.loadImage(resPath .. "\\SelIceflower.png"); -- Stuff
local Seltanookie = Graphics.loadImage(resPath .. "\\tanookie.png"); -- Stuff
local UnSeltanookie = Graphics.loadImage(resPath .. "\\UnSeltanookie.png"); -- Stuff
local UnSelHammer = Graphics.loadImage(resPath .. "\\UnSelHammer.png"); -- Stuff
local SelHammer = Graphics.loadImage(resPath .. "\\SelHammer.png"); -- Stuff
local UnEmptyItem = Graphics.loadImage(resPath .. "\\EmptyItem.png"); -- Stuff
local SelEmptyItem = Graphics.loadImage(resPath .. "\\EmptyItem.png"); -- Stuff
local Selbutton = Graphics.loadImage(resPath .. "\\Selbutton.png"); -- Stuff
local UnSelbutton = Graphics.loadImage(resPath .. "\\UnSelbutton.png"); -- Stuff
local debugback = Graphics.loadImage(resPath .. "\\debugback.png"); -- Stuff
local P1PlayerIcon = Graphics.loadImage(resPath .. "\\P1PlayerIcon.png"); -- Stuff
local P2PlayerIcon = Graphics.loadImage(resPath .. "\\P2PlayerIcon.png"); -- Stuff
local Rbutton = Graphics.loadImage(resPath .. "\\Rbutton.png"); -- Stuff
local hand = Graphics.loadImage(resPath .. "\\hand.png"); -- Stuff
local handdown = Graphics.loadImage(resPath .. "\\handdown.png"); -- Stuff
local TimerActivate = 0
local TimerSet = 2
local TimerSecondeleft = TimerSet
local TimerTick = 0.1
local addthis = 0
local PosItemsX = 1
local testthisvar = 0
local MoveTheHandX = 0.7
local HandPosY = 0
local lives = 0
local NPCToObject = ""
local GodMode = 0
local powerups = 0
local closemenu = 1
MenuCheatsStuff = {}
Menu1PosY = {0, 30, 60, 90, 120, 170}
ItemsSelSpritesPosX = {190, 253, 310, 370, 430, 490, 550}
ItemsSelSpritesPosY = {535, 535, 535, 535, 535, 535, 535}
ItemsSlotsPos = {}
local ta = {}
MenuItemCheats = { "turn Enemy", "God Mode", "add lives", " Debug Menu", " PowerUps Menu" }
MenuClose = {"Close Cheats Menu"}
local TPauseKey = 0
local TPauseVar = 0
local j1 = 0
local timeLimit = 20
local UnItems = {UnSelMushroom[1], UnSelflower[1], UnSelIceflower[1], UnSelleafsmb3, UnSeltanookie, UnSelHammer, EmptyItem}
local SelItems = {SelMushroom[1], Selflower[1], SelIceflower[1], Selleafsmb3, Seltanookie, SelHammer, EmptyItem}
local A = { PLAYER_BIG, PLAYER_FIREFLOWER, PLAYER_ICE, PLAYER_LEAF, PLAYER_TANOOKIE, PLAYER_HAMMER }
local UnItems1 = UnSelMushroom[1]
local UnItems2 = UnSelflower[1]
local UnItems3 = UnSelIceflower[1]
local UnItems4 = UnSelleafsmb3
local UnItems5 = UnSeltanookie
local UnItems6 = UnSelHammer
local UnItems7 = UnEmptyItem
local SelItems1 = SelMushroom[1]
local SelItems2 = Selflower[1]
local SelItems3 = SelIceflower[1]
local SelItems4 = Selleafsmb3
local SelItems5 = Seltanookie
local SelItems6 = SelHammer
local SelItems7 = SelEmptyItem
local RemoveTest = 0
-- local PowerUpsSelSprites = { SelMushroom, Selflower, Seltanookie, Selleafsmb3, SelIceflower }
--local PowerUpsSelSprites = { "SelMushroom", "Selflower", "Seltanookie", "Selleafsmb3", "SelIceflower" }
-- local spritesA = { This = "That", Those = "These", Him = "Her" }
spritesA = {
-- [SelItems1] = UnItems1 ,
-- [SelItems2] = UnItems2 ,
-- [SelItems7] = UnItems7 ,
}
local PowerUpsSelSprites = {
-- "SelItems1",
-- "SelItems7" ,
-- "SelItems2" ,
}
local PowerUpsUnSelSprites = {
UnItems1 ,
UnItems7 ,
UnItems2 ,
}
local index = 2
local powerupsitemsstock = {
PLAYER_BIG ,
PLAYER_FIREFLOWER ,
PLAYER_ICE ,
PLAYER_LEAF ,
PLAYER_TANOOKIE ,
PLAYER_HAMMER
}
local playerselect = { "CHARACTER_LUIGI" , "CHARACTER_LINK" }
function table.map_length(t)
local c = 0
for k,v in pairs(t) do
c = c+1
end
return c
end
local ItemsSlot = { }
local timeAA = 1
local SpriteLines = table.map_length(spritesA)
local LineSpritesTable = table.map_length(PowerUpsSelSprites)
local ThisItemsSlots = math.floor(PosItemsX)
function DebugMenuTest_API.onInitAPI()
registerEvent(DebugMenuTest_API, "onLoop", "onLoopOverride");
registerEvent(DebugMenuTest_API, "onLoad", "onLoadOverride");
registerEvent(DebugMenuTest_API, "onInputUpdate", "onInputUpdateOverride");
end
function DebugMenuTest_API.onLoopOverride()
ItemsTable = table.getn(UnItems)
if (TimerSecondeleft > 1) and (TimerActivate == 1) then
TimerSecondeleft = TimerSecondeleft - TimerTick
end
if (TimerSecondeleft < 2) then
TimerSecondeleft = 1
end
if (TimerActivate > 1) then
TimerActivate = 1
end
if (debugpage == 1) then
printText( "Moving Stuff" , 536, 96 )
printText( "---------------" , 505, 119 )
printText( "MoveHandX:" .. MoveTheHandX , 507, 147 )
printText( "TimerSleft:" .. math.floor(TimerSecondeleft) , 507, 170 )
printText( "testvar:" .. testthisvar , 507, 224 )
printText( "pausekey:" .. math.floor(TPauseKey) , 506, 340 )
printText( "timeAA:" .. math.floor(timeAA) , 506, 363 )
printText( "Page:1/3" , 630, 390 )
printText( "RemoveTest:" .. RemoveTest , 507 + 10 , 286 - 10)
else
printText( "Page:1/3" , 630, 390 )
end
if (debugpage == 3) then
printText( "Table Stuff" , 543, 97 )
printText( "---------------" , 505, 119 )
printText( "Page:2/3" , 630, 390 )
printText( "Lines:" .. math.floor(TimerSecondeleft) , 510 , 200)
printText( "ta:" .. tostring(ta), 510 , 230)
else
printText( "Page:2/3" , 630, 390 )
end
Graphics.unplaceSprites(inv);
Graphics.placeSprite(1,inv, 10 , 40 );
Graphics.unplaceSprites(debugback);
Graphics.placeSprite(1,debugback, 490 , 40 );
Graphics.unplaceSprites(hand);
Graphics.placeSprite(1,hand, 10 , 10);
Graphics.unplaceSprites(inv2);
Graphics.placeSprite(1,inv2, 160 , 518 );
Graphics.unplaceSprites(Rbutton);
Graphics.placeSprite(1,Rbutton, 176 , 496 );
if (TPauseKey == 1) then
CheatsMenuEnabled = 1
else
CheatsMenuEnabled = 0
end
timeAA = timeAA + TPauseVar
if (TPauseKey == 1) then
TPauseVar = 0.1
else
TPauseVar = 0
end
if (timeAA >= 2) then
timeAA = 2
end
if (timeAA == 2) then
end
if (player.pauseKeyPressing) and (timeAA >= 2)then
timeAA = 2
TPauseVar = 0
end
if (PosItemsX < 1) then
PosItemsX = 1
end
if (PosItemsX >= ItemsTable ) then
PosItemsX = ItemsTable
end
local GetLinePUpsUnSelSprites = table.getn(PowerUpsUnSelSprites)
local TimerA = math.floor(PosItemsX)
if (debugpage == 1) then
printText( "PosItemsX:" .. math.floor(PosItemsX) , 507, 200 )
printText( "items:" .. ItemsTable , 507, 260 )
else
end
for k,v in pairs (PowerUpsSelSprites) do
if (debugpage == 2) then
printText( "Lines:" .. SpriteLines , 507 + 20 , 286 + 20)
end
end
for k,v in pairs (PowerUpsUnSelSprites) do
if (debugpage == 1) then
-- printText( "Cheats Act:" .. CheatsMenuEnabled , 507, 223 )
-- printText( "k Value:" .. k , 507, 246 )
else
end
end
ThatSlot = math.floor(PosItemsX)
Graphics.unplaceSprites( SelMushroom[1] ) ;
Graphics.placeSprite(1, SelMushroom[1], 190 , 400 ) ;
Graphics.unplaceSprites( SelMushroom[2] ) ;
Graphics.placeSprite(1, SelMushroom[2], 253 , 400 ) ;
Graphics.unplaceSprites( UnItems[1] ) ;
Graphics.placeSprite(1, UnItems[1], ItemsSelSpritesPosX[1] , ItemsSelSpritesPosY[1] ) ;
Graphics.unplaceSprites( UnItems[2]) ;
Graphics.placeSprite(1, UnItems[2], ItemsSelSpritesPosX[2] , ItemsSelSpritesPosY[2] ) ;
Graphics.unplaceSprites( UnItems[3]) ;
Graphics.placeSprite(1, UnItems[3], ItemsSelSpritesPosX[3] , ItemsSelSpritesPosY[3] ) ;
Graphics.unplaceSprites( UnItems4) ;
Graphics.placeSprite(1, UnItems4, ItemsSelSpritesPosX[4] , ItemsSelSpritesPosY[4] ) ;
Graphics.unplaceSprites( UnItems5) ;
Graphics.placeSprite(1, UnItems5, ItemsSelSpritesPosX[5] , ItemsSelSpritesPosY[5] ) ;
Graphics.unplaceSprites( UnItems6) ;
Graphics.placeSprite(1, UnItems6, ItemsSelSpritesPosX[6] , ItemsSelSpritesPosY[6] ) ;
if (ThatSlot == 1) then
Graphics.unplaceSprites( SelItems[1]) ;
Graphics.placeSprite(1, SelItems[1], ItemsSelSpritesPosX[1] , ItemsSelSpritesPosY[1] ) ;
elseif (ThatSlot == 2) then
Graphics.unplaceSprites( SelItems[2]) ;
Graphics.placeSprite(1, SelItems[2], ItemsSelSpritesPosX[2] , ItemsSelSpritesPosY[2] ) ;
elseif (ThatSlot == 3) then
Graphics.unplaceSprites( SelItems[3]) ;
Graphics.placeSprite(1, SelItems[3], ItemsSelSpritesPosX[3] , ItemsSelSpritesPosY[3] ) ;
elseif (ThatSlot == 4) then
Graphics.unplaceSprites( SelItems4) ;
Graphics.placeSprite(1, SelItems4, ItemsSelSpritesPosX[4] , ItemsSelSpritesPosY[4] ) ;
elseif (ThatSlot == 5) then
Graphics.unplaceSprites( SelItems5) ;
Graphics.placeSprite(1, SelItems5, ItemsSelSpritesPosX[5] , ItemsSelSpritesPosY[5] ) ;
elseif (ThatSlot == 6) then
Graphics.unplaceSprites( SelItems6) ;
Graphics.placeSprite(1, SelItems6, ItemsSelSpritesPosX[6] , ItemsSelSpritesPosY[6] ) ;
end
table.insert(ItemsSlotsPos, 1, "tessst")
for i=1, ItemsTable - 1 do
Text.print("powers:" , 510, 180)
if (player.runKeyPressing) then
for k,v in pairs (SelItems[1]) do
printText( "This:" .. k .. " " .. tostring(v) , 507, 243 + 20 * k )
end
-- UnItems[2] = UnSelMushroom[2]
-- SelItems[2] = SelMushroom[2]
-- UnItems3 = UnSelMushroom[3]
-- SelItems3 = SelMushroom[3]
end
if (player.pauseKeyPressing) then
player.powerup = A[2]
end
--[[
if (RemoveTest == 1) then
else
end
if (ThatSlot == i) then
Graphics.unplaceSprites( UnItems[i]) ;
Graphics.unplaceSprites( SelItems[i]) ;
Graphics.placeSprite(1, SelItems[i] , ItemsSelSpritesPosX[i] , ItemsSelSpritesPosY[i] ) ;
end
-- ]]
end
if(getInput().str:find("cheats")) then
if (CheatsMenuEnabled ~= 1) then
CheatsMenuEnabled = 1
end
-- getInput():clear()
end
end
function DebugMenuTest_API.onInputUpdateOverride()
if(player.runKeyPressing) then
end
if (player.downKeyPressing) then
end
if (player.upKeyPressing) then
end
if (player.leftKeyPressing) then
addthis = 0.23
PosItemsX = PosItemsX - addthis
else
addthis = 0
end
if(player.pauseKeyPressing) then
TPauseKey = 1
end
if (player.rightKeyPressing) then
addthis = 0.23
PosItemsX = PosItemsX + addthis
printText( "ttttt" , 507 , 386 ) -- ici --
-- player.rightKeyPressing = false;
end
if (player.pauseKeyPressing) then
if (TimerSecondeleft == 1) then
TimerSecondeleft = TimerSet
end
end
if (player.pauseKeyPressing) and (TimerSecondeleft > TimerSet - 1) then
TimerActivate = TimerActivate + 1
end
end
return DebugMenuTest_API