Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Program pro dvojity sedmisegmentovy display
- Verze 0.8 beta
- Vytvoril SVty
- http://pastebin.com/u/SVty
- http://www.youtube.com/user/SVtyPlay
- --]]
- --***********************
- num1 = { 63, 6, 91, 79, 102, 109, 125, 7, 127, 111, 0 }
- num2 = { 8064, 768, 11648, 10112, 13056, 13952, 16000, 896, 16256, 14208, 0 }
- sr = 0
- sl = 0
- s = "r"
- exit = false
- rednet.open("bottom")
- --mazani
- rs.setBundledOutput("left",0)
- rs.setBundledOutput("right",0)
- rs.setBundledOutput("back",0)
- rs.setBundledOutput("top",0)
- function start()
- id, y = rednet.receive()
- end
- function spousteni()
- if y > 99999 and s=="r" then
- chyba()
- elseif y>999 and s=="l" then
- chyba()
- else
- x = y
- vypocet()
- end
- end
- function vypocet()
- e = math.floor (x / 10000)
- d = math.floor((x - (e * 10000)) / 1000)
- a = math.floor((x - ((e * 10000) + (d * 1000))) /100)
- b = math.floor((x - ((e * 10000) + (d * 1000) + (a * 100))) /10)
- c = math.floor (x - ((e * 10000) + (d * 1000) + (a * 100) + (b * 10)))
- end
- function printl()
- if e == 0 then e = 10 end
- if e == 10 and d == 0 then d = 10 end
- if e == 10 and d == 10 and a == 0 then a = 10 end
- if e == 10 and d == 10 and a == 10 and b == 0 then b = 10 end
- if e == 10 and not(d == 10) then
- e = d
- d = a
- a = b
- b = c
- c = 10
- elseif e == 10 and d == 10 and not(a == 10) then
- e = a
- d = b
- a = c
- b = 10
- c = 10
- elseif e == 10 and d == 10 and a == 10 and not(b == 10) then
- e = b
- d = c
- a = 10
- b = 10
- c = 10
- elseif e == 10 and d == 10 and a == 10 and b == 10 and not(c == 10) then
- e = c
- d = 10
- a = 10
- b = 10
- c = 10
- end
- print(e)
- print(d)
- print(a)
- print(b)
- print(c)
- sl = (num1[e + 1])
- rs.setBundledOutput("left",(num1[a + 1]) + (num2[d + 1]))
- rs.setBundledOutput("top",sl + sr)
- rs.setBundledOutput("back",(num1[c + 1]) + (num2[b + 1]))
- end
- function printr()
- if a == 0 then a = 10 end
- if a == 10 and b == 0 then b = 10 end
- print(a)
- print(b)
- print(c)
- sr = (num2[c + 1])
- rs.setBundledOutput("right",(num2[a + 1]) + (num1[b + 1]))
- rs.setBundledOutput("top",sl + sr)
- end
- function leftd()
- rgh = rs.getBundledInput("right")
- top = rs.getBundledInput("top")
- lft = rs.getBundledInput("left")
- bck = rs.getBundledInput("back")
- for rep=1,3 do
- rs.setBundledOutput("right",10240+48)
- rs.setBundledOutput("top",14208+118)
- rs.setBundledOutput("left",15360)
- rs.setBundledOutput("back",0)
- sleep(0.5)
- rs.setBundledOutput("right",0)
- rs.setBundledOutput("top",0)
- rs.setBundledOutput("left",0)
- rs.setBundledOutput("back",0)
- sleep(0.5)
- end
- rs.setBundledOutput("right",rgh)
- rs.setBundledOutput("top",top)
- rs.setBundledOutput("left",lft)
- rs.setBundledOutput("back",bck)
- end
- function rightd()
- rgh = rs.getBundledInput("right")
- top = rs.getBundledInput("top")
- lft = rs.getBundledInput("left")
- bck = rs.getBundledInput("back")
- for rep=1,3 do
- rs.setBundledOutput("right",7168+121)
- rs.setBundledOutput("top",14464+120)
- rs.setBundledOutput("left",0)
- rs.setBundledOutput("back",0)
- sleep(0.5)
- rs.setBundledOutput("right",0)
- rs.setBundledOutput("top",0)
- rs.setBundledOutput("left",0)
- rs.setBundledOutput("back",0)
- sleep(0.5)
- end
- rs.setBundledOutput("right",rgh)
- rs.setBundledOutput("top",top)
- rs.setBundledOutput("left",lft)
- rs.setBundledOutput("back",bck)
- end
- function chyba()
- rgh = rs.getBundledInput("right")
- top = rs.getBundledInput("top")
- lft = rs.getBundledInput("left")
- bck = rs.getBundledInput("back")
- for rep=1,3 do
- rs.setBundledOutput("right",15488+80)
- rs.setBundledOutput("top",10240+92)
- rs.setBundledOutput("left",10240)
- rs.setBundledOutput("back",0)
- sleep(0.5)
- rs.setBundledOutput("right",0)
- rs.setBundledOutput("top",0)
- rs.setBundledOutput("left",0)
- rs.setBundledOutput("back",0)
- sleep(0.5)
- end
- rs.setBundledOutput("right",rgh)
- rs.setBundledOutput("top",top)
- rs.setBundledOutput("left",lft)
- rs.setBundledOutput("back",bck)
- end
- --********************************
- function help()
- print("----------")
- print(" Napoveda ")
- print("----------")
- print("")
- print("/left - pro zapis na levou stranu displaye")
- print("/right - pro zapis na pravou stranu displaye")
- print("/day - pro zobraneni Den na pravou stranu displaye")
- print("/help - zobrazeni napovedy")
- print("/exit - konec programu")
- end
- function day()
- sr = (10752)
- rs.setBundledOutput("right",12032+121)
- rs.setBundledOutput("top",sl + sr)
- print("Na prave strane displaye je zobrazeno Den:")
- s = "r"
- end
- function ep()
- end
- function exit1()
- for rep=1,3 do
- rs.setBundledOutput("right",121)
- rs.setBundledOutput("top",6912+48)
- rs.setBundledOutput("left",15360)
- rs.setBundledOutput("back",0)
- sleep(0.5)
- rs.setBundledOutput("right",0)
- rs.setBundledOutput("top",0)
- rs.setBundledOutput("left",0)
- rs.setBundledOutput("back",0)
- sleep(0.5)
- end
- rs.setBundledOutput("right",8064+62)
- rs.setBundledOutput("top",15360+115)
- rs.setBundledOutput("left",7936+120)
- rs.setBundledOutput("back",0)
- end
- --********************************
- --program
- while exit == false do
- start()
- if not tonumber(y) then
- if y == "/right" then
- s = "r"
- leftd()
- elseif y == "/left" then
- s = "l"
- rightd()
- elseif y == "/day" then
- day()
- elseif y == "/help" then
- help()
- elseif y == "/exit" then
- exit = true
- exit1()
- else
- print(y.." je neplatny prikaz!")
- end
- else
- print(y)
- y = tonumber(y)
- spousteni()
- if s == "r" then
- printl()
- else
- printr()
- end
- end
- sleep(1)
- print(s)
- end
Advertisement
Add Comment
Please, Sign In to add comment