lego11

Contatore del gas

May 16th, 2018
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. --contatore del gas v1 (c) lego11
  2. term.clear()
  3. term.setCursorPos(1,1)
  4.  
  5. local metricubi = 0
  6. function refresh()
  7. term.setCursorPos(1,3)
  8. end
  9.  
  10. print("Compagnia Generale Contatori S.A. (New Radeon)")
  11. print("")
  12.  
  13. rhandle = assert(fs.open("metricubi", "r"), "ERRORE: file metri cubi non presente")
  14. rawmc = rhandle.readAll()
  15. metricubi = tonumber(rawmc)
  16. rhandle.close()
  17.  
  18.  
  19. while true do
  20. os.pullEvent("redstone")
  21. if redstone.getInput("back") == true then
  22. metricubi = metricubi + 1
  23. refresh()
  24. print(metricubi.." m³")
  25. whandle = assert(fs.open("metricubi", "w"), "TOC ERROR")
  26. whandle.write(tostring(metricubi))
  27. whandle.close()
  28. end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment