Posted 27 September 2013 - 02:29 PM
Hi there,
i have a short question about turtles and especially interrupting loops:
i sent from a computer 2 messages:
in my turtle i want to recieve this message and start or end a infinite turtle.attack() loop. And here i have the probelm.
To make my turtle attack all the time, i need this,or?
to activate it i use a os.pullEvent
but how to make the turtle.attack now infinite till i send "turtleoff", i tried following:
–> Error
Can anyone help me here?
thx in advance
#
Wiesl
i have a short question about turtles and especially interrupting loops:
i sent from a computer 2 messages:
(button pressed)
modem.transmit (1, 1, "turtleon")
(button pressed again)
modem.transmit (1, 1, "turtleoff")
in my turtle i want to recieve this message and start or end a infinite turtle.attack() loop. And here i have the probelm.
To make my turtle attack all the time, i need this,or?
while true do
turtle.attack()
end
to activate it i use a os.pullEvent
function msg()
event, par1, par2, par3, message, os.pullEvent(modem_message)
if message = "turtleon"
then
turtle.attack() -- how to make this infinite??
if message = "turtleoff"
then
print("OFF")
end
end
while true do
msg()
end
but how to make the turtle.attack now infinite till i send "turtleoff", i tried following:
function msg()
event, par1, par2, par3, message, os.pullEvent(modem_message)
if message = "turtleon"
then
while true do
turtle.attack() -- how to make this infinite??
end
if message = "turtleoff"
then
print("OFF")
end
end
while true do
msg()
end
–> Error
Can anyone help me here?
thx in advance
#
Wiesl