Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Ensure the modem is open for communication
- rednet.open("right") -- Replace "right" with the side where your modem is attached
- -- Label to identify turtles
- local turtleLabel = "mobkiller_turtle" -- Replace with the label you want to target
- -- Function to send a start/stop signal to turtles with a specific label
- local function sendSignalToTurtles(action)
- -- Broadcast the action to all turtles with the matching label
- rednet.broadcast(action)
- print("Sent " .. action .. " signal to turtles with label: " .. turtleLabel)
- end
- -- Main loop to monitor redstone input and control turtles
- local previousState = false
- while true do
- local currentState = redstone.getInput("back") -- Replace "back" with the side with redstone input
- if currentState and not previousState then
- print("Redstone signal ON - Starting turtles")
- sendSignalToTurtles("start")
- elseif not currentState and previousState then
- print("Redstone signal OFF - Stopping turtles")
- sendSignalToTurtles("stop")
- end
- previousState = currentState
- os.sleep(1) -- Small delay to prevent excessive checking
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement