Clavier tactile par rednet
2 participants
Page 1 sur 1
Clavier tactile par rednet
--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- Messages : 7
Date d'inscription : 30/03/2016
Re: Clavier tactile par rednet
Wow, c'est très bien pour faire des claviers tactiles
RedallAimeLeLUA- Messages : 11
Date d'inscription : 05/05/2016
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum