Advertisement
Guest User

interface

a guest
Sep 1st, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 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.         term.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.         term.clear()
  29.         if rednet.isOpen(WLAN) == false then
  30.                 rednet.open(WLAN)
  31.         end
  32. end
  33.  
  34. function menu () -- TODO: lots of writes and formating
  35.         print("___________________ Commands ___________________")
  36.         for i,v in pairs(commands) do
  37.                 print(i.." on/off")
  38.         end
  39. end
  40.  
  41. init()
  42. local answer,command, status
  43. repeat
  44.     menu()
  45.     print("___________________ Interface ___________________")
  46.     print("Enter command.")
  47.     io.flush()
  48.         answer=io.read() -- or pullevent
  49.        
  50.         -- check answer
  51.         answer = string.lower(answer)
  52.         command, status = string.find(answer," ") -- found positions
  53.   if command ~= nil then
  54.     command = string.sub(answer, 1, command-1) -- found command
  55.                 status = string.sub(answer, status) -- found status
  56.     write(command)
  57.     if status ~= nil and commands[command] ~= nil then
  58.                         write(" ")
  59.       print(status)
  60.       send(command,status)
  61.     else
  62.       print("Error: Command or value not found.")
  63.                 end
  64.   else
  65.     print("Error: no Space.")
  66.         end
  67. until false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement