Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local STATION_URL = "2CwStA8E"
- local SERVER_URL = "giJN22xf"
- --Writes text at a specific position.
- function writeC(text, tc)
- term.setTextColor(tc)
- print(text)
- end
- --Trims a string.
- function trim(s)
- return (s:gsub("^%s*(.-)%s*$", "%1"))
- end
- --Loops until a choice is made.
- function getInput()
- local answer
- while (true) do
- writeC("Is this computer a station or server?", colors.lightBlue)
- term.setTextColor(colors.white)
- answer = trim(string.lower(read()))
- if (answer == "station" or answer == "server") then
- return answer
- end
- end
- end
- writeC("Welcome to HandieAndy's Railcraft Station installation.", colors.blue)
- local answer = getInput()
- if (answer == "station") then
- writeC("Installing station program.", colors.yellow)
- local x, y = term.getCursorPos()
- term.setCursorPos(1,y+1)
- term.setTextColor(colors.lightGray)
- shell.run("pastebin", "get", STATION_URL, "station")
- local x, y = term.getCursorPos()
- term.setCursorPos(1, y+1)
- writeC("Got program, creating startup script.", colors.yellow)
- local f = fs.open("startup", "w")
- f.write('shell.run("station")')
- f.close()
- writeC("Startup script done.", colors.blue)
- writeC("Starting config generation.", colors.yellow)
- local config = {tracks = {}}
- writeC("What is the ID of the server that will be controlling this station?", colors.lightBlue)
- term.setTextColor(colors.white)
- config.server_id = tonumber(read())
- writeC("What is the unique destination name of this station?", colors.lightBlue)
- term.setTextColor(colors.white)
- config.dest = read()
- writeC("What is the cosmetic name?", colors.lightBlue)
- term.setTextColor(colors.white)
- config.name = read()
- writeC("Enter monitor ID: (Example: 'monitor_0')", colors.lightBlue)
- term.setTextColor(colors.white)
- config.monitor_id = read()
- writeC("Enter noteblock ID: (Example: 'note_block_0')", colors.lightBlue)
- term.setTextColor(colors.white)
- config.note_block_id = read()
- writeC("How many tracks does this station have?", colors.lightBlue)
- term.setTextColor(colors.white)
- local trackCount = tonumber(read())
- for i=1,trackCount do
- config.tracks[i] = {train = -1,}
- writeC("Enter track "..i.."'s sensor ID: ", colors.lightBlue)
- term.setTextColor(colors.white)
- config.tracks[i].sensor_id = read()
- writeC("Enter track "..i.."'s detector decimal color code. For more info, see www.computercraft.info/wiki/Colors_(API).", colors.lightBlue)
- term.setTextColor(colors.white)
- config.tracks[i].detectorColor = tonumber(read())
- writeC("Enter track "..i.."'s ticket retriever color code.", colors.lightBlue)
- term.setTextColor(colors.white)
- config.tracks[i].ticketColor = tonumber(read())
- end
- local f = fs.open("station_config", "w")
- f.write(textutils.serialize(config))
- f.close()
- writeC("Setup is now complete. Remember to double check that everything has been set up properly, and if so, this station is ready for operation after a restart. You may also restart the server for optimal performance.", colors.lime)
- elseif (answer == "server") then
- writeC("Installing server program.", colors.yellow)
- local x, y = term.getCursorPos()
- term.setCursorPos(1,y+1)
- term.setTextColor(colors.lightGray)
- shell.run("pastebin", "get", SERVER_URL, "server")
- local x, y = term.getCursorPos()
- term.setCursorPos(1, y+1)
- writeC("Got program, creating startup script.", colors.yellow)
- local f = fs.open("startup", "w")
- f.write('shell.run("server")')
- f.close()
- writeC("Startup script done.", colors.blue)
- writeC("Server installed successfully. Place a wireless modem on top of this computer, and restart it.", colors.lime)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement