dadragon84

CC counter2

Mar 1st, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. -- ComputerCraft Item Counter
  2. --    originally coded by Ingrimmm (theMindCrafters.com)
  3. --    this spaghetti nightmare comes with no warrantee but it cant
  4. --    mess anything up so have fun :)
  5. -- USAGE: uses a (hard-coded, I know, I know) redstone signal on the
  6. --    right to signal when an item has passed through the system
  7.  
  8. local hMonitor=peripheral.wrap("left")
  9. local count,count_1,count_2,count_3=0,0,0,0
  10. local day1, day2, day3=0,0,0
  11. local days=0
  12. local total=0
  13. local activeday=os.day()
  14. local today=os.day()
  15. term.redirect(hMonitor)
  16.  
  17. while true do
  18. today=os.day()
  19. event = os.pullEvent()
  20.  
  21. if today ~= activeday then
  22. --store hist
  23. count_3=count_2
  24. count_2=count_1
  25. count_1=count
  26. day3=day2
  27. day2=day1
  28. day1=activeday
  29. --add to totals
  30. days=days+1
  31. --reset for today
  32. count = 0
  33. activeday=today
  34. end
  35.  
  36. if event=="redstone" and rs.getInput("right") then
  37. count = count + 1
  38. total = total + 1
  39. end
  40.  
  41. term.clear()
  42. print("Day: "..today)
  43. print("Count: " .. count)
  44. print("Last x counts: ")
  45. print("   Day "..day1..": "..count_1)
  46. print("   Day "..day2..": "..count_2)
  47. print("   Day "..day3..": "..count_3)
  48. print("Days since reset: "..days)
  49. print("UU-Matter since reset: "..total)
  50.  
  51. if event=="redstone" and rs.getInput("back") then
  52. break
  53. end
  54.  
  55. end
  56. term.clear()
  57. term.restore()
Add Comment
Please, Sign In to add comment