Elrol

Fallout Styled server/terminal installer

Apr 10th, 2020 (edited)
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.76 KB | None | 0 0
  1. --[[
  2.     To download this to a computer, run this command in the command line:
  3.     pastebin get mrgQrQXB startup.lua
  4.    
  5.     Once it has downloaded, reboot the computer
  6.     It will prompt you with a choice between this being a terminal or a server
  7.    
  8.     After you make your choice, type it in, and hit enter.
  9.     This will install the needed files to the computer.
  10.    
  11.     When it is finished, run the following command:
  12.     edit startup.lua
  13.    
  14.     Here you can change the settings to whatever you want
  15.    
  16.     For a server:
  17.         Name: The name of the server. This will be shown to all connected terminals
  18.         Port: The port of the server. This is a unique number for terminals to send commands to
  19.         Side: The side of the block where the modem is located
  20.         Cable: The bundled cable where to output the redstone signals
  21.         GuiColor: The color of the text for the server interface
  22.        
  23.     For a client:
  24.         Name: The name of this terminal. It will be displayed on the terminal interface and used to identify which terminals are doing what on the server. This helps with debugging to make sure things are working
  25.         Port: The port of the terminal. This is a unique number needed for the terminal to get the response from the server when running commands
  26.         ServerPort: The port of the server. This is needed so the terminal knows where to send it's commands
  27.         Side: The side of the block where the modem is located
  28.         GuiColor: The color of the text for the terminal interface
  29.        
  30.     After you finish configuring the computer, press the [ctrl] button on your keyboard then [enter] to save the file
  31.     Finally, restart the computer again.
  32.    
  33.     Now the only change that needs to happen is on the terminals. They will have a file called data.json
  34.     This file contains the logs(texts) and menus that the terminal will show.
  35.    
  36.     For Texts, each one will need a unique key.
  37.     In the Text object, you will need three parts. An id, title, and txt. Here is an example:
  38.         "key": {
  39.             "id": "key", << This needs to be the same as the one above!
  40.             "title": "The text to display on the UI when selecting a log",
  41.             "txt": "The contents of the log that will be displayed after opening the log"
  42.         }
  43.    
  44.     For the menus, each one will also need a unique id. Though, you can have the same ID for a menu and a text, it would be best to have them not be
  45.     Here is an example:
  46.         "key": {
  47.             "id": "key",
  48.             "title": "The text to display as a sub-header"
  49.             "cmds":[
  50.                 [
  51.                   "toggle 100 1",
  52.                   "Lights",
  53.                   false
  54.                 ]
  55.             ]
  56.         }
  57.    
  58.     For the commands, each will be a button to select on the menu. It is an array
  59.     The first string in a command's array is the command to send to the server
  60.     The second is the text to display on the menu.
  61.     For toggle commands, you can invert the displayed text. This would show that it is on when no redsstone signal is being sent out. This is just for cosmetic purposes and functions the same either way
  62.    
  63.     These are the current commands that can be sent, more will likely be added:
  64.         "name:{terminalName}" - This sends the terminal's name to the server and the server sends back the server name
  65.         "toggle {targetPort} {color}" - This will toggle the signal of the bundled cable at the server targeted. The color needs to be the numerical value which will be listed below
  66.         "trigger {targetPort} {color}" - This will toggle the signal for the color and then, after a second, toggle it again.
  67.         "check {targetPort} {color}" - This checks if the specified color cable is being output or not
  68.         "stop {targetPort}" - Stops the specified server
  69.         "ping {targetPort}" - Pings the server
  70.    
  71.     Numeric values for the color for bundled cables
  72.     --white 1
  73.     --lightGray 256
  74.     --gray 128
  75.     --black 32768
  76.     --brown 4096
  77.     --red 16384
  78.     --orange 2
  79.     --yellow 16
  80.     --lime 32
  81.     --green 8192
  82.     --cyan 512
  83.     --lightBlue 8
  84.     --blue 2048
  85.     --purple 1024
  86.     --magenta 4
  87.     --pink 64
  88. ]]
  89. local color = colors.green
  90. local w, h = term.getSize()
  91.  
  92. local serverFiles = {}
  93.     serverFiles.server = "G8jS60D1"
  94.     serverFiles.startup = "pAuEZD46"
  95.  
  96. local clientFiles = {}
  97.     clientFiles.client = "dSYLZtkX"
  98.     clientFiles.menu = "iz95vBeb"
  99.     clientFiles.startup = "kvwgz7L0"
  100.  
  101. function init()
  102.     term.setTextColor(color)
  103.     term.setBackgroundColor(colors.black)
  104.     term.clear()
  105.     term.setCursorPos(1,1)
  106.     info("ROBCO INDUSTRIES UNIFIED OPERATING SYSTEM", true)
  107.     info("COPYRIGHT 2019-2020 ROBCO INDUSTRIES", true)
  108.     info("-Server 1-", true)
  109.     info(nil, false)
  110.     info("Terminal Setup", false)
  111.     info("======================", false)
  112.     info("Install for Terminal or Server?", false)
  113.     hr()
  114.     local side = read()
  115.     if side == "server" or side == "Server" then
  116.         server()
  117.     elseif side == "terminal" or side == "Terminal" then
  118.         client()
  119.     else
  120.         term.clear()
  121.         term.setCursorPos(1,1)
  122.     end
  123. end
  124.  
  125. function hr()
  126.     x, y = term.getCursorPos()
  127.     for i = 1, w, 1 do
  128.         write("-")
  129.     end
  130.     term.setCursorPos(1, y+1)
  131. end
  132.  
  133. function info(text, isCenter)
  134.     if text == nil then
  135.         term.setCursorPos(1, y+2)
  136.     elseif isCenter then
  137.         x, y = term.getCursorPos()
  138.         x = (w - #text) / 2
  139.         term.setCursorPos(x, y)
  140.         write(text)
  141.         term.setCursorPos(1, y+1)
  142.     else
  143.         print(text)
  144.     end
  145. end
  146.  
  147. function install(link,file)
  148.     if fs.exists(file) then
  149.         fs.delete(file)
  150.         shell.run("pastebin", "get", link, file)
  151.         print("Updated "..file)
  152.     else
  153.         shell.run("pastebin", "get", link, file)
  154.         print("Installed "..file)
  155.     end
  156. end
  157.  
  158. function server()
  159.     info("Installing Server", false)
  160.     for f, l in pairs(serverFiles) do
  161.         install(l, f..".lua")
  162.     end
  163. end
  164.  
  165. function client()
  166.     info("Intalling Client", false)
  167.     for f, l in pairs(clientFiles) do
  168.         install(l, f..".lua")
  169.     end
  170. end
  171.  
  172. init()
Advertisement
Add Comment
Please, Sign In to add comment