Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local targetMonitor = os.getComputerID()==32 and "monitor_10" or "monitor_239"
- local mon = peripheral.wrap(targetMonitor)
- if not mon then
- error("Missing: "..targetMonitor,0)
- return
- end
- --computers
- os.loadAPI("pos/ZombieLeader")
- os.loadAPI("pos/ZombieMonitoring")
- os.loadAPI("pos/ZombieLightMgr")
- --turtle
- os.loadAPI("pos/ZombieKiller")
- --drive
- os.loadAPI("pos/ZombieLogs")
- os.loadAPI("pos/SpawnerLogs")
- local wi = peripheral.find("WorldInterface")
- local void = function() return "" end
- local function info(c,wrap)
- local block = wi.getBlockInfos(c.x,c.y,c.z)
- if os.getComputerID()~=32 then
- block.datatags = wi.getBlockDatatags(c.x,c.y,c.z).datatags
- end
- loaded = block.isChunkLoaded
- local connected,p = false,false
- if wrap then
- connected = peripheral.isPresent(c.name)
- p = connected and peripheral.wrap(c.name) or false
- end
- return block, loaded, connected, p
- end
- local function _computer(c)
- local block, loaded, connected, p = info(c,true)
- local present = block.blockName=="computercraft:CC-Computer"
- local isOn = block.datatags.on==1
- local reboot = not connected and void or function()
- if p.isOn() then
- p.reboot()
- else
- p.turnOn()
- end return p.isOn()
- end
- return {loaded, present, connected, isOn and "On" or "Off", {"reboot",reboot}}
- end
- local function _drive(c)
- local block, loaded, connected, p = info(c,true)
- local present = block.blockName=="computercraft:CC-Peripheral"
- local hasData,freeSpace = false, void
- if connected then
- hasData = p.isDiskPresent() and p.hasData()
- freeSpace = function() return hasData and fs.getFreeSpace("/"..p.getMountPath()) or "--" end
- end
- return {loaded, present, connected, hasData and "hasData" or "noData", {"freeSpace",freeSpace}}
- end
- local function _turtle(c)
- local block, loaded = info(c,false)
- local present = block.blockName=="computercraft:CC-TurtleExpanded"
- local isOn = block.datatags.on==1
- return {loaded, present, connected, isOn and "On" or "Off", {"--",void}}
- end
- local menu = {
- function() return {"ZombieLeader", _computer(ZombieLeader)} end,
- function() return {"Monitoring ", _computer(ZombieMonitoring)} end,
- function() return {"LightMgr ", _computer(ZombieLightMgr)} end,
- function() return {"ZombieKiller", _turtle(ZombieKiller)} end,
- function() return {"ZombieLogs ", _drive(ZombieLogs)} end,
- function() return {"SpawnerLogs ", _drive(SpawnerLogs)} end,
- }
- local function item(no,name,o,clicked)
- clicked = clicked or false
- local line1 = string.format("%s %s %s",
- name,
- o[1] and "loaded" or "unload",
- o[2] and "here" or "miss"
- )
- local line2 = string.format("%s %s%s %s",
- o[3] and "plugged " or "unplugged",
- o[4],
- string.rep(" ",math.max(0,7-string.len(o[4]))),
- clicked and o[5][2]() or o[5][1]
- )
- return line1,line2
- end
- local function printMenu(click,act)
- click = click or 0
- mon.setTextScale(1)
- mon.setCursorPos(1,1)
- mon.clear()
- local line,o,oF
- for line,oF in pairs(menu) do
- o = oF()
- local line1,line2 = item(line,o[1],o[2],click==line and act)
- mon.setCursorPos(1,(line*2)-1)
- if click==line then
- mon.setBackgroundColor(colors.yellow)
- mon.setTextColor(colors.black)
- else
- mon.setBackgroundColor(line%2==1 and colors.black or colors.gray)
- mon.setTextColor(line%2==1 and colors.lightGray or colors.white)
- end
- mon.clearLine()
- mon.write(line1)
- mon.setCursorPos(1,line*2)
- mon.clearLine()
- mon.write(line2)
- end
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- end
- local function traceEvent(e,p1,p2,p3,p4,p5)
- if e=="sound_played" or e=="timer" or e=="char" or e=="key_up" or e=="key" then
- return
- end
- print(string.format("e=%s\np=%s\np2=%s\np3=%s\np4=%s\np5=%s\n--\n",
- tostring(e) and tostring(e) or type(e),
- tostring(p1) and tostring(p1) or type(p1),
- tostring(p2) and tostring(p2) or type(p2),
- tostring(p3) and tostring(p3) or type(p3),
- tostring(p4) and tostring(p4) or type(p4),
- tostring(p5) and tostring(p5) or type(p5)
- ))
- end
- local sel,act,delay=0,false
- local tick = os.startTimer(2.5)
- local e,p,x,y,p4,p5
- while true do
- printMenu(sel,act)
- -- initMenu()
- act = false
- e,p,x,y,p4,p5 = os.pullEventRaw()
- traceEvent(e,p,x,y,p4,p5)
- if e=="monitor_touch" and p==targetMonitor then
- os.cancelTimer(tick)
- sel = math.ceil(y/2)
- act = true
- if delay then
- os.cancelTimer(delay)
- end
- delay = os.startTimer(2.5)
- tick = os.startTimer(2.5)
- elseif e=="timer" and p==tick then
- tick = os.startTimer(2.5)
- elseif e=="timer" and p==delay then
- sel = 0
- elseif e=="terminate" or (e=="key" and p==keys.q) then
- sleep(.3)
- printError("Terminated")
- return
- end
- end
Add Comment
Please, Sign In to add comment