button combos?
hey does anyone know how to code in certain combos? i'm thinking like Konami code. I can't figure it out ={
hey does anyone know how to code in certain combos? i'm thinking like Konami code. I can't figure it out ={
Are you talking about entering cheat code combos?
Different approaches, as always it depends on the situation.
I would maybe start by putting all the allowed combos into an array.
And then you need to read the keyboard one by one, comparing it to your 'cheat database' to determine if there is a match.
For sure not as easy as it sounds, when do you reset the input counter etc.
Is this what you are looking for at all?
yes. exactly that. i didn't even think to put it into an array.
Had a quick go at it during my lunch break, this is how far I got:
init = function()
// original Konami Code ... using 'Enter' instead of 'Start'
code = ["ARROW_UP" ,"ARROW_UP",
"ARROW_DOWN" ,"ARROW_DOWN",
"ARROW_LEFT" ,"ARROW_RIGHT",
"ARROW_LEFT" ,"ARROW_RIGHT",
"B","A","ENTER"]
index = 0
active = false
end
update = function()
if keyboard.press[code[index]] then
index+=1
if index==code.length then active=true end
//else
// index = 0 // doesn't work this way, need to figure out how the keyboard object works
end
end
draw = function()
screen.clear()
screen.drawText("Count : "+index ,0,15,10, "#FFF")
if active then
screen.drawText("CODE ACTIVE",0,0,15, "#F00")
else
screen.drawText("CODE INACTIVE",0,0,15, "#FF0")
end
end
It kind of works. Only problem, I was not able to work out how to reset the index when a different character gets entered. My break is over :)
Experts here, please some insight into the keyboard object
thank you so much.
I think I got it working now. Not sure if the way I did it is correct, BUT it works, LOL :)
:embed https://microstudio.io/TinkerSmith/konamicode/
Link: https://microstudio.dev/i/TinkerSmith/konamicode/
Live Long and Tinker
omg it works perfectly. thank you so much