Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local computer = require("computer")
- local component = require("component")
- local term = require("term")
- local math = require("math")
- local event = require("event")
- local string = require("string")
- local screen = component.getPrimary("screen")
- local gpu = component.gpu
- gpu.setResolution(63,25)
- local v1 = 0
- local sens = true
- local function setColor(bg,fg)
- gpu.setBackground(bg)
- gpu.setForeground(fg)
- end
- local function barre_verticale(x,y,hauteur,largeur,valeur,valmax)
- local k = 0
- local cur = math.floor((valeur / valmax) * hauteur)
- local dir = string.rep(" ",largeur)
- for k = 1, hauteur do
- local vy = y + hauteur - k
- if k <= cur then
- setColor(0x00FF00,0x0000FF)
- elseif k > cur then
- setColor(0x000000,0xFFFFFF)
- end
- gpu.set(x,vy,dir)
- if k == 1 then
- gpu.set(x,vy,dir)
- gpu.set(x,vy,string.format("Max %4s mB",valmax))
- elseif k == 3 then
- gpu.set(x,vy,dir)
- gpu.set(x,vy,string.format("Cur %4s mB",valeur))
- elseif k == 4 then
- gpu.set(x,vy,dir)
- gpu.set(x,vy,string.format(" %06.02f%% ",(valeur/valmax)*100))
- elseif k == 6 then
- gpu.set(x,vy," Carburant ")
- elseif k == 7 then
- gpu.set(x,vy," Réserve ")
- end
- setColor(0x000000,0xFFFFFF)
- end
- end
- gpu.set(1,1,"╔═════════════════════════════════════════════════════════════╗")
- gpu.set(1,2,"║ ║")
- gpu.set(1,3,"╠═════════════════════════════════════════════════════════════╣")
- gpu.set(1,4,"║ ║")
- gpu.set(1,5,"║ ║")
- gpu.set(1,6,"║ ║")
- gpu.set(1,7,"║ ║")
- gpu.set(1,8,"║ ║")
- gpu.set(1,9,"║ ║")
- gpu.set(1,10,"║ ║")
- gpu.set(1,11,"║ ║")
- gpu.set(1,12,"║ ║")
- gpu.set(1,13,"║ ║")
- gpu.set(1,14,"║ ║")
- gpu.set(1,15,"║ ║")
- gpu.set(1,16,"║ ║")
- gpu.set(1,17,"║ ║")
- gpu.set(1,18,"║ ║")
- gpu.set(1,19,"║ ║")
- gpu.set(1,20,"║ ║")
- gpu.set(1,21,"║ ║")
- gpu.set(1,22,"║ ║")
- gpu.set(1,23,"║ ║")
- gpu.set(1,24,"║ ║")
- gpu.set(1,25,"╚═════════════════════════════════════════════════════════════╝")
- local function onTouch(event,adress,x,y,clic,pseudo)
- local tclic
- if clic == 0 then
- tclic = "Clic gauche"
- elseif clic == 1 then
- tclic = "Clic droit"
- else
- tclic = "Clic inconnu"
- end
- gpu.set(2,2," "..tclic.." de la part de "..pseudo.." / X : "..string.format("% 3s",x).." / Y : "..string.format("% 3s",y))
- if clic == 0 then
- if x==1 and y==1 then
- computer.pushSignal("quit")
- term.setCursor(1,1)
- return false
- elseif 1 == 0 then
- end
- end
- end
- local function onTimer(_,timer)
- if sens == true then
- v1 = v1 + 4
- elseif sens == false then
- v1 = v1 - 4
- end
- if v1 == 400 then
- sens = false
- elseif v1 == 0 then
- sens = true
- end
- gpu.set(50,3,string.format("%.02f ",v1))
- barre_verticale(30,4,25,7,v1,400)
- barre_verticale(10,4,25,7,v1,400)
- return true
- end
- event.listen("touch",onTouch)
- local timer = event.timer(0.2,onTimer,math.huge)
- event.pull("quit")
- event.cancel(timer)
- event.ignore("touch",onTouch)
- gpu.setResolution(160,50)
- gpu.fill(1,1,160,50," ")
- term.clear()
- --Créé par sshikamaru. Vous avez le droit de l'utiliser mais pas de le distribuer.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement