Advertisement
Guest User

oil.lua

a guest
Jul 13th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. local net = peripheral.find("modem")
  2. local chan = 2000
  3. local nchan = 1999
  4.  
  5. function supersosik()
  6.    
  7.     local event, modemSide, senderChannel, replyChannel, message, distance = os.pullEvent("modem_message")
  8.    
  9.     if message == "on" then
  10.         rs.setAnalogOutput("bottom", 1)
  11.         net.transmit(nchan, nchan, "Answer from station: \nStarted pumping")
  12.     elseif message == "off" then
  13.         rs.setAnalogOutput("bottom", 0)
  14.         net.transmit(nchan, nchan, "Answer from station: \nStopped")
  15.     else
  16.         net.transmit(nchan, nchan, "Answer from oil station: \nUnknown command")
  17.     end
  18. end
  19.  
  20. while true do
  21.  
  22. if net.isOpen(chan) then
  23.     supersosik()
  24. else
  25.     net.open(chan)
  26.     supersosik()
  27. end    
  28.  
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement