Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local term = require("term")
- local sides = require("sides")
- local colors = require("colors")
- local rs = component.redstone
- local io = require("io")
- local fs = require("filesystem")
- local running = true
- local numberOfTrains = 0
- local isParked = false
- local isTrain1 = false
- local isTrain2 = false
- local isTrain3 = false
- local isShuttingDown = false
- local function initSetup()
- -- Test to see if isParked is all ready on
- --rs.setBundledOutput(sides.north, colors.orange, 255)
- if rs.getBundledInput(sides.north, colors.gray) == true then
- rs.setBundledOutput(sides.north, colors.brown+colors.pink, 0)
- --isParked = true
- end
- --if rs.getBundledInput(sides.north, colors.pink) == true then
- -- isTrain1 = true
- --elseif rs.getBundledInput(sides.north, colors.pink) == false then
- -- isTrain1 = false
- --end
- end
- local function setupCheck()
- if fs.exists("/tmp/cookie.txt") == false then
- initSetup()
- c = io.open("/tmp/cookie.txt", "w")
- c:write("This is a cookie.")
- c:close()
- else
- nil
- end
- end
- local function ui()
- term.clear()
- term.setCursor(10,3)
- term.write("Main Menu")
- term.setCursor(10,5)
- term.write("1. Park Train on : " ..tostring(isParked))
- term.setCursor(10,7)
- term.write("2. Train 1 is running : " ..tostring(isTrain1))
- term.setCursor(10,8)
- term.write("3. Train 2 is running : " ..tostring(isTrain2))
- term.setCursor(10,9)
- term.write("4. Train 3 is running : " ..tostring(isTrain3))
- term.setCursor(10, 11)
- term.write("Shutting Down Train : "..tostring(isShuttingDown))
- term.setCursor(10, 15)
- term.write("Q Quit or Exit")
- term.setCursor(10,16)
- end
- local function input()
- answer = term.read()
- answer= string.gsub(answer, "\n", "")
- if answer == "1" then
- if isParked == false then
- rs.setBundledOutput(sides.north, colors.white, 255)
- elseif isParked == true then
- rs.setBundledOutput(sides.north, colors.white, 0)
- end
- if isParked == true then
- isParked = false
- isShuttingDown = true
- elseif isParked == false then
- isShuttingDown = false
- isParked = true
- end
- end
- if answer == "2" then
- if isTrain1 == false then
- rs.setBundledOutput(sides.north, colors.pink, 255)
- rs.setBundledOutput(sides.north, colors.brown, 0)
- elseif isTrain1 == true then
- rs.setBundledOutput(sides.north, colors.pink, 0)
- rs.setBundledOutput(sides.north, colors.brown, 255)
- end
- if isTrain1 == true then
- isTrain1 = false
- elseif isTrain1 == false then
- isTrain1 = true
- end
- end
- if answer == "Q" or answer == "q" then
- running = false
- end
- end
- while running do
- setupCheck()
- --chStatus()
- ui()
- input()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement