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 | clear() | |
| 19 | print("___________________ Send ___________________")
| |
| 20 | if rednet.send(15,c.." "..s) then | |
| 21 | print("sent command.")
| |
| 22 | else | |
| 23 | print("Sending not successful.")
| |
| 24 | end | |
| 25 | end | |
| 26 | ||
| 27 | function init () | |
| 28 | clear() | |
| 29 | if rednet.isOpen(WLAN) == false then | |
| 30 | rednet.open(WLAN) | |
| 31 | end | |
| 32 | end | |
| 33 | ||
| 34 | function clear() | |
| 35 | term.setBackgroundColor(colours.black) -- Set the background colour to black. | |
| 36 | term.clear() -- Paint the entire display with the current background colour. | |
| 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 | local answer,command, status | |
| 49 | repeat | |
| 50 | menu() | |
| 51 | print("___________________ Interface ___________________")
| |
| 52 | print("Enter command.")
| |
| 53 | io.flush() | |
| 54 | answer=io.read() -- or pullevent | |
| 55 | ||
| 56 | -- check answer | |
| 57 | answer = string.lower(answer) | |
| 58 | command, status = string.find(answer," ") -- found positions | |
| 59 | if command ~= nil then | |
| 60 | command = string.sub(answer, 1, command-1) -- found command | |
| 61 | - | status = string.sub(answer, status) -- found status |
| 61 | + | status = string.sub(answer, status+1) -- found status |
| 62 | if status ~= nil and commands[command] ~= nil then | |
| 63 | send(command,status) | |
| 64 | else | |
| 65 | print("Error: Command or value not found.")
| |
| 66 | end | |
| 67 | else | |
| 68 | print("Error: no Space.")
| |
| 69 | end | |
| 70 | until false |