Advertisement
Guest User

interface

a guest
Sep 1st, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  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.  
  19.     rednet.send(15,c.." "..s)
  20. end
  21.  
  22. function init ()
  23.     term.clear()
  24.     if rednet.isOpen(WLAN) == false then
  25.         rednet.open(WLAN)
  26.     end
  27. end
  28.  
  29. function menu () -- TODO: lots of writes and formating
  30.     print("_________________________")
  31.     print("Commands: command")
  32.     for i,v in pairs(commands) do
  33.         print(i.." on/off")
  34.     end
  35. end
  36.  
  37. init()
  38. local answer,command, status
  39. repeat
  40.     menu()
  41.     print("_________________________")
  42.     print("Enter command.")
  43.     io.flush()
  44.     answer=io.read() -- or pullevent
  45.    
  46.     -- check answer
  47.     answer = string.lower(answer)
  48.     command, status = string.find(answer," ") -- found positions
  49.     if found ~= nil then
  50.         command = string.sub(answer, 1, command) -- found command
  51.         status = string.sub(answer, status) -- found status
  52.         if command[found] ~= nil then
  53.             send(command,status)
  54.         end
  55.     end
  56. until false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement