repeat and wait together in move

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

Post Reply
chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

repeat and wait together in move

Post by chris25 » Sat Nov 23, 2013 12:25 pm

Yes I know, sorry, but really I have tried all sorts of combinations involving the repeat while and repeat statements. Human logical thinking has not helped me solve this so please could you show me the correct syntax
I am simply wanting to slow down the movement from pixel to pixel. If I am not worthy of the answer then just a clue would make me happy. Actually a clue might be better, thanks, I really get annoyed at not being able to work it out. Thankyou.
on moveBox
if keysdown() = 65362 then
set the top of the button "box" to the top of the button "box" - 1
--wait 30 ticks
end if

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: repeat and wait together in move

Post by Klaus » Sat Nov 23, 2013 12:49 pm

Code: Select all

on movebox
  if keysdown() = 65362 then
     set the top of the button "box" to the top of the button "box" - 1
  end if
  --wait 30 ticks

  ## If you want a handler to do the same over a preiod of time, SEND the message again with a delay!
  send "movebox" to me in 30 ticks
end movebox
8)

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: repeat and wait together in move

Post by jmburnod » Sat Nov 23, 2013 1:06 pm

Hi Chris,

You can use a local time counter to do that

Code: Select all

local sChrono
on moveBox
   if keysdown() = 65362 then
      if the ticks > (sChrono + 30) then
         set the top of the button "box" to the top of the button "box" - 1
         put the ticks into sChrono
      end if
   end if
end moveBox
Jean-Marc
https://alternatic.ch

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: repeat and wait together in move

Post by chris25 » Sat Nov 23, 2013 1:21 pm

When I see the answer it's seems so obvious. Thankyou. Jean - Marc thanks for the variation.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10332
Joined: Wed May 06, 2009 2:28 pm

Re: repeat and wait together in move

Post by dunbarx » Sat Nov 23, 2013 5:34 pm

Chris.

It isn't so much that you miss the obvious, it is rather that you have undertaken all of LC at once, and do not have the experience with techniques and tricks (and work-arounds) that have been learned over many years. Decades in some cases. Your progress is lightning-like. Your dedication and stubbornness are inspirational. We are patient. So must you be.

Craig

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: repeat and wait together in move

Post by chris25 » Sat Nov 23, 2013 6:08 pm

That is a good point and I do agree with you. I definitely tried to keep it simple though. Which is why I came up with this - All I am doing is the following:

To learn different movement techniques:
To grind myself in the use of variables and Functions:
To grasp randomization:
To learn how to use intersection with objects whereby the area of impact varies at a different radius from the centre:

I am learning much more besides and feel that despite the apparent ignorance I have shown in my questioning each answer is providing so much more than just an answer to the current problem. I am building up a library of answers and codes that I use to investigate further in other simple tasks, trying to remember to use the message box, practising understanding the debug and watching what happens at breakpoints. Yes it is probably a lot too much too early, and strategy is not something I will not learn in a few months, and I see that it is an inability of being able to conceptualize a sort of mental strategic organization of syntax and methods that causes most of my problems. Anyway I came up with what I thought was simple enough to begin with.

The non-functional graphic stack is here if you are interested.

EDIT, ok try again:

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: repeat and wait together in move

Post by jacque » Sat Nov 23, 2013 8:25 pm

Here's an article I wrote to explain what a function is. It's specifically aimed at new programmers:

http://www.hyperactivesw.com/resources_function.html
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: repeat and wait together in move

Post by chris25 » Sun Nov 24, 2013 12:18 am

Jacque very kind of you to post this. I actually have this next to all my references, I read it through a number of times but found it hard to relate to, and putting it into practise after reading was troublesome. However, now that I have experienced a number of situations with functions within a working environment so to speak I can ead your article with a better understanding, it makes more sense to me what you explain.
Kindest regards
chris

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: repeat and wait together in move

Post by jacque » Sun Nov 24, 2013 5:52 am

If it's any consolation, I had a hard time with functions when I first started. And I wrote the article when another new programmer had the same trouble. Once the shoe drops it's easy, but there's no real world parallel for it, it's strictly a programming thing.

You can think of a function like a carrier pigeon. You want some info so you tie a basket to the bird and let it fly off. It comes back with the data in the basket. You put the data into a variable and use it however you want.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: repeat and wait together in move

Post by Simon » Sun Nov 24, 2013 7:35 am

Jacque WOW!!!
http://www.hyperactivesw.com/Resources.html
HyperCard Tips and Tricks
Both you and Craig Newman have postings in '98!
Your 10 thousand hours are well up.

Chris, do you get it? These guys way way way out of my league.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: repeat and wait together in move

Post by jacque » Sun Nov 24, 2013 7:47 am

LOL. I'd been at it over 10 years by then too. I started learning the language with HyperCard 1.0 in 1987. I've known Craig almost all that time too -- only we've never met in person and I still don't know what he looks like.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: repeat and wait together in move

Post by chris25 » Sun Nov 24, 2013 9:18 am

Haven't you two heard of Skype? the humble photograph? no variables needed here.... :)

""Chris, do you get it? These guys way way way out of my league."" Back in the days when I was building the pyramids, I remember having to actually walk some distance to a phone attached to a long piece of string, and then I had to reach down after months of body building, and haul that phone to my ears. After sitting down, due to the exhaustion of having to hold the phone with one hand and then having to turn a great big metal wheely thing with numbers underneath it, I would hear a nice attractive woman on the other end say -"How would you like to be connected sir"....after 5 whole cumbersome minutes and having to leave two rooms, walk 6 metres and sometimes downstairs or upstairs, and grab one chair and close one other door, nobody was in....I like the pyramids

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10332
Joined: Wed May 06, 2009 2:28 pm

Re: repeat and wait together in move

Post by dunbarx » Sun Nov 24, 2013 4:36 pm

Jacque.

Funny. I have had your picture for many years, and had actually noticed that you might not have mine. Guys don't generally notice anything at all, so I am proud of that.

I am computer challenged. My kids, or at least the ones I know about, run my facebook page. I guess you could search for me. I hate being photographed, as you will see...

Craig

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: repeat and wait together in move

Post by chris25 » Sun Nov 24, 2013 6:32 pm

While we were on the subject,Jacque, about this article, I noticed that a person called Geoff Canyon had a website link with your article. The website no longer exists, any chance you might know about his article though?

Chris

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: repeat and wait together in move

Post by jacque » Sun Nov 24, 2013 8:58 pm

Oh dear, he's had that site forever. It does seem to be gone now and I can't find where it went. I'll remove the dead link from my article, thanks for the heads-up.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply