Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SIDE_INPUT = "left"
- SIDE_OUTPUT = "right"
- COLOUR_OFFSET = 1
- COLOUR_MAX = 16
- --DELAY_TIME = 1
- CURRENT_COLOUR = 0
- function save_config()
- local fHandle = fs.open("config.txt", "w")
- fHandle.writeLine(SIDE_INPUT)
- fHandle.writeLine(SIDE_OUTPUT)
- fHandle.writeLine(COLOUR_OFFSET)
- fHandle.writeLine(COLOUR_MAX)
- --fHandle.writeLine(DELAY_TIME)
- fHandle.close()
- end
- function load_config()
- local fHandle = fs.open("config.txt", "r")
- SIDE_INPUT = fHandle.readLine()
- SIDE_OUTPUT = fHandle.readLine()
- COLOUR_OFFSET = tonumber(fHandle.readLine())
- COLOUR_MAX = tonumber(fHandle.readLine())
- --DELAY_TIME = tonumber(fHandle.readLine())
- fHandle.close()
- end
- function verify_side(side)
- if (side == "left") then
- return true
- elseif (side == "right") then
- return true
- elseif (side == "front") then
- return true
- elseif (side == "back") then
- return true
- elseif (side == "top") then
- return true
- elseif (side == "bottom") then
- return true
- else
- return false
- end
- end
- function numberToColour(num)
- if (num == 1) then
- return colours.white
- elseif (num == 2) then
- return colours.orange
- elseif (num == 3) then
- return colours.magenta
- elseif (num == 4) then
- return colours.lightBlue
- elseif (num == 5) then
- return colours.yellow
- elseif (num == 6) then
- return colours.lime
- elseif (num == 7) then
- return colours.pink
- elseif (num == 8) then
- return colours.grey
- elseif (num == 9) then
- return colours.lightGrey
- elseif (num == 10) then
- return colours.cyan
- elseif (num == 11) then
- return colours.purple
- elseif (num == 12) then
- return colours.blue
- elseif (num == 13) then
- return colours.brown
- elseif (num == 14) then
- return colours.green
- elseif (num == 15) then
- return colours.red
- else
- return colours.black
- end
- end
- term.setCursorPos(1,1)
- term.clear()
- if (fs.exists("config.txt")) then
- load_config()
- print("Loaded config!")
- else
- print("Enter the input side: ")
- SIDE_INPUT = read();
- if (verify_side(SIDE_INPUT) == false) then
- print("Unknown side: " .. SIDE_INPUT)
- return
- end
- print("Enter the output rednet side: ")
- SIDE_OUTPUT = read()
- if (verify_side(SIDE_OUTPUT) == false) then
- print("Unknown side: " .. SIDE_OUTPUT)
- return
- end
- print("Enter the starting colour number (1-16)")
- COLOUR_OFFSET = tonumber(read());
- if (COLOUR_OFFSET < 1 or COLOUR_OFFSET > 16) then
- print("Colour number (" .. COLOUR_OFFSET .. ") was not between 1 and 16")
- return
- end
- print("Enter the end colour number (" .. COLOUR_OFFSET .. "-16)")
- COLOUR_MAX = tonumber(read());
- if (COLOUR_MAX < 1 or COLOUR_MAX > 16) then
- print("Colour number (" .. COLOUR_MAX .. ") was not between 1 and 16")
- return
- end
- if (COLOUR_OFFSET == COLOUR_MAX) then
- print("Colour offset and max value are the same??? (" .. COLOUR_OFFSET .. ")")
- return
- end
- CURRENT_COLOUR = COLOUR_OFFSET
- --print("Enter the delay time between steps (in seconds)")
- --DELAY_TIME = tonumber(read());
- --if (DELAY_TIME < 0) then
- -- print("Delay cannot be negative!!!")
- -- return
- --end
- save_config()
- print("Saved configuration to file!")
- end
- while (true) do
- local event = os.pullEvent("redstone")
- if (rs.getInput(SIDE_INPUT)) then
- local col = numberToColour(CURRENT_COLOUR)
- --print("Colour type = " .. type(col) .. ", out type = " .. type(SIDE_OUTPUT))
- -- print("Set colour number: " .. CURRENT_COLOUR .. " (" .. col .. ")")
- redstone.setBundledOutput(SIDE_OUTPUT, col)
- CURRENT_COLOUR = CURRENT_COLOUR + 1
- if (CURRENT_COLOUR > COLOUR_MAX) then
- CURRENT_COLOUR = COLOUR_OFFSET
- end
- end
- end
Add Comment
Please, Sign In to add comment