Advertisement
CaptainResu

elevator_door

Dec 25th, 2022 (edited)
976
-1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 1
  1. peripheral.find("modem", rednet.open);
  2. function gethost()
  3.     while true do
  4.         local tmphost = rednet.lookup("elevator", "elevator.api");
  5.  
  6.         if (type(tmphost) == "number") then
  7.             return tmphost;
  8.         end
  9.     end
  10. end
  11.  
  12. local host = gethost();
  13. -- local host = 7;
  14. rednet.send(host, "iamel_door");
  15.  
  16. function iam()
  17.     -- host = rednet.lookup("elevator", "elevator.api");
  18.     rednet.send(host, "iamel_door");
  19. end
  20.  
  21. local doorside = "back";
  22.  
  23. redstone.setOutput(doorside, true);
  24. sleep(0.1);
  25. redstone.setOutput(doorside, false);
  26.  
  27. while true do
  28.     -- iam();
  29.     -- sleep(0.5);
  30.     com, msgdata = rednet.receive(nil, 5);
  31.  
  32.     print("com: " .. tostring(com));
  33.     print("msg: " .. tostring(msgdata));
  34.  
  35.     -- for Key = 1, #msg, 1 do
  36.     --     print(msg[Key]);
  37.     -- end;
  38.    
  39.     if(msgdata == "open") then
  40.         redstone.setOutput(doorside, true);
  41.     elseif(msgdata == "close") then
  42.         redstone.setOutput(doorside, true);
  43.         sleep(0.1);
  44.         redstone.setOutput(doorside, false);
  45.     end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement