Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- rednet.open("left")
- mon = peripheral.wrap("back")
- mod = peripheral.wrap("left")
- mon.setTextScale(1)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.clear()
- gx, gy = mon.getSize()
- function mcbut (cx,cy,text,tcol,bcol)
- mon.setCursorPos(cx,cy)
- mon.setBackgroundColor(bcol)
- mon.setTextColor(tcol)
- mon.write(text)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- end
- function startscreen()
- shell.run("clear")
- mcbut(4,4,"Light ",colors.white, colors.black)
- mcbut(26,4,globTab["Light"]["Status"],colors.white,globTab.Light.Color)
- mcbut(4,6,"Mass Fabricator",colors.white, colors.black)
- mcbut(24,4,"|",colors.white,colors.black)
- mcbut(24,6,"|",colors.white,colors.black)
- mcbut(26,6,globTab["Mass"]["Status"],colors.white,globTab.Mass.Color)
- mcbut(4,8,"UU-Matter in Mass",colors.white,colors.black)
- mcbut(24,6,":",colors.white,colors.black)
- end
- function loadSave()
- if fs.exists("save") == false then
- globTab = {}
- globTab["Light"] = {["Status"] = "On ",["Color"] = colors.green}
- globTab["Mass"] = {["Status"] = "Get", ["Color"] = colors.green}
- save()
- else
- fileR = fs.open("save","r")
- globTab = textutils.unserialize(fileR.readLine(1))
- fileR.close()
- end
- if globTab.Light.Status == "Off" then
- rs.setOutput("top",false)
- elseif globTab.Light.Status == "On " then
- rs.setOutput("top",true)
- end
- end
- function save()
- shell.run("delete save")
- fileS = fs.open("save", "w")
- fileS.writeLine(textutils.serialize(globTab))
- fileS.close()
- end
- function screens()
- evt,side, x, y = os.pullEvent("monitor_touch")
- if y == 4 then
- if globTab.Light.Status == "Off" then
- globTab.Light.Status = "On "
- globTab.Light.Color = colors.green
- rs.setOutput("top",true)
- mcbut(26,4,globTab.Light.Status,colors.white, globTab.Light.Color)
- elseif globTab.Light.Status == "On " then
- globTab.Light.Status = "Off"
- globTab.Light.Color = colors.red
- rs.setOutput("top",false)
- mcbut(26,4,globTab.Light.Status,colors.white,globTab.Light.Color)
- end
- end
- if y == 6 then
- globTab.Mass.Status = "Cls"
- globTab.Mass.Color = colors.red
- smsg = {["Type"] = "RS",["Info"] = "Mass"}
- rednet.broadcast(textutils.serialize(smsg))
- mcbut(26,6,"Cls",colors.white, globTab.Mass.Color)
- sleep(3)
- globTab.Mass.Status = "Get"
- globTab.Mass.Color = colors.green
- mcbut(26,6,"Cls",colors.white,globTab.Mass.Color)
- end
- save()
- sleep(0.2)
- end
- function gets()
- ID,msg = rednet.receive()
- if ID == 897 or ID == 905 or ID == 903 then
- tabler = textutils.unserialize(msg)
- print(tabler.Type)
- if tabler["Type"] == "Info" then
- if tabler["Machine"] == "Mass"then
- setText = tabler["Info"]
- term.clearLine(8)
- mcbut(4,8,"UU-Matter",colors.white, colors.black)
- mcbut(24,8,"|",colors.white,colors.black)
- mcbut(26,8,math.floor(setText) .. " ",colors.white,colors.black)
- end
- elseif tabler["Type"] == "En" then
- machines = textutils.unserialize(tabler.Info)
- for ic = 1 , gy, 1 do
- mcbut(32,ic + 2," ",colors.yellow,colors.black)
- end
- for p = 1 , table.maxn(machines),1 do
- strmsg = machines[p].Name .. ": " .. machines[p].Stored .. "/" .. machines[p].Capacity .. " | ".. machines[p].Location
- mcbut(32,p + 2,strmsg ,colors.yellow,colors.black)
- end
- end
- end
- end
- while true do
- loadSave()
- shell.run("clear")
- startscreen()
- parallel.waitForAny(screens, gets)
- sleep(0.2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement