Discord
Login
Community
DARK THEME

button combos

hey i'm kinda new to java script. does anyone know how to do button combos? or if you even can?

init = function()
end

update = function()
  local key = 1
  if keyboard.A then 
    key *= 13
  end
  if keyboard.S then 
    key *= 17
  end
  if key == 13 then 
    print( "A" )
  elsif key == 17 then 
    print( "S" )
  elsif key == ( 17*13 ) then 
    print( " A + S " )
  end
  print( "-" )
end

draw = function()
end

You give the key a value equal to a prime number. Ex: A = 13, S = 17

you check if a given key is pressed.

If so, you multiply the value of the variable that holds the value of the currently pressed keys by the prime number you assigned to the key.

Now this variable has information about which keys are pressed.

Finally, you check with an array where you have multiplied all the key combinations that will be used.

Maybe have a look at this :

https://microstudio.dev/i/gilles/keyboardtest/

It shows how to access all the keys that have been pressed through keyboard

Live Long and Tinker

P.S.

Or just do this

  if keyboard.A and keyboard.S then
    print("A+S")
  end

thank you so much

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community