Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local b = require("button")
- local s = require("strings")
- local m = peripheral.find("monitor")
- local r = peripheral.find("BigReactors-Reactor")
- local c = peripheral.find("minecraft:chest")
- local ins = {peripheral.find("bigreactors:tileentityreactoraccessport")}
- local rin = ins[1]
- local rout = ins[2]
- local arg = ...
- local updatespeed = 1 --*higher speeds look better but buttons are less responsive #default = 1
- local bootime = 2
- local theme = {
- ["dblack"] = colors.black,
- ["dwhite"] = colors.white,
- ["dcyan"] = colors.cyan,
- ["dgray"] = colors.gray,
- ["dred"] = colors.red,
- ["dgreen"] = colors.green,
- ["dblue"] = colors.blue,
- ["fred"] = "red",
- ["fcyan"] = "cyan",
- ["fblack"] = "black",
- ["fgray"] = "gray",
- ["fwhite"] = "white",
- ["fgreen"] = "green",
- ["fblue"] = "blue",
- ["borange"] = "1",
- ["bgray"] = "7",
- ["bwhite"] = "e",
- ["bred"] = "r",
- ["bblack"] = "f"
- }
- if arg ~= nil then
- print("entered configuration mode press enter to exit")
- print("to skip peripheral just write skip\n")
- print("peripherals list:")
- textutils.pagedTabulate(peripheral.getNames())
- print("")
- print("enter your monitor")
- local ins = read()
- if ins ~= "skip" then
- m = peripheral.wrap(ins)
- end
- local function cancel()
- if ins == "" then
- error("canceled", 0)
- end
- end
- cancel()
- print("enter your reactor")
- local ins = read()
- if ins ~= "skip" then
- r = peripheral.wrap(ins)
- end
- print("enter your chest")
- local ins = read()
- if ins ~= "skip" then
- c = peripheral.wrap(ins)
- end
- print("enter your input reactor port")
- local ins = read()
- if ins ~= "skip" then
- rin = peripheral.wrap(ins)
- end
- print("enter your output reactor port")
- local ins = read()
- if ins ~= "skip" then
- rout = peripheral.wrap(ins)
- end
- end
- ----*peripheral check(--------
- if not m then
- local otc = term.getBackgroundColor()
- term.setBackgroundColor(theme["dblack"])
- error("you dont have a monitor attached !", 0)
- term.setBackgroundColor(otc)
- end
- m.setBackgroundColor(theme["dcyan"])
- if not r then
- m.setCursorPos(2, 5)
- m.setTextColor(theme["dwhite"])
- m.setBackgroundColor(theme["dblack"])
- m.clear()
- m.setTextScale(2)
- m.write("you dont have a reactor attached !")
- error("no detected reactor !", 0)
- end
- if not c then
- m.setCursorPos(2, 5)
- m.setTextColor(theme["dwhite"])
- m.setBackgroundColor(theme["dblack"])
- m.clear()
- m.setTextScale(1)
- m.write("you dont have a chest attached !")
- error("no chest detected !", 0)
- end
- if not rin then
- m.setCursorPos(2, 5)
- m.setTextColor(theme["dwhite"])
- m.setBackgroundColor(theme["dblack"])
- m.clear()
- m.setTextScale(1)
- m.write("no input/output port detected !")
- error("no ports detected !", 0)
- end
- if (not rout) and rin then
- m.setCursorPos(2, 5)
- m.setTextColor(theme["dwhite"])
- m.setBackgroundColor(theme["dblack"])
- m.clear()
- m.setTextScale(1)
- m.write("no or 1 input/output port detected !")
- error("no or 1 port detected !", 0)
- end
- ----*peripheral check)--------
- local mname = peripheral.getName(m)
- m.setTextScale(0.5)
- m.clear()
- m.setBackgroundColor(theme["dcyan"])
- m.setTextColor(theme["dcyan"])
- b.frame(mname, 3, 19, 97, 18, theme["fwhite"], theme["fcyan"], false)
- b.frame(mname, 30, 20, 40, 5, theme["fwhite"], theme["fred"], true)
- m.setCursorPos(42, 20)
- m.blit("reakt by 9551", string.rep(theme["borange"], 13), string.rep(theme["bgray"], 13))
- m.setCursorPos(37, 21)
- m.setBackgroundColor(theme["dred"])
- m.setTextColor(theme["dblack"])
- m.blit("reactor control program", string.rep(theme["borange"], 23), string.rep(theme["bgray"], 23))
- m.setCursorPos(38, 28)
- m.write("default peripherals used \25")
- m.setCursorPos(36, 29)
- m.write("reactor: " .. peripheral.getName(r))
- m.setCursorPos(36, 30)
- m.write("monitor: " .. peripheral.getName(m))
- m.setCursorPos(36, 31)
- m.write("chest: " .. peripheral.getName(c))
- m.setCursorPos(36, 32)
- m.write("r. in: " .. peripheral.getName(rin))
- m.setCursorPos(36, 33)
- m.write("r. out: " .. peripheral.getName(rout))
- local function topline()
- b.frame(mname, 5, 6, 70, 1, theme["fblack"], theme["fblack"])
- m.setTextColor(theme["dblack"])
- m.setCursorPos(6, 6)
- m.write("main")
- m.setCursorPos(11, 6)
- m.write("fuels")
- m.setCursorPos(17, 6)
- m.write("chest")
- m.setCursorPos(23, 6)
- m.write("rod control")
- m.setCursorPos(35, 6)
- m.write("energy control")
- m.setCursorPos(50, 6)
- m.write("energy info")
- m.setCursorPos(62, 6)
- m.write("settings")
- end
- local function setcol(x, text)
- local oldcol = m.getBackgroundColor()
- m.setBackgroundColor(theme["dgray"])
- m.setCursorPos(x + 1, 6)
- m.write(text)
- m.setBackgroundColor(oldcol)
- end
- local function maincard(x, text)
- topline()
- local oldcol = m.getBackgroundColor()
- m.setBackgroundColor(theme["dcyan"])
- b.frame(mname, 5, 22, 70, 14, theme["fblack"], theme["fgray"], true)
- m.setBackgroundColor(theme["dgray"])
- b.frame(mname, x + 2, 8, #text - 1, 1, theme["fgray"], theme["fgray"])
- setcol(x, text)
- m.setBackgroundColor(oldcol)
- end
- local function menuButtons(click)
- local oci = m.getBackgroundColor()
- local ocii = m.getTextColor()
- m.setBackgroundColor(theme["dblack"])
- m.setTextColor(theme["dred"])
- m.setCursorPos(81, 6)
- m.write("TABS \25")
- m.setBackgroundColor(oci)
- m.setTextColor(ocii)
- b.menu(mname, click, 1, 81, 7, theme["fblack"], theme["fred"], "main", "main", true, 5)
- b.menu(mname, click, 2, 81, 8, theme["fblack"], theme["fred"], "fuels", "fuels", true, 10)
- b.menu(mname, click, 3, 81, 9, theme["fblack"], theme["fred"], "chest", "chest", true, 16)
- b.menu(mname, click, 4, 81, 10, theme["fblack"], theme["fred"], "rod control", "rod control", true, 22)
- b.menu(mname, click, 5, 81, 11, theme["fblack"], theme["fred"], "energy control", "energy control", true, 34)
- b.menu(mname, click, 6, 81, 12, theme["fblack"], theme["fred"], "energy info", "energy info", true, 49)
- --------------*settings menu--------------
- m.setBackgroundColor(theme["dblack"])
- b.menu(mname, click, 7, 81, 25, theme["fwhite"], theme["fgreen"], "peripherals", "peripherals", true, 61)
- b.menu(mname, click, 8, 81, 26, theme["fwhite"], theme["fgreen"], "reactor set.", "reactor set.", true, 61)
- --*---------------------------------------
- m.setTextColor(theme["dwhite"])
- if b.button(mname, click, 81, 14, ">shutdown<") then
- m.setBackgroundColor(theme["dblack"])
- m.setTextColor(theme["dwhite"])
- m.clear()
- m.setCursorPos(70, 14)
- m.write("shutting down.")
- sleep(bootime / 3)
- m.setCursorPos(70, 14)
- m.write("shutting down..")
- sleep(bootime / 3)
- m.setCursorPos(70, 14)
- m.write("shutting down...")
- sleep(bootime / 3)
- m.clear()
- os.shutdown()
- end
- m.setBackgroundColor(theme["dcyan"])
- local out = b.menudata()
- if (type(out[2]) == "number") and (out[1]) then
- maincard(out[2], out[1])
- end
- end
- sleep(bootime)
- local function basemenu()
- m.setBackgroundColor(theme["dcyan"])
- b.frame(mname, 3, 20, 97, 18, theme["fblack"], theme["fcyan"], true)
- b.frame(mname, 80, 20, 15, 15, theme["fblack"], theme["fcyan"], true)
- b.frame(mname, 80, 20, 16, 15, theme["fwhite"], theme["fcyan"], true)
- b.frame(mname, 81, 18, 14, 5, theme["fred"], theme["fblack"], false)
- m.setCursorPos(81, 13)
- m.blit("system", string.rep(theme["bred"], 6), string.rep(theme["bwhite"], 6))
- b.frame(mname, 81, 29, 14, 5, theme["fred"], theme["fblack"], false)
- m.setCursorPos(81, 24)
- m.blit("settings", string.rep(theme["bred"], 8), string.rep(theme["bwhite"], 8))
- end
- basemenu()
- topline()
- --*-----------------main programs----------------
- local function mmain(click)
- b.frame(mname, 30, 20, 10, 5, theme["fblack"], theme["fgray"], true)
- end
- local function mpers(click)
- local function selection(ins)
- while true do
- local click = b.timetouch(updatespeed, mname)
- m.setBackgroundColor(theme["dgray"])
- b.frame(mname, 8, 22, 63, 12, theme["fblack"], theme["fblue"], false)
- m.setBackgroundColor(theme["dred"])
- m.setCursorPos(22, 10)
- m.write("what kind of peripheral is this ?")
- m.setCursorPos(20, 11)
- m.write(ins)
- if b.button(mname, click, 35, 21, "|BACK|") then
- break
- end
- m.setBackgroundColor(theme["dgreen"])
- if b.button(mname, click, 28, 15, "monitor") then
- m.setBackgroundColor(theme["dblack"])
- m.clear()
- m.setBackgroundColor(theme["dcyan"])
- m = peripheral.wrap(ins)
- m.setTextScale(0.5)
- mname = ins
- menuButtons(click)
- basemenu()
- topline()
- break
- end
- if b.button(mname, click, 36, 15, "reactor") then
- r = peripheral.wrap(ins)
- break
- end
- if b.button(mname, click, 40, 17, "r. input <") then
- rin = peripheral.wrap(ins)
- break
- end
- if b.button(mname, click, 28, 17, "r. output >") then
- rout = peripheral.wrap(rout)
- break
- end
- if b.button(mname, click, 44, 15, "chest") then
- c = peripheral.wrap(ins)
- break
- end
- end
- end
- m.setBackgroundColor(theme["dgray"])
- b.frame(mname, 8, 22, 30, 12, theme["fblack"], theme["fgreen"], false)
- b.frame(mname, 41, 22, 30, 12, theme["fblack"], theme["fred"], false)
- m.setBackgroundColor(theme["dgreen"])
- b.frame(mname, 10, 14, 26, 2, theme["fblack"], theme["fblue"], false)
- m.setCursorPos(10, 12)
- m.blit("monitor :", string.rep(theme["bred"], 9), string.rep(theme["bblack"], 9))
- b.frame(mname, 10, 19, 26, 2, theme["fblack"], theme["fblue"], false)
- m.setCursorPos(10, 17)
- m.blit("reactor :", string.rep(theme["bred"], 9), string.rep(theme["bblack"], 9))
- b.frame(mname, 10, 24, 26, 2, theme["fblack"], theme["fblue"], false)
- m.setCursorPos(10, 22)
- m.blit("chest :", string.rep(theme["bred"], 7), string.rep(theme["bblack"], 7))
- b.frame(mname, 10, 30, 26, 3, theme["fblack"], theme["fblue"], false)
- m.setCursorPos(10, 27)
- m.blit("input/output :", string.rep(theme["bred"], 14), string.rep(theme["bblack"], 14))
- m.setCursorPos(8, 10)
- m.blit("active :", string.rep(theme["bred"], 8), string.rep(theme["bblack"], 8))
- m.setCursorPos(41, 10)
- m.blit("all found :", string.rep(theme["bred"], 11), string.rep(theme["bblack"], 11))
- m.setBackgroundColor(theme["dblue"])
- m.setCursorPos(11, 14)
- m.write(peripheral.getName(m))
- m.setCursorPos(11, 19)
- m.write(peripheral.getName(r))
- m.setCursorPos(11, 24)
- m.write(peripheral.getName(c))
- m.setCursorPos(11, 29)
- m.write("I: " .. string.sub(peripheral.getName(rin), 23))
- m.setCursorPos(11, 31)
- m.write("O: " .. string.sub(peripheral.getName(rout), 23))
- local pers = peripheral.getNames()
- local sc = 11
- m.setTextColor(theme["dblack"])
- m.setBackgroundColor(theme["dred"])
- for i = 1, #pers do
- if peripheral.getType(pers[i]) == "bigreactors:tileentityreactoraccessport" then
- pers[i] = string.sub(pers[i], 23)
- end
- if b.button(mname, click, 42, sc + i, pers[i]) then
- if s.ensure_width(pers[i], 18) == "reactoraccessport_" then
- pers[i] = "bigreactors:tileentityreactoraccessport_" .. string.sub(pers[i], 19)
- end
- selection(pers[i])
- end
- end
- end
- local function mfuel(click)
- b.frame(mname, 30, 20, 10, 5, theme["fblack"], theme["fgray"], true)
- end
- local function mchest(click)
- b.frame(mname, 30, 20, 10, 5, theme["fblack"], theme["fgray"], true)
- end
- local function mrod(click)
- b.frame(mname, 30, 20, 10, 5, theme["fblack"], theme["fgray"], true)
- end
- local function menergyc(click)
- b.frame(mname, 30, 20, 10, 5, theme["fblack"], theme["fgray"], true)
- end
- local function menergyi(click)
- b.frame(mname, 30, 20, 10, 5, theme["fblack"], theme["fgray"], true)
- end
- local function mreactor(click)
- b.frame(mname, 30, 20, 10, 5, theme["fblack"], theme["fgray"], true)
- end
- --*----------------------------------------------
- local function peripheralsmenu()
- local oc = m.getBackgroundColor()
- repeat
- local ins = b.menudata()
- local click = b.timetouch(updatespeed, mname)
- menuButtons(click)
- mpers(click)
- until ins ~= "peripherals"
- m.setBackgroundColor(oc)
- end
- local function main()
- local oc = m.getBackgroundColor()
- repeat
- local ins = b.menudata()
- local click = b.timetouch(updatespeed, mname)
- menuButtons(click)
- mmain(click)
- until ins ~= "main"
- m.setBackgroundColor(oc)
- end
- local function fuels()
- local oc = m.getBackgroundColor()
- repeat
- local ins = b.menudata()
- local click = b.timetouch(updatespeed, mname)
- menuButtons(click)
- mfuel(click)
- until ins ~= "fuels"
- m.setBackgroundColor(oc)
- end
- local function chest()
- local oc = m.getBackgroundColor()
- repeat
- local ins = b.menudata()
- local click = b.timetouch(updatespeed, mname)
- menuButtons(click)
- mchest(click)
- until ins ~= "chest"
- m.setBackgroundColor(oc)
- end
- local function rodcontrol()
- local oc = m.getBackgroundColor()
- repeat
- local ins = b.menudata()
- local click = b.timetouch(updatespeed, mname)
- menuButtons(click)
- mrod(click)
- until ins ~= "rod control"
- m.setBackgroundColor(oc)
- end
- local function energyc()
- local oc = m.getBackgroundColor()
- repeat
- local ins = b.menudata()
- local click = b.timetouch(updatespeed, mname)
- menuButtons(click)
- menergyc(click)
- until ins ~= "energy control"
- m.setBackgroundColor(oc)
- end
- local function energyinf()
- local oc = m.getBackgroundColor()
- repeat
- local ins = b.menudata()
- local click = b.timetouch(updatespeed, mname)
- menuButtons(click)
- menergyi(click)
- until ins ~= "energy info"
- m.setBackgroundColor(oc)
- end
- local function reactorsettings()
- local oc = m.getBackgroundColor()
- repeat
- local ins = b.menudata()
- local click = b.timetouch(updatespeed, mname)
- menuButtons(click)
- mreactor(click)
- until ins ~= "reactor set."
- m.setBackgroundColor(oc)
- end
- menuButtons({"monitor_touch", mname, 83, 7})
- while true do
- local menuout = b.menudata()
- if menuout[1] == "peripherals" then
- peripheralsmenu()
- end
- if menuout[1] == "main" then
- main()
- end
- if menuout[1] == "fuels" then
- fuels()
- end
- if menuout[1] == "chest" then
- chest()
- end
- if menuout[1] == "rod control" then
- rodcontrol()
- end
- if menuout[1] == "energy control" then
- energyc()
- end
- if menuout[1] == "energy info" then
- energyinf()
- end
- if menuout[1] == "reactor set." then
- reactorsettings()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement