Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(toSplit, pattern, results)
- if not results then
- results = {}
- end
- local start = 1
- local splitStart, splitEnd = string.find(toSplit, pattern, start)
- while splitStart do
- table.insert(results, string.sub(toSplit, start, splitStart-1))
- start = splitEnd+1
- splitStart, splitEnd = string.find(toSplit, pattern, start)
- end
- table.insert(results, string.sub(toSplit, start))
- return results
- end
- function main()
- rednet.open("bottom")
- local leave
- repeat
- print("Enter the desired action.") --Format: state(on, off, allOn, allOff) row(1-15) color(1-15, only necessary if on or off state)
- input = read()
- input_table = split(input, " ")
- instructions = {}
- instructions[1] = input_table[1] -- Action
- rowNumber = input_table[2] -- Row number
- instructions[2] = input_table[3] -- Light number (color on cable)
- if instructions[1] == "allOn" or instructions[1] == "allOff" then
- print("Performing "..instructions[1].." to "..rowNumber)
- else
- print("Turning "..instructions[1].." light number "..instructions[2].." in "..rowNumber)
- end
- rednet.broadcast(instructions, rowNumber)
- print("Continue? Type false to stop")
- leave = read()
- until leave == "false"
- end -- end main()
- main()
Advertisement
Add Comment
Please, Sign In to add comment