Advertisement
Guest User

ff

a guest
Dec 23rd, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. -- storing argument present when program is launched
  2. -- ( on / off )
  3. local com = {...}
  4. if #com ~= 1 then
  5.     print( "usage: ff <on/off>" )
  6. end
  7. -- Opening the wireless modem
  8. rednet.open( "top" )
  9.  
  10. -- determining if you entered "on"
  11. if com[1] == "on" then
  12.  
  13.     -- telling other comp you want to turn on the forcefield
  14.     rednet.send( 0, "FF on" )
  15.    
  16.     -- password input
  17.     print( "Enter password:" )
  18.     password = read( "*" )
  19.     os.sleep( 0.5 )
  20.    
  21.     -- sending password to other comp
  22.     rednet.send( 0, tostring( password ) )
  23.    
  24.     --[[waiting for other comp to confirm or deny password.
  25.             this is handled by the other comp, so this just tells
  26.             you if you entered the correct password or not so you
  27.             know to try again.]]--
  28.     wVer = false
  29.     while not wVer do
  30.         local network, passVer = rednet.receive()
  31.         if passVer == "correct" then
  32.             print( "Password accepted." )
  33.             wVer = true
  34.         elseif passVer == "incorrect" then
  35.             print( "Password incorrect." )
  36.             wVer = true
  37.         end
  38.     end
  39.  
  40. -- determining if you entered "off"
  41. elseif com[1] == "off" then
  42.     rednet.send( 0, "FF off" )
  43.  
  44. else
  45.     print( "usage: ff <on/off>" )
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement