Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local wi = peripheral.find("WorldInterface")
- local function printerCount()
- local h = wi.getBlockDatatags(-584,29,123)
- if h.datatags.id~="ccprinter" then
- error("Missing printer in coords -584,29,123",0)
- exit()
- end
- if #h.datatags.Items>=13 then
- --tous les slots sont occupés
- return 6
- elseif #h.datatags.Items==0 then
- --tous les slots sont vides
- return 0
- else
- local count,_,s = 0
- for _,s in pairs(h.datatags.Items) do
- if s.Slot >= 7 then
- count = count+1
- end
- end
- return count
- end
- end
- local function hopperCount()
- local h = wi.getBlockDatatags(-584,28,123)
- if h.datatags.id~="Hopper" then
- error("Missing hopper in coords -584,28,123",0)
- exit()
- end
- return #h.datatags.Items
- end
- local function printTickets()
- local count,i = 0
- while count < 5 do
- count = hopperCount()
- if count < 5 then
- for i=1,5-count do
- shell.run("/ticket")
- end
- end
- end
- end
- local e,p
- local countdown = 0
- local batch = os.startTimer(.1)
- local tick = os.startTimer(1)
- while true do
- term.setCursorPos(1,1)
- term.clear()
- term.write("Countdown: "..countdown)
- e,p = os.pullEvent("timer")
- if e=="timer" and p==batch then
- os.cancelTimer(tick)
- if printerCount()<6 then
- printTickets()
- countdown = 10
- else
- countdown = 40
- end
- batch = os.startTimer(countdown)
- tick = os.startTimer(1)
- elseif e=="timer" and p==tick then
- countdown = math.max(0,countdown-1)
- tick = os.startTimer(1)
- end
- end
Add Comment
Please, Sign In to add comment