jille_Jr icon

CC: item counter (using bundled cable)

jille_Jr | PRO | 10/06/12 07:59:16 PM UTC | 0 ⭐ | 439 👁️ | Never ⏰ | []
Lua |

560 B

|

None

|

0 👍

/

0 👎

local count = 0
 
if not fs.exists(".itemCount") then
  countFile = fs.open(".itemCount", "w")
  countFile.write(count)
  countFile.close()
else
  countFile = fs.open(".itemCount", "r")
  count = tonumber(countFile.readLine())
  countFile.close()
end
 
term.clear()
 
while true do
  term.setCursorPos(3,2)
  print("Total items passed: "..count.."   ")
  os.pullEvent("redstone")
  if rs.testBundledInput("bottom", color.black) then
    count = count + 1
    countFile = fs.open(".itemCount", "w")
    countFile.write(count)
    countFile.close()
  end
end

Comments