Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
richmond62
- Livecode Opensource Backer

- Posts: 10137
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Fri Aug 29, 2025 11:06 am
I have a young friend/victim who has got himself in trouble with this:
Code: Select all
command moveEnemy
if field "f1" is empty then
move image "Knight 2" to random(800), random(600) in 2 seconds
end if
if field "f1" is empty then
move image "Knight 45" to random(800), random(600) in 2 seconds
end if
send "moveEnemy" to me in 2 secs
end moveEnemy
On attempting to quite the LC IDE the 'thing' gets caught at
move image "Knight 45" to random(800), random(600) in 2 seconds and will NOT
quit.
-
richmond62
- Livecode Opensource Backer

- Posts: 10137
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Fri Aug 29, 2025 11:14 am
Here's the stack:
Not any more: see posting further down.
-
Last edited by
richmond62 on Sat Aug 30, 2025 4:16 pm, edited 1 time in total.
-
Klaus
- Posts: 14213
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Fri Aug 29, 2025 11:22 am
Try with two different commands:
Code: Select all
command moveEnemy1
if field "f1" = empty then
move image "Knight 2" to random(800), random(600) in 2 seconds
end if
send "moveEnemy2" to me in 2 secs
end moveEnemy1
command moveEnemy2
if field "f1" = empty then
move image "Knight 45" to random(800), random(600) in 2 seconds
end if
send "moveEnemy1" to me in 2 secs
end moveEnemy2
Maybe test with "... move... without waiting"
AND add a way to CANCEL the MOVEs when neccessary!

-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10356
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Fri Aug 29, 2025 1:54 pm
Richmond.
Have not tested, but a quick glance tells me this is a loop without end. Handler 1 calls handler 2, and then guess what handler 2 does.
Craig
-
richmond62
- Livecode Opensource Backer

- Posts: 10137
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Fri Aug 29, 2025 3:54 pm
I have suggested to Alexander (the pupil in question) that he registers for this list . . . a clever laddie, that.
Alexander's "problem" is concerned with keeping his baddies moving around while the end-user manipulates the goody with key commands.
-
stam
- Posts: 3108
- Joined: Sun Jun 04, 2006 9:39 pm
Post
by stam » Sat Aug 30, 2025 2:58 pm
richmond62 wrote: ↑Fri Aug 29, 2025 11:06 am
I have a young friend/victim who has got himself in trouble with this:
Code: Select all
command moveEnemy
if field "f1" is empty then
move image "Knight 2" to random(800), random(600) in 2 seconds
end if
if field "f1" is empty then
move image "Knight 45" to random(800), random(600) in 2 seconds
end if
send "moveEnemy" to me in 2 secs
end moveEnemy
On attempting to quite the LC IDE the 'thing' gets caught at
move image "Knight 45" to random(800), random(600) in 2 seconds and will NOT
quit.
1. Why the two “if” statements? The condition is the same, why not have them as a single conditional?
2. The only way to terminate this handler is to put something into field “f1” - why not do that when trying to quit? Or clear the pending messages…
-
richmond62
- Livecode Opensource Backer

- Posts: 10137
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Sat Aug 30, 2025 3:29 pm
I did wonder about ' flushEvents'.
-
richmond62
- Livecode Opensource Backer

- Posts: 10137
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Sat Aug 30, 2025 3:47 pm
OOF:
My pupil states that he has registered here but it is 'inactive' . . .