Forum du serveur Computercraft FR
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
-45%
Le deal à ne pas rater :
WHIRLPOOL OWFC3C26X – Lave-vaisselle pose libre 14 couverts – ...
339 € 622 €
Voir le deal

Clavier tactile par rednet

2 participants

Aller en bas

Clavier tactile par rednet Empty Clavier tactile par rednet

Message par R3dflyter Ven 6 Mai - 16:53

Clavier tactile par rednet 2016-011
Clavier tactile par rednet 2016-010
--pastebin code : S77XRBsf

local mon = peripheral.wrap("top")
--L , H = mon.getSize()

-- Tableau de clavier
touche = {}
touche[1] = {"0","1","2","3","4","5","6","7","8","9"}
touche[2] = {"a","b","c","d","e","f","g","h","i","j"}
touche[3] = {"k","l","m","n","o","p","q","r","s","t"}
touche[4] = {"u","v","w","x","y","z","[ Maj ]","[ Maj ]","[ Maj ]","[ Maj ]"}
touche[5] = {"Space","Entrer"}

toucheM={}
toucheM[1] = {"&","é","è","à","-","_","(",")","ç","'"}
toucheM[2] = {"A","B","C","D","E","F","G","H","I","J"}
toucheM[3] = {"K","L","M","N","O","P","Q","R","S","T"}
toucheM[4] = {"U","V","W","X","Y","Z","[ Maj ]","[ Maj ]","[ Maj ]","[ Maj ]"}
toucheM[5] = {"Space","Entrer"}

--initialisation du moniteur
mon.setTextScale(2)
mon.setBackgroundColor(colors.white)
mon.clear()
mon.setTextColor(colors.black)

--main
Maj = false
while true do
mon.clear()
--affichage
for y=1,4 do
 mon.setCursorPos(2,(y*2))
 for x=1,10 do
  if Maj == true then
   mon.write(toucheM[y][x])
    mon.write(" ")
  else
   mon.write(touche[y][x])
    mon.write(" ")
  end
 end
end
mon.setCursorPos(4,10)
mon.write(touche[5][1].."    "..touche[5][2])
-- tactile + assosiation
event, side, xpos, ypos = os.pullEvent("monitor_touch")
x = 1
Pos = 2
y = math.floor((ypos+1)/2)
if y==5 then
 if xpos>3 and xpos<9 then
  x = 1
 end
end
 if xpos>12 and xpos<19 then
 x = 2
 else
 while xpos>Pos do
  Pos=Pos+2
  x=x+1
 end
end
--envoit par Rednet
rednet.open("left")
if Maj==true then
 Lout = toucheM[y][x]
else
 Lout = touche[y][x]
end
if Lout == "Space" then
 Lout = " "
else if Lout == "[ Maj ]" then
  Maj = not Maj
 end
end
if Maj == false then
 rednet.send(3,Lout)
end
end
R3dflyter
R3dflyter

Messages : 7
Date d'inscription : 30/03/2016

Revenir en haut Aller en bas

Clavier tactile par rednet Empty Re: Clavier tactile par rednet

Message par RedallAimeLeLUA Ven 6 Mai - 20:36

Wow, c'est très bien pour faire des claviers tactiles Surprised

RedallAimeLeLUA

Messages : 11
Date d'inscription : 05/05/2016

Revenir en haut Aller en bas

Revenir en haut


 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum