Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pcid = os.getComputerID()
- mon = peripheral.wrap("back")
- gx,gy = mon.getSize()
- dbcol = colors.black
- dtcol = colors.lime
- machines = peripheral.getNames()
- com = ""
- for v, k in pairs(machines) do
- if string.find(k,"drive") ~= nil then
- drive = peripheral.wrap(k)
- driveAPI = k
- methods = peripheral.getMethods(k)
- break
- end
- end
- function readDisk(state)
- if state == nil then
- diskR = fs.open("disk/akw.lua","r")
- reading = diskR.readAll()
- diskR.close()
- return reading
- else
- diskR = fs.open("disk/"..state..".lua","r")
- reading = diskR.readAll()
- diskR.close()
- return reading
- end
- end
- function saveDisk(text,state)
- if state == nil then
- disk = fs.open("disk/akw.lua","w")
- disk.write(text)
- disk.close()
- else
- disk = fs.open("disk/"..state..".lua","w")
- disk.write(text)
- disk.close()
- end
- end
- function mbut(cx,cy,text,bcol,tcol)
- if bcol == nil then
- bcol = dbcol
- end
- if tcol == nil then
- tcol = dtcol
- end
- mon.setCursorPos(cx,cy)
- mon.setBackgroundColor(bcol)
- mon.setTextColor(tcol)
- mon.write(string.rep(" ",#text))
- mon.setCursorPos(cx,cy)
- mon.write(text)
- mon.setBackgroundColor(dbcol)
- mon.setTextColor(dtcol)
- end
- a = fs.exists("disk/ids.lua")
- if a == nil then
- error("No IDs set")
- else
- ids = readDisk("ids")
- lines = {}
- for s in ids:gmatch("[^\n]+") do
- table.insert(lines, s)
- ids = lines
- end
- end
- while true do
- evt = {os.pullEvent("monitor_touch")}
- x = evt[3]
- y = evt[4]
- mbut(54,3,"X: " .. x .. " Y: " .. y)
- for v, k in pairs(ids) do
- reactor_s = textutils.unserialize(readDisk(k))
- reactor_name = reactor_s[1]
- reactor_x = reactor_s[2]
- reactor_y = reactor_s[3]
- reactor_status = reactor_s[4]
- if y == reactor_y + 1 and x >= reactor_x + 8 and x <= reactor_x + 12 then
- print(x .. ": " .. reactor_x + 8)
- print(x .. ": " .. reactor_x + 12)
- print(y .. ": " .. reactor_y + 1)
- reactor = peripheral.wrap(reactor_name)
- reactorCore = reactor.getReactorCore()
- data = reactorCore.getMetadata()
- stats = data["reactor"]
- if reactor_status == "false" then
- print("False")
- reactor_status = true
- save = fs.open("disk/"..reactor_name .. ".lua","w")
- save.writeLine(reactor_name)
- save.writeLine(reactor_x)
- save.writeLine(reactor_y)
- save.writeLine(reactor_status)
- save.close()
- else
- print("True")
- reactor_status = false
- save = fs.open("disk/"..reactor_name .. ".lua","w")
- save.writeLine(reactor_name)
- save.writeLine(reactor_x)
- save.writeLine(reactor_y)
- save.writeLine(reactor_status)
- save.close()
- end
- reactor_status_r = stats.active
- end
- end
- if x >= 18 and x <= 19 and y == 3 then
- state = true
- saveDisk(state)
- mbut(29,35," ")
- mbut(29,35,"All Reactors Activated")
- elseif x >= 21 and x <=23 and y == 3 then
- state = false
- saveDisk(state)
- mbut(29,35,"All Reactors Deactivated")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment