Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local wpp = require("wpp")
- local pretty = require("cc.pretty")
- local network_name = "network-name"
- local remote_pc_id = "8"
- wpp.wireless.connect(network_name) -- Starts a loop waiting for wpp rednet messages
- function getperiph(name)
- return "wpp@"..network_name.."://"..remote_pc_id.."/"..name
- end
- local altar_reader = peripheral.wrap("blockReader_2")
- local altar = peripheral.wrap("bloodmagic:altar_0")
- local input_barrel = peripheral.wrap("minecraft:barrel_1")
- local output_barrel = peripheral.wrap("minecraft:barrel_0")
- local lever_reader= peripheral.wrap("blockReader_3")
- local switch = peripheral.wrap("redstoneIntegrator_0")
- local monitorSide = "top"
- function getDesiredSlate()
- local slates = { "blank","reinforced","infused","demon","ethereal"}
- local index = lever_reader.getBlockData().State + 1
- if index > 4 then
- index = 1
- end
- return "bloodmagic:"..slates[index].."slate"
- end
- function getAltarData()
- return altar_reader.getBlockData()
- end
- function altarIsFull()
- return getAltarData().bloodAltar.Amount == getAltarData().bloodAltar.capacity
- end
- function pushToAltar()
- input_barrel.pushItems(peripheral.getName(altar),1,1)
- end
- function extractFromAltar()
- local current_item = getAltarData().Items[1].id
- if current_item == getDesiredSlate() then
- altar.pushItems(peripheral.getName(output_barrel),1,1)
- end
- end
- function altarHasItem()
- return #altar.list() > 0
- end
- function systemOn()
- return switch.getInput("right")
- end
- function statusReport()
- local monitor = getperiph(monitorSide)
- local status = systemOn()
- local altar_fill = altarIsFull()
- if status then
- status = "ON"
- else
- status = "OFF"
- end
- if altar_fill then
- altar_fill = "full"
- else
- altar_fill = "not full, waiting for altar to refill ( "..getAltarData().bloodAltar.Amount.." mb )"
- end
- local currentSlate = getDesiredSlate()
- local write = function(text) wpp.peripheral.call(monitor,"write",text) end
- wpp.peripheral.call(monitor,"clear")
- local phrases = {
- "Blood Altar System",
- "########################################################################",
- "System is : "..status,
- "Currently producing : "..currentSlate,
- "Altar is : "..altar_fill
- }
- for i,text in pairs(phrases) do
- wpp.peripheral.call(monitor,"setCursorPos",1,i)
- write(text)
- end
- end
- while true do
- if not systemOn() or not altarIsFull() then
- -- simply do nothing
- elseif not altarHasItem() then
- pushToAltar()
- else
- extractFromAltar()
- end
- statusReport()
- end
Add Comment
Please, Sign In to add comment