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
-
MaxV
- Posts: 1579
- Joined: Tue May 28, 2013 2:20 pm
- Location: Italy
-
Contact:
Post
by MaxV » Thu Feb 04, 2016 6:21 pm
I can't understand the
move command.
If I write:
Code: Select all
repeat with i=1 to 16
send "mex2" to image i in 0 sec
end repeat
and the following code in all images
Code: Select all
on mex2
move me relative "0,60" in 2 sec
wait 2 sec with messages
move me relative "0,-60" in 2 sec
end mex2
The second part of the movement is unpredictable.
The images don't come back in the same sequence they start moving...
Last edited by
MaxV on Sat Feb 06, 2016 7:35 am, edited 1 time in total.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
dunbarx
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Post
by dunbarx » Thu Feb 04, 2016 10:49 pm
Hi.
I would do it like this, in a button script:
Code: Select all
on mouseUp
repeat with i=1 to 16
mex2 i
end repeat
end mouseUp
on mex2 index
move img index relative "0,60" in 10
wait 4 with messages
move ing index relative "0,-60" in 10
end mex2
I shortened the timing just so things would progress in a reasonable time frame.
But Max, why invoke a second handler when one will do? You can rewrite this in about one minute, I know.
Craig Newman
-
bn
- VIP Livecode Opensource Backer
- Posts: 3999
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Post
by bn » Fri Feb 05, 2016 1:01 am
Max,
I don't quite what exactly you are trying to do. But if it is the fact that your control with the mex2 script in pauses 2 seconds before going up again then you might want to have a look at "without waiting"
Code: Select all
on mex2
move me relative "0,60" in 2 sec without waiting
wait 2 sec with messages
move me relative "0,-60" in 2 sec without waiting
end mex2
now the control moves down and then immediately up again. It does not wait 2 seconds when it is down as your script. In your script the whole thing takes 6 seconds and in "without waiting" it takes 4 seconds This is because move is blocking with "without waiting"
KInd regards
Bernd
-
MaxV
- Posts: 1579
- Joined: Tue May 28, 2013 2:20 pm
- Location: Italy
-
Contact:
Post
by MaxV » Fri Feb 05, 2016 11:56 am
I made this video:
https://www.youtube.com/watch?v=6EXPHwutSwM
I can't understand the
move command. If you look the video, when move has
NOT the
without waiting option, every image seems waiting the other images. Why this happen?
Every images receive its input, so every image should move independently from the others.
I'm very confused...
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
dunbarx
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Post
by dunbarx » Fri Feb 05, 2016 4:19 pm
I think the issues derive from the fact that the move command sort of lives its own life. Please try this experiment. On a new card, make a button and four fields. In the button script:
Code: Select all
on mouseUp
put 10 into moveTime
lock moves
repeat with i=1 to 4
move fld i relative "0,60" in moveTime without waiting
end repeat
unlock moves
wait moveTime with messages
lock moves
repeat with i=1 to 4
move fld i relative "0,-60" in moveTime without waiting
end repeat
end mouseUp
If anything new at all can be gleaned from the above nonsense, it is the introduction of the "lock/unlock moves" command.
Craig
-
MaxV
- Posts: 1579
- Joined: Tue May 28, 2013 2:20 pm
- Location: Italy
-
Contact:
Post
by MaxV » Fri Feb 05, 2016 6:20 pm
dunbarx wrote:I think the issues derive from the fact that the move command sort of lives its own life. Please try this experiment. On a new card, make a button and four fields.
...
If anything new at all can be gleaned from the above nonsense, it is the introduction of the "lock/unlock moves" command.
Craig
Craig,
I know the
lock/unlock moves, but it has more sense to me. Because only with this option you can perfectly synchronize some interactions.
My problem is that I want
unsynchronized movements, I want independent movements; but I get
now it's my turn style movements
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
[-hh]
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Post
by [-hh] » Fri Feb 05, 2016 6:36 pm
[ EDIT. The first version of this post was wrong, sorry.]
Hi MaxV,
the problem is not the "move" but the "wait".
If you try for example
Code: Select all
local w=20
on mouseUp
put line 13 to 20 of the script of me into s
repeat with i=1 to 16
put ("b"&i) into b
if there is no btn b then create btn b
set rect of btn b to (i*w,i*w,i*w+30,i*w+20)
set script of btn b to s
send "mex2 40" to btn b in i*100 millisecs
end repeat
end mouseUp
on mex2 x
if the shiftkey is down then exit mex2
-- move me relative 0,x in 1 sec
move me relative 0,x in 1 sec without waiting
send "mex2 -x" to me in 1 sec
end mex2
then you can control exactly whats going by using "without waiting" or not, as Bernd proposes (and what the dictionary to "move" claims).
Hermann
p.s. Nice videos!
Last edited by
[-hh] on Fri Feb 05, 2016 8:17 pm, edited 3 times in total.
shiftLock happens
-
dunbarx
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Post
by dunbarx » Fri Feb 05, 2016 6:42 pm
Hi.
If you remove all the "without waiting" in the example, the controls move in sequential order. is this closer to what you want? I suspect it is not exactly what you want, however.
Craig
-
MaxV
- Posts: 1579
- Joined: Tue May 28, 2013 2:20 pm
- Location: Italy
-
Contact:
Post
by MaxV » Sat Feb 06, 2016 7:34 am
[-hh] wrote:][/i]
Hi MaxV,
the problem is not the "move" but the "wait".
....
Hermann
p.s. Nice videos!
Hi Herman,
your code works great!
So I learned for complex movement:
- no more than a move in a handler
- use without waiting option
- calculate the time of movement
- at the end of the hanlder use send in xx sec a new hanlder containing the new movement, xx is the time of the last movement.
Thank you so much!
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
dunbarx
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Post
by dunbarx » Sat Feb 06, 2016 5:39 pm
Hermann.
That was terrific insight. This should be useful for many.
I would love to see a repository of clever solutions, not quite suitable for the "Sample Stacks" site, though one could make a stack that simply demonstrated techniques or solved problems, but rather an annotated library of handlers.
You might say that we already have this in the forum. But try to find this thread in a year. Keyword searches would do it, but how could a user even start to know what keywords are going to yield results?
Craig
-
[-hh]
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Post
by [-hh] » Sat Feb 06, 2016 6:23 pm
Craig wrote:That was terrific insight.
One of my teachers was Craig N. (and Bernd N. for the animation part)
Craig wrote:I would love to see a repository of clever solutions, not quite suitable for the "Sample Stacks" site, though one could make a stack that simply demonstrated techniques or solved problems, but rather an annotated library of handlers.
MaxV will make a short summary (he started already with the listing above) of what he's doing on
his site, not too complicated, isn't it Massimiliano?
And we will improve our knowledge of italian language by that ...
shiftLock happens
-
MaxV
- Posts: 1579
- Joined: Tue May 28, 2013 2:20 pm
- Location: Italy
-
Contact:
Post
by MaxV » Mon Feb 08, 2016 10:25 am
My personal site is in Italian, so I prefer to add things here in english:
http://livecode.wikia.com/wiki/HOW_TO
It's free and everybody can add his magic codes.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w