Advertisement
9551

Untitled

Jun 22nd, 2021
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.72 KB | None | 0 0
  1. local b = require("button")
  2. local m = peripheral.find("monitor")
  3. local r = peripheral.find("BigReactors-Reactor")
  4. local c = peripheral.find("minecraft:chest")
  5. local ins = {peripheral.find("bigreactors:tileentityreactoraccessport")}
  6. local rin = ins[1]
  7. local rout = ins[2]
  8. local arg = ...
  9. local theme = {
  10.     ["dblack"] = colors.black,
  11.     ["dwhite"] = colors.white,
  12.     ["dcyan"] = colors.cyan,
  13.     ["dgray"] = colors.gray,
  14.     ["dred"] = colors.red,
  15.     ["fred"] = "red",
  16.     ["fcyan"] = "cyan",
  17.     ["fblack"] = "black",
  18.     ["fgray"] = "gray",
  19.     ["fwhite"] = "white",
  20.     ["fgreen"] = "green",
  21.     ["borange"] = "1",
  22.     ["bgray"] = "7",
  23.     ["bwhite"] = "e",
  24.     ["bred"] = "r"
  25. }
  26. if arg ~= nil then
  27.     print("entered configuration mode press enter to exit")
  28.     print("to skip peripheral just write skip\n")
  29.     print("peripherals list:")
  30.     textutils.pagedTabulate(peripheral.getNames())
  31.     print("")
  32.     print("enter your monitor")
  33.     local ins = read()
  34.     if ins ~= "skip" then
  35.         m = peripheral.wrap(ins)
  36.     end
  37.     local function cancel()
  38.         if ins == "" then
  39.             error("canceled", 0)
  40.         end
  41.     end
  42.     cancel()
  43.     print("enter your reactor")
  44.     local ins = read()
  45.     if ins ~= "skip" then
  46.         r = peripheral.wrap(ins)
  47.     end
  48.     print("enter your chest")
  49.     local ins = read()
  50.     if ins ~= "skip" then
  51.         c = peripheral.wrap(ins)
  52.     end
  53.     print("enter your input reactor port")
  54.     local ins = read()
  55.     if ins ~= "skip" then
  56.         rin = peripheral.wrap(ins)
  57.     end
  58.     print("enter your output reactor port")
  59.     local ins = read()
  60.     if ins ~= "skip" then
  61.         rout = peripheral.wrap(ins)
  62.     end
  63. end
  64. ----*peripheral check(--------
  65. if not m then
  66.     local otc = term.getBackgroundColor()
  67.     term.setBackgroundColor(theme["dblack"])
  68.     error("you dont have a monitor attached !", 0)
  69.     term.setBackgroundColor(otc)
  70. end
  71. if not r then
  72.     m.setCursorPos(2, 5)
  73.     m.setTextColor(theme["dwhite"])
  74.     m.setBackgroundColor(theme["dblack"])
  75.     m.clear()
  76.     m.setTextScale(2)
  77.     m.write("you dont have a reactor attached !")
  78.     error("no detected reactor !", 0)
  79. end
  80. if not c then
  81.     m.setCursorPos(2, 5)
  82.     m.setTextColor(theme["dwhite"])
  83.     m.setBackgroundColor(theme["dblack"])
  84.     m.clear()
  85.     m.setTextScale(1)
  86.     m.write("you dont have a chest attached !")
  87.     error("no chest detected !", 0)
  88. end
  89. if not rin then
  90.     m.setCursorPos(2, 5)
  91.     m.setTextColor(theme["dwhite"])
  92.     m.setBackgroundColor(theme["dblack"])
  93.     m.clear()
  94.     m.setTextScale(1)
  95.     m.write("no input/output port detected !")
  96.     error("no ports detected !", 0)
  97. end
  98. if (not rout) and rin then
  99.     m.setCursorPos(2, 5)
  100.     m.setTextColor(theme["dwhite"])
  101.     m.setBackgroundColor(theme["dblack"])
  102.     m.clear()
  103.     m.setTextScale(1)
  104.     m.write("no or 1 input/output port detected !")
  105.     error("no or 1 port detected !", 0)
  106. end
  107. ----*peripheral check)--------
  108. local mname = peripheral.getName(m)
  109. m.setTextScale(0.5)
  110. m.clear()
  111. m.setBackgroundColor(theme["dcyan"])
  112. m.setTextColor(theme["dcyan"])
  113. b.frame(mname, 3, 19, 97, 18, theme["fwhite"], theme["fcyan"], false)
  114. b.frame(mname, 30, 20, 40, 5, theme["fwhite"], theme["fred"], true)
  115. m.setCursorPos(42, 20)
  116. m.blit("reakt by 9551", string.rep(theme["borange"], 13), string.rep(theme["bgray"], 13))
  117. m.setCursorPos(37, 21)
  118. m.setBackgroundColor(theme["dred"])
  119. m.setTextColor(theme["dblack"])
  120. m.blit("reactor control program", string.rep(theme["borange"], 23), string.rep(theme["bgray"], 23))
  121. m.setCursorPos(38, 28)
  122. m.write("default peripherals used \25")
  123. m.setCursorPos(36, 29)
  124. m.write("reactor: " .. peripheral.getName(r))
  125. m.setCursorPos(36, 30)
  126. m.write("monitor: " .. peripheral.getName(m))
  127. m.setCursorPos(36, 31)
  128. m.write("chest: " .. peripheral.getName(c))
  129. m.setCursorPos(36, 32)
  130. m.write("r. in: " .. peripheral.getName(rin))
  131. m.setCursorPos(36, 33)
  132. m.write("r. out: " .. peripheral.getName(rout))
  133. local function topline()
  134.     b.frame(mname, 5, 6, 70, 1, theme["fblack"], theme["fblack"])
  135.     m.setTextColor(theme["dblack"])
  136.     m.setCursorPos(6, 6)
  137.     m.write("main")
  138.     m.setCursorPos(11, 6)
  139.     m.write("fuels")
  140.     m.setCursorPos(17, 6)
  141.     m.write("chest")
  142.     m.setCursorPos(23, 6)
  143.     m.write("rod control")
  144.     m.setCursorPos(35, 6)
  145.     m.write("energy control")
  146.     m.setCursorPos(50, 6)
  147.     m.write("energy info")
  148.     m.setCursorPos(62, 6)
  149.     m.write("settings")
  150. end
  151. local function setcol(x, text)
  152.     local oldcol = m.getBackgroundColor()
  153.     m.setBackgroundColor(theme["dgray"])
  154.     m.setCursorPos(x + 1, 6)
  155.     m.write(text)
  156.     m.setBackgroundColor(oldcol)
  157. end
  158. local function maincard(x, text)
  159.     topline()
  160.     local oldcol = m.getBackgroundColor()
  161.     m.setBackgroundColor(theme["dcyan"])
  162.     b.frame(mname, 5, 22, 70, 14, theme["fblack"], theme["fgray"], true)
  163.     m.setBackgroundColor(theme["dgray"])
  164.     b.frame(mname, x + 2, 8, #text - 1, 1, theme["fgray"], theme["fgray"])
  165.     setcol(x, text)
  166.     m.setBackgroundColor(oldcol)
  167. end
  168. local function menuButtons()
  169.     local click = b.timetouch(1, mname)
  170.     local oci = m.getBackgroundColor()
  171.     local ocii = m.getTextColor()
  172.     m.setBackgroundColor(theme["dblack"])
  173.     m.setTextColor(theme["dred"])
  174.     m.setCursorPos(81, 6)
  175.     m.write("TABS \25")
  176.     m.setBackgroundColor(oci)
  177.     m.setTextColor(ocii)
  178.     b.menu(mname, click, 1, 81, 7, theme["fblack"], theme["fred"], "main", "main", true, 5)
  179.     b.menu(mname, click, 2, 81, 8, theme["fblack"], theme["fred"], "fuels", "fuels", true, 10)
  180.     b.menu(mname, click, 3, 81, 9, theme["fblack"], theme["fred"], "chest", "chest", true, 16)
  181.     b.menu(mname, click, 4, 81, 10, theme["fblack"], theme["fred"], "rod control", "rod control", true, 22)
  182.     b.menu(mname, click, 5, 81, 11, theme["fblack"], theme["fred"], "energy control", "energy control", true, 34)
  183.     b.menu(mname, click, 6, 81, 12, theme["fblack"], theme["fred"], "energy info", "energy info", true, 49)
  184.  
  185.     --------------*settings menu--------------
  186.     m.setBackgroundColor(theme["dblack"])
  187.     b.menu(mname, click, 7, 81, 25, theme["fwhite"], theme["fgreen"], "peripherals", "peripherals", true, 61)
  188.     b.menu(mname, click, 8, 81, 26, theme["fwhite"], theme["fgreen"], "reactor set.", "reactor set.", true, 61)
  189.     --*---------------------------------------
  190.     m.setBackgroundColor(theme["dblack"])
  191.     m.setTextColor(theme["dwhite"])
  192.     if b.button(mname, click, 81, 14, ">shutdown<") then
  193.         m.setBackgroundColor(theme["dblack"])
  194.         m.setTextColor(theme["dwhite"])
  195.         m.clear()
  196.         m.setCursorPos(70, 14)
  197.         m.write("shutting down")
  198.         sleep(1)
  199.         m.clear()
  200.         os.shutdown()
  201.     end
  202.     m.setBackgroundColor(theme["dcyan"])
  203.     local out = b.menudata()
  204.     if (type(out[2]) == "number") and (out[1]) then
  205.         maincard(out[2], out[1])
  206.     end
  207. end
  208. sleep(1)
  209.  
  210. local function clears()
  211.     local oldcol = m.getBackgroundColor()
  212.     m.setBackgroundColor(theme["dcyan"])
  213.     m.clear()
  214.     m.setBackgroundColor(oldcol)
  215. end
  216.  
  217. local function basemenu()
  218.     m.setBackgroundColor(theme["dcyan"])
  219.     b.frame(mname, 3, 20, 97, 18, theme["fblack"], theme["fcyan"], true)
  220.     b.frame(mname, 80, 20, 15, 15, theme["fblack"], theme["fcyan"], true)
  221.     b.frame(mname, 80, 20, 16, 15, theme["fwhite"], theme["fcyan"], true)
  222.     b.frame(mname, 81, 18, 14, 5, theme["fred"], theme["fblack"], false)
  223.     m.setCursorPos(81, 13)
  224.     m.blit("system", string.rep(theme["bred"], 6), string.rep(theme["bwhite"], 6))
  225.  
  226.     b.frame(mname, 81, 29, 14, 5, theme["fred"], theme["fblack"], false)
  227.     m.setCursorPos(81, 24)
  228.     m.blit("settings", string.rep(theme["bred"], 8), string.rep(theme["bwhite"], 8))
  229. end
  230. basemenu()
  231. topline()
  232. while true do
  233.     menuButtons()
  234. end
  235.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement