Advertisement
MrFinn

Turtle - mobfarm main computer

Nov 7th, 2024 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. -- Ensure the modem is open for communication
  2. rednet.open("right") -- Replace "right" with the side where your modem is attached
  3.  
  4. -- Label to identify turtles
  5. local turtleLabel = "mobkiller_turtle" -- Replace with the label you want to target
  6.  
  7. -- Function to send a start/stop signal to turtles with a specific label
  8. local function sendSignalToTurtles(action)
  9. -- Broadcast the action to all turtles with the matching label
  10. rednet.broadcast(action)
  11. print("Sent " .. action .. " signal to turtles with label: " .. turtleLabel)
  12. end
  13.  
  14. -- Main loop to monitor redstone input and control turtles
  15. local previousState = false
  16. while true do
  17. local currentState = redstone.getInput("back") -- Replace "back" with the side with redstone input
  18.  
  19. if currentState and not previousState then
  20. print("Redstone signal ON - Starting turtles")
  21. sendSignalToTurtles("start")
  22. elseif not currentState and previousState then
  23. print("Redstone signal OFF - Stopping turtles")
  24. sendSignalToTurtles("stop")
  25. end
  26.  
  27. previousState = currentState
  28. os.sleep(1) -- Small delay to prevent excessive checking
  29. end
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement