Advertisement
Corbinhol

Main Controller

Sep 23rd, 2022 (edited)
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. --Main Duper Controller
  2. local protocol = "TNTDUPER";
  3. rednet.open("back");
  4. local enderAddress;
  5. local singularityAddress;
  6. local tntAddress;
  7. while true do
  8. enderAddress = rednet.lookup(protocol, "ender_dust");
  9. singularityAddress = rednet.lookup(protocol, "singularity");
  10. tntAddress = rednet.lookup(protocol, "duper");
  11. if enderAddress ~= nil and singularityAddress ~= nil and tntAddress ~= nil then break; end
  12. sleep(0);
  13. end
  14.  
  15. term.clear();
  16. term.setCursorPos(1,1);
  17.  
  18.  
  19. function getDispenserStatus(dispenser)
  20.     local dispenserAddress = rednet.lookup(protocol, dispenser);
  21.     if dispenserAddress == nil then return false; end
  22.     rednet.send(dispenserAddress, "hasItem", protocol);
  23.     local from, has = rednet.receive(protocol, 1);
  24.     if has == nil then has = false; end
  25.     return has;
  26. end
  27.  
  28. function activateDispensers()
  29.     rednet.send(enderAddress, "triggerDispenser", protocol);
  30.     rednet.send(singularityAddress, "triggerDispenser", protocol);
  31. end
  32.  
  33. function activateTNT()
  34.     rednet.send(tntAddress, "activate", protocol);
  35. end
  36.  
  37. function server()
  38.     while true do
  39.         if getDispenserStatus("ender_dust") and getDispenserStatus("singularity") and redstone.getInput("front") == false then
  40.             activateTNT();
  41.             sleep(3);
  42.             activateDispensers();
  43.             sleep(3);
  44.         end
  45.         sleep(0);
  46.     end
  47. end
  48.  
  49. server();
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement