Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("left")
- mon = peripheral.wrap("right")
- local total_counted = 0
- local counted_hour = 0
- local old_total_counted = 0
- local lst_of_counted = {}
- local cycle = 0
- function sum(t)
- local sum = 0
- for k,v in pairs(t) do
- sum = sum + v
- end
- return sum
- end
- while true do
- local currently_counted = 0
- x,y,z = rednet.receive()
- old_total_counted = total_counted
- table.insert(lst_of_counted,old_total_counted)
- cycle = cycle+1
- total_counted = y
- currently_counted = y - old_total_counted
- if cycle > 11 then
- table.remove(lst_of_counted, 1)
- --delete last item of table and then sum together all
- counted_hour = sum(lst_of_counted)
- end
- mon.clear()
- print("+-------------------------------------+")
- print("\n")
- print("\nWe have produced a total of", total_counted, "pieces of coal!\n")
- print(total_counted,"makes", math.floor(total_counted/64),"stacks of coal!\n")
- print("In the last batch there was", currently_counted, "pieces of coal!\n")
- if cycle > 10 then
- print("In the last hour we have produced", counted_hour,"pieces of coal!")
- print("\n")
- print("\n")
- print("+-------------------------------------+")
- else do
- print("In the last hour we have produced [N/A] pieces of coal!") end
- print("\n")
- print("\n")
- print(lst_of_counted)
- print("+-------------------------------------+")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement