SHOW:
|
|
- or go back to the newest paste.
| 1 | --[[ | |
| 2 | ||
| 3 | Control_Interface:14 | |
| 4 | Control_RedstoneServer:15 | |
| 5 | Control_RedstoneClient1:24 | |
| 6 | Control_Bee:25 | |
| 7 | ||
| 8 | --]] | |
| 9 | ||
| 10 | local WLAN = "top" | |
| 11 | local coloroff = colors.red; | |
| 12 | local coloron = colors.green; | |
| 13 | local commands = {} --
| |
| 14 | commands["boringmachine"] = true -- has to be always true! | |
| 15 | --table.insert(orders,"exctractor",true) | |
| 16 | ||
| 17 | function send (c,s) | |
| 18 | - | term.clear() |
| 18 | + | clear() |
| 19 | - | print("___________________ Send ___________________")
|
| 19 | + | print("___________________ Send ___________________")
|
| 20 | - | if rednet.send(15,c.." "..s) then |
| 20 | + | if rednet.send(15,c.." "..s) then |
| 21 | - | print("sent command.")
|
| 21 | + | print("sent command.")
|
| 22 | else | |
| 23 | - | print("Sending not successful.")
|
| 23 | + | print("Sending not successful.")
|
| 24 | end | |
| 25 | end | |
| 26 | ||
| 27 | function init () | |
| 28 | - | term.clear() |
| 28 | + | clear() |
| 29 | - | if rednet.isOpen(WLAN) == false then |
| 29 | + | if rednet.isOpen(WLAN) == false then |
| 30 | - | rednet.open(WLAN) |
| 30 | + | rednet.open(WLAN) |
| 31 | end | |
| 32 | end | |
| 33 | ||
| 34 | function clear() | |
| 35 | - | print("___________________ Commands ___________________")
|
| 35 | + | term.setBackgroundColor(colours.black) -- Set the background colour to black. |
| 36 | - | for i,v in pairs(commands) do |
| 36 | + | term.clear() -- Paint the entire display with the current background colour. |
| 37 | - | print(i.." on/off") |
| 37 | + | term.setCursorPos(1,1) -- Move the cursor to the top left position. |
| 38 | end | |
| 39 | ||
| 40 | function menu () -- TODO: lots of writes and formating | |
| 41 | print("___________________ Commands ___________________")
| |
| 42 | for i,v in pairs(commands) do | |
| 43 | print(i.." on/off") | |
| 44 | end | |
| 45 | end | |
| 46 | ||
| 47 | init() | |
| 48 | - | answer=io.read() -- or pullevent |
| 48 | + | |
| 49 | - | |
| 49 | + | |
| 50 | - | -- check answer |
| 50 | + | |
| 51 | - | answer = string.lower(answer) |
| 51 | + | |
| 52 | - | command, status = string.find(answer," ") -- found positions |
| 52 | + | |
| 53 | - | if command ~= nil then |
| 53 | + | |
| 54 | - | command = string.sub(answer, 1, command-1) -- found command |
| 54 | + | answer=io.read() -- or pullevent |
| 55 | - | status = string.sub(answer, status) -- found status |
| 55 | + | |
| 56 | - | write(command) |
| 56 | + | -- check answer |
| 57 | - | if status ~= nil and commands[command] ~= nil then |
| 57 | + | answer = string.lower(answer) |
| 58 | - | write(" ")
|
| 58 | + | command, status = string.find(answer," ") -- found positions |
| 59 | - | print(status) |
| 59 | + | if command ~= nil then |
| 60 | - | send(command,status) |
| 60 | + | command = string.sub(answer, 1, command-1) -- found command |
| 61 | - | else |
| 61 | + | status = string.sub(answer, status) -- found status |
| 62 | - | print("Error: Command or value not found.")
|
| 62 | + | if status ~= nil and commands[command] ~= nil then |
| 63 | - | end |
| 63 | + | send(command,status) |
| 64 | - | else |
| 64 | + | |
| 65 | - | print("Error: no Space.")
|
| 65 | + | print("Error: Command or value not found.")
|
| 66 | end | |
| 67 | else | |
| 68 | print("Error: no Space.")
| |
| 69 | end | |
| 70 | until false |