I checked my Code again and see that you can reduce it to one while loop cause the parralell is executed in a while true loop you dont need the loop in the atk function.
Depending on your setup you can play around with the sleep command a bit to increase performance.
to make it easier for you to play around with the delay i added the delay as argument
if you start your program without arguments the delay is 1 second. if you want to start it with another delay just use <yourprogramname> x
where x is delay between attacks in seconds
rednet.open("right")
local running = true
args = ... or 1
local function atk()
if running == true then
turtle.attack()
print("attacking")
sleep(tonumber(args))
else
print("wait for command")
sleep(10)
end
end
local function switchit()
event, id, text = os.pullEvent()
if text == "on" then
running = true
elseif text =="off" then
running = false
print("Stop attack")
end
end
while true do
parallel.waitForAny(switchit,atk)
end
Greets Loki



