SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local targetMonitor = "monitor_239" |
| 1 | + | local targetMonitor = os.getComputerID()==32 and "monitor_10" or "monitor_239" |
| 2 | local mon = peripheral.wrap(targetMonitor) | |
| 3 | if not mon then | |
| 4 | - | error("Missing: monitor_239",0)
|
| 4 | + | error("Missing: "..targetMonitor,0)
|
| 5 | - | return |
| 5 | + | return |
| 6 | end | |
| 7 | ||
| 8 | - | --interfaces |
| 8 | + | |
| 9 | - | os.loadAPI("pos/ZombieWI")
|
| 9 | + | |
| 10 | - | os.loadAPI("pos/ZombieED")
|
| 10 | + | |
| 11 | os.loadAPI("pos/ZombieLightMgr")
| |
| 12 | --turtle | |
| 13 | os.loadAPI("pos/ZombieKiller")
| |
| 14 | --drive | |
| 15 | os.loadAPI("pos/ZombieLogs")
| |
| 16 | os.loadAPI("pos/SpawnerLogs")
| |
| 17 | ||
| 18 | local wi = peripheral.find("WorldInterface")
| |
| 19 | ||
| 20 | local void = function() return "" end | |
| 21 | ||
| 22 | - | local ed = peripheral.isPresent("EntityDetector")
|
| 22 | + | |
| 23 | local block = wi.getBlockInfos(c.x,c.y,c.z) | |
| 24 | if os.getComputerID()~=32 then | |
| 25 | block.datatags = wi.getBlockDatatags(c.x,c.y,c.z).datatags | |
| 26 | end | |
| 27 | - | local block = wi.getBlockInfos(c.x,c.y,c.z) |
| 27 | + | loaded = block.isChunkLoaded |
| 28 | - | block.datatags = wi.getBlockDatatags(c.x,c.y,c.z).datatags |
| 28 | + | local connected,p = false,false |
| 29 | - | loaded = block.isChunkLoaded |
| 29 | + | if wrap then |
| 30 | - | local connected,p = false,false |
| 30 | + | connected = peripheral.isPresent(c.name) |
| 31 | - | if wrap then |
| 31 | + | p = connected and peripheral.wrap(c.name) or false |
| 32 | - | connected = peripheral.isPresent(c.name) |
| 32 | + | end |
| 33 | - | p = connected and peripheral.wrap(c.name) or false |
| 33 | + | return block, loaded, connected, p |
| 34 | - | end |
| 34 | + | |
| 35 | - | return block, loaded, connected, p |
| 35 | + | |
| 36 | local function _computer(c) | |
| 37 | local block, loaded, connected, p = info(c,true) | |
| 38 | - | local function _interface(c,name) |
| 38 | + | local present = block.blockName=="computercraft:CC-Computer" |
| 39 | - | local block, loaded, connected = info(c) |
| 39 | + | local isOn = block.datatags.on==1 |
| 40 | - | local present = block.blockName == "lifeisperipheral:"..name |
| 40 | + | local reboot = not connected and void or function() |
| 41 | - | return {loaded, present, peripheral.isPresent(c.name), "--", {"",void}}
|
| 41 | + | if p.isOn() then |
| 42 | p.reboot() | |
| 43 | else | |
| 44 | p.turnOn() | |
| 45 | - | local block, loaded, connected, p = info(c,true) |
| 45 | + | end return p.isOn() |
| 46 | - | local present = block.blockName=="computercraft:CC-Computer" |
| 46 | + | end |
| 47 | - | local isOn = block.datatags.on==1 |
| 47 | + | return {loaded, present, connected, isOn and "On" or "Off", {"reboot",reboot}}
|
| 48 | - | local reboot = connected and function() if p.isOn() then p.reboot() else p.turnOn() end return p.isOn() end or function() return "--" end |
| 48 | + | |
| 49 | - | return {loaded, present, connected, isOn and "On" or "Off", {"reboot",reboot}}
|
| 49 | + | |
| 50 | local block, loaded, connected, p = info(c,true) | |
| 51 | local present = block.blockName=="computercraft:CC-Peripheral" | |
| 52 | - | local block, loaded, connected, p = info(c,true) |
| 52 | + | local hasData,freeSpace = false, void |
| 53 | - | local present = block.blockName=="computercraft:CC-Peripheral" |
| 53 | + | if connected then |
| 54 | - | local hasData,freeSpace = false, void |
| 54 | + | hasData = p.isDiskPresent() and p.hasData() |
| 55 | - | if connected then |
| 55 | + | freeSpace = function() return hasData and fs.getFreeSpace("/"..p.getMountPath()) or "--" end
|
| 56 | - | hasData = p.isDiskPresent() and p.hasData() |
| 56 | + | end |
| 57 | - | freeSpace = function() return fs.getFreeSpace("/"..p.getMountPath()) end
|
| 57 | + | return {loaded, present, connected, hasData and "hasData" or "noData", {"freeSpace",freeSpace}}
|
| 58 | - | end |
| 58 | + | |
| 59 | - | return {loaded, present, connected, hasData and "hasData" or "noData", {"freeSpace",freeSpace}}
|
| 59 | + | |
| 60 | local block, loaded = info(c,false) | |
| 61 | local present = block.blockName=="computercraft:CC-TurtleExpanded" | |
| 62 | - | local block, loaded = info(c,false) |
| 62 | + | local isOn = block.datatags.on==1 |
| 63 | - | local present = block.blockName=="computercraft:CC-TurtleExpanded" |
| 63 | + | return {loaded, present, connected, isOn and "On" or "Off", {"--",void}}
|
| 64 | - | local isOn = block.datatags.on==1 |
| 64 | + | |
| 65 | - | return {loaded, present, connected, isOn and "On" or "Off", {"--",void}}
|
| 65 | + | |
| 66 | local menu = {
| |
| 67 | function() return {"ZombieLeader", _computer(ZombieLeader)} end,
| |
| 68 | function() return {"Monitoring ", _computer(ZombieMonitoring)} end,
| |
| 69 | - | -- {"WorldInterface", _interface(ZombieWI,"WorldInterface")},
|
| 69 | + | function() return {"LightMgr ", _computer(ZombieLightMgr)} end,
|
| 70 | - | -- {"EntityDetector", _interface(ZombieED,"EntityDetector")},
|
| 70 | + | function() return {"ZombieKiller", _turtle(ZombieKiller)} end,
|
| 71 | - | {"ZombieLeader", _computer(ZombieLeader)},
|
| 71 | + | function() return {"ZombieLogs ", _drive(ZombieLogs)} end,
|
| 72 | - | {"Monitoring ", _computer(ZombieMonitoring)},
|
| 72 | + | function() return {"SpawnerLogs ", _drive(SpawnerLogs)} end,
|
| 73 | - | {"LightMgr ", _computer(ZombieLightMgr)},
|
| 73 | + | |
| 74 | - | {"ZombieKiller", _turtle(ZombieKiller)},
|
| 74 | + | |
| 75 | - | {"ZombieLogs ", _drive(ZombieLogs)},
|
| 75 | + | |
| 76 | - | {"SpawnerLogs ", _drive(SpawnerLogs)},
|
| 76 | + | clicked = clicked or false |
| 77 | local line1 = string.format("%s %s %s",
| |
| 78 | name, | |
| 79 | o[1] and "loaded" or "unload", | |
| 80 | - | clicked = clicked or false |
| 80 | + | o[2] and "here" or "miss" |
| 81 | - | local line1 = string.format("%s %s %s",
|
| 81 | + | ) |
| 82 | - | name, |
| 82 | + | local line2 = string.format("%s %s%s %s",
|
| 83 | - | o[1] and "loaded" or "unload", |
| 83 | + | o[3] and "plugged " or "unplugged", |
| 84 | - | o[2] and "here" or "miss" |
| 84 | + | o[4], |
| 85 | - | ) |
| 85 | + | string.rep(" ",math.max(0,7-string.len(o[4]))),
|
| 86 | - | local line2 = string.format("%s %s%s %s",
|
| 86 | + | clicked and o[5][2]() or o[5][1] |
| 87 | - | o[3] and "plugged " or "unplugged", |
| 87 | + | ) |
| 88 | - | o[4], |
| 88 | + | return line1,line2 |
| 89 | - | string.rep(" ",math.max(0,7-string.len(o[4]))),
|
| 89 | + | |
| 90 | - | clicked and o[5][2]() or o[5][1] |
| 90 | + | |
| 91 | - | ) |
| 91 | + | |
| 92 | - | return line1,line2 |
| 92 | + | click = click or 0 |
| 93 | mon.setTextScale(1) | |
| 94 | mon.setCursorPos(1,1) | |
| 95 | mon.clear() | |
| 96 | - | click = click or 0 |
| 96 | + | local line,o,oF |
| 97 | - | mon.setTextScale(1) |
| 97 | + | for line,oF in pairs(menu) do |
| 98 | - | mon.setCursorPos(1,1) |
| 98 | + | o = oF() |
| 99 | - | mon.clear() |
| 99 | + | local line1,line2 = item(line,o[1],o[2],click==line and act) |
| 100 | - | local line,o |
| 100 | + | mon.setCursorPos(1,(line*2)-1) |
| 101 | - | for line,o in pairs(menu) do |
| 101 | + | if click==line then |
| 102 | - | local line1,line2 = item(line,o[1],o[2],click==line and act) |
| 102 | + | mon.setBackgroundColor(colors.yellow) |
| 103 | - | mon.setCursorPos(1,(line*2)-1) |
| 103 | + | mon.setTextColor(colors.black) |
| 104 | - | if click==line then |
| 104 | + | else |
| 105 | - | mon.setBackgroundColor(colors.yellow) |
| 105 | + | mon.setBackgroundColor(line%2==1 and colors.black or colors.gray) |
| 106 | - | mon.setTextColor(colors.black) |
| 106 | + | mon.setTextColor(line%2==1 and colors.lightGray or colors.white) |
| 107 | - | else |
| 107 | + | end |
| 108 | - | mon.setBackgroundColor(line%2==1 and colors.black or colors.gray) |
| 108 | + | mon.clearLine() |
| 109 | - | mon.setTextColor(line%2==1 and colors.lightGray or colors.white) |
| 109 | + | mon.write(line1) |
| 110 | - | end |
| 110 | + | mon.setCursorPos(1,line*2) |
| 111 | - | mon.clearLine() |
| 111 | + | mon.clearLine() |
| 112 | - | mon.write(line1) |
| 112 | + | mon.write(line2) |
| 113 | - | mon.setCursorPos(1,line*2) |
| 113 | + | end |
| 114 | - | mon.clearLine() |
| 114 | + | mon.setBackgroundColor(colors.black) |
| 115 | - | mon.write(line2) |
| 115 | + | mon.setTextColor(colors.white) |
| 116 | - | end |
| 116 | + | |
| 117 | - | mon.setBackgroundColor(colors.black) |
| 117 | + | |
| 118 | - | mon.setTextColor(colors.white) |
| 118 | + | |
| 119 | if e=="sound_played" or e=="timer" or e=="char" or e=="key_up" or e=="key" then | |
| 120 | return | |
| 121 | end | |
| 122 | - | if e=="timer" or e=="char" or e=="key_up" or e=="key" then |
| 122 | + | print(string.format("e=%s\np=%s\np2=%s\np3=%s\np4=%s\np5=%s\n--\n",
|
| 123 | - | return |
| 123 | + | tostring(e) and tostring(e) or type(e), |
| 124 | - | end |
| 124 | + | tostring(p1) and tostring(p1) or type(p1), |
| 125 | - | print(string.format("e=%s\np=%s\np2=%s\np3=%s\np4=%s\np5=%s\n--\n",
|
| 125 | + | tostring(p2) and tostring(p2) or type(p2), |
| 126 | - | tostring(e) and tostring(e) or type(e), |
| 126 | + | tostring(p3) and tostring(p3) or type(p3), |
| 127 | - | tostring(p1) and tostring(p1) or type(p1), |
| 127 | + | tostring(p4) and tostring(p4) or type(p4), |
| 128 | - | tostring(p2) and tostring(p2) or type(p2), |
| 128 | + | tostring(p5) and tostring(p5) or type(p5) |
| 129 | - | tostring(p3) and tostring(p3) or type(p3), |
| 129 | + | )) |
| 130 | - | tostring(p4) and tostring(p4) or type(p4), |
| 130 | + | |
| 131 | - | tostring(p5) and tostring(p5) or type(p5) |
| 131 | + | |
| 132 | - | )) |
| 132 | + | local tick = os.startTimer(2.5) |
| 133 | local e,p,x,y,p4,p5 | |
| 134 | while true do | |
| 135 | - | local tick = os.startTimer(2) |
| 135 | + | printMenu(sel,act) |
| 136 | -- initMenu() | |
| 137 | act = false | |
| 138 | - | printMenu(sel,act) |
| 138 | + | e,p,x,y,p4,p5 = os.pullEventRaw() |
| 139 | - | -- initMenu() |
| 139 | + | traceEvent(e,p,x,y,p4,p5) |
| 140 | - | act = false |
| 140 | + | if e=="monitor_touch" and p==targetMonitor then |
| 141 | - | e,p,x,y,p4,p5 = os.pullEventRaw() |
| 141 | + | os.cancelTimer(tick) |
| 142 | - | traceEvent(e,p,x,y,p4,p5) |
| 142 | + | sel = math.ceil(y/2) |
| 143 | - | if e=="monitor_touch" and p==targetMonitor then |
| 143 | + | act = true |
| 144 | - | sel = math.ceil(y/2) |
| 144 | + | if delay then |
| 145 | - | if delay then |
| 145 | + | os.cancelTimer(delay) |
| 146 | - | os.cancelTimer(delay) |
| 146 | + | end |
| 147 | - | end |
| 147 | + | delay = os.startTimer(2.5) |
| 148 | - | delay = os.startTimer(5) |
| 148 | + | tick = os.startTimer(2.5) |
| 149 | - | elseif e=="timer" and p==tick then |
| 149 | + | elseif e=="timer" and p==tick then |
| 150 | - | tick = os.startTimer(2) |
| 150 | + | tick = os.startTimer(2.5) |
| 151 | - | elseif e=="timer" and p==delay then |
| 151 | + | elseif e=="timer" and p==delay then |
| 152 | - | sel = 0 |
| 152 | + | sel = 0 |
| 153 | - | elseif e=="terminate" or (e=="key" and p==keys.q) then |
| 153 | + | elseif e=="terminate" or (e=="key" and p==keys.q) then |
| 154 | - | sleep(.3) |
| 154 | + | sleep(.3) |
| 155 | - | printError("Terminated")
|
| 155 | + | printError("Terminated")
|
| 156 | - | return |
| 156 | + | return |
| 157 | - | end |
| 157 | + | end |
| 158 | end |