Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitor = peripheral.wrap("top")
- monYCount = 1
- function clean()
- monitor.clear()
- monitor.setCursorPos(1,1)
- term.clear()
- term.setCursorPos(1,1)
- monYCount = monYCount - monYCount + 1
- end
- function printclr(...)
- local colors = {
- ["white"] = colors.white,
- ["orange"] = colors.orange,
- ["magenta"] = colors.magenta,
- ["lightBlue"] = colors.lightBlue,
- ["yellow"] = colors.yellow,
- ["lime"] = colors.lime,
- ["pink"] = colors.pink,
- ["gray"] = colors.gray,
- ["lightGray"] = colors.lightGray,
- ["cyan"] = colors.cyan,
- ["purple"] = colors.purple,
- ["blue"] = colors.blue,
- ["brown"] = colors.brown,
- ["green"] = colors.green,
- ["red"] = colors.red,
- ["black"] = colors.black,
- }
- local args = {...}
- for i = 1, #args do
- local arg = args[i]
- if type(arg) == "string" and colors[arg] then
- term.setTextColor(colors[arg])
- monitor.setTextColor(colors[arg])
- else
- write(tostring(arg))
- monitor.write(tostring(arg))
- end
- end
- term.setTextColor(colors.white)
- monYCount = monYCount + 2
- monitor.setCursorPos(1, monYCount)
- monitor.setTextColor(colors.white)
- term.setCursorPos(1, monYCount)
- end
- function restockVillagers()
- local peripheralNames = {
- "trading_interface_1",
- "trading_interface_2",
- "trading_interface_3",
- "trading_interface_4",
- "trading_interface_5",
- "trading_interface_6",
- "trading_interface_7",
- "trading_interface_8",
- "trading_interface_9",
- "trading_interface_10"
- }
- for i, peripheralName in ipairs(peripheralNames) do
- local success, error = pcall(function()
- peripheral.wrap(peripheralName).restock()
- end)
- if not success then
- --error code can go here.
- end
- end
- end
- function activeTimer()
- while timeToWait > 0 do
- clean()
- timeToWait = math.floor((timeToWait - 0.1) * 10) / 10
- printclr("white","Redstone ","red", "active")
- printclr("yellow","Restocking trades")
- printclr("gray","Restocking in:","\n")
- --Jank location fix
- monYCount = monYCount - 1
- monitor.setCursorPos(1, monYCount)
- monitor.setTextColor(colors.white)
- term.setCursorPos(1, monYCount)
- printclr("gray",timeToWait,"gray")
- --Jank location fix
- monYCount = monYCount - 2
- monitor.setCursorPos(5, monYCount)
- monitor.setTextColor(colors.white)
- term.setCursorPos(5, monYCount)
- printclr("gray","Seconds","\n")
- sleep(0.1)
- end
- end
- function inactiveTimer()
- while timeToWait > 0 do
- clean()
- timeToWait = math.floor((timeToWait - 0.1) * 10) / 10
- printclr("white","Redstone ","gray", "inactive")
- printclr("yellow","Not restocking trades")
- printclr("gray","Checking for redstone in:","\n")
- --Jank location fix
- monYCount = monYCount - 1
- monitor.setCursorPos(1, monYCount)
- monitor.setTextColor(colors.white)
- term.setCursorPos(1, monYCount)
- printclr("gray",timeToWait,"gray")
- --Jank location fix
- monYCount = monYCount - 2
- monitor.setCursorPos(5, monYCount)
- monitor.setTextColor(colors.white)
- term.setCursorPos(5, monYCount)
- printclr("gray","Seconds","\n")
- sleep(0.1)
- end
- end
- while true do
- clean()
- if redstone.getInput("right") then
- restockVillagers()
- timeToWait = 5
- activeTimer()
- else
- timeToWait = 5
- inactiveTimer()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement