Discord
Connexion
Communauté
THEME SOMBRE

tester si une touch est appuyer avec un objet

arrow = object
 key="r"
end

if keyboard.(arrow.key) then
 print("wow")
end

en gros j'ai un objet(arrow) qui contient une lettre(key) puis je veux tester si la touche de arrow.key a été appuyer

de mémoire il me semble que c'est plutôt comme ca :

controls = object
end

controls.reload = object
 key = "R"
 isActive = false
end
  
controls.action = object
  key = "E"
  isActive = false
end

controls.update = function()
  for c in controls
    if controls[c].key then
      if keyboard[controls[c].key] then
        controls[c].isActive = true
      else
        controls[c].isActive = false
      end
    end
  end
end

controls.draw = function()
  local y = 80
  
  for c in controls
      if controls[c].key then
        screen.drawText(controls[c].key+ " : " + controls[c].isActive, 0, y, 15, "#FFF")
        y -= 20
      end
  end
end

init = function()
end


update = function()
  controls.update()
end


clr = function()
  screen.fillRect(0,0,screen.width,screen.height,"rgba(0,0,0)") // remplit l'écran de noir
end


draw = function()
  //clr()
  screen.clear()
  
  controls.draw()
end

https://microstudio.dev/i/CryptoLogiq/littlekeymanager/

Poster une réponse

Avancement

Statut

Aperçu
Annuler
Poster
Validez votre adresse e-mail pour participer à la communauté