Author | Comment |
1337h4kor Wraith
Posted: 14 Oct 2007 19:42 GMT Total Posts: 612 | Ok I was wondering if there was some way to set a timer to increase by a set increment during the repeat subroutine.
For example: To increase a variable 'A' by 1 for every repeat cycle of this
0->K:Repeat K>21 and K<22:getKey->K:End
How can I make the variable A increase by lets say .5 and then when it reaches let's 2 make it goto Lbl F.
--- I wish i could swim in the sea of probabilty but once during my life. |
Lunchbox Carrier
Posted: 14 Oct 2007 20:09 GMT Total Posts: 2007 | There are ways to make a program pause briefly during execution, like via an empty For() loop.
e.g.
For(x,1,)600 End This, however, does not correspond to a set amount of time that can be reasonably measured. If you want to pause for a second (lowest increment possible), and you're programming on an 84+/SE, you can do this:
getTime->L1 getTime->L2 Repeat L1(3)=L2(3) getTime->L2 End This should work reasonably well, but I make no guarantees, as I have found the 84+ series' handling of its internal clock to be quite unsatisfactory.
Edit: Wait, hold on, you're not even talking about a timer at all. If you want a variable (call it foo) to increase by .5 everytime a loop executes, just put foo = foo + .5 in the body of the loop. |
1337h4kor Wraith
Posted: 14 Oct 2007 20:14 GMT Total Posts: 612 | but then how could I tell it to stop increasing and go to a certain Lbl after it reaches said value?
--- I wish i could swim in the sea of probabilty but once during my life. |
tifreak8x Administrator
Posted: 14 Oct 2007 20:30 GMT Total Posts: 419 | Well, you would do an If n=#:Goto L
Of course, using such code inside a loop will have its consequences...
--- Bringing you Pokemon, for your calculator. |
1337h4kor Wraith
Posted: 14 Oct 2007 20:45 GMT Total Posts: 612 | How well would that work inside of the repeat though?
--- I wish i could swim in the sea of probabilty but once during my life. |
tifreak8x Administrator
Posted: 14 Oct 2007 21:04 GMT Total Posts: 419 | It would work until it ran out of memory. You would need to exit the loop before jumping to the label.
--- Bringing you Pokemon, for your calculator. |
1337h4kor Wraith
Posted: 14 Oct 2007 21:09 GMT Total Posts: 612 | like how. Example using the loop that I used in the top would be greatly appreciated.
--- I wish i could swim in the sea of probabilty but once during my life. |
tifreak8x Administrator
Posted: 14 Oct 2007 21:12 GMT Total Posts: 419 | :0->K :Repeat K>21 and K<22 :getKey->K :A+.5->A :If A=3:21.3->K :End :If K=21.3:Goto LB
Something along those lines. I like While loops better. If you encompass everything in a single While loop, you can simply call the first While value and go to the top without ever having to use a Goto or Lbl.
--- Bringing you Pokemon, for your calculator. |
1337h4kor Wraith
Posted: 14 Oct 2007 21:17 GMT Total Posts: 612 | thank you so much tifreak8x you're definatly going to be in the credits of all of my games and above you're name it'll say 'Help with coding issues.'. Thanks. Now I can have the proper screen from the original game in my program.
Edit: Well anything else that is said on here won't be read by me until tomorrow because I'm going to bed. Mainly because it's like 0:30 hours here.
--- I wish i could swim in the sea of probabilty but once during my life. |
Lunchbox Carrier
Posted: 15 Oct 2007 07:51 GMT Total Posts: 2007 | Dude, just put
Repeat (K>=21 and K<=22) or A>=2 getKey->K A+.5->A End That will break when A gets to 2, or when 21 |
tifreak8x Administrator
Posted: 15 Oct 2007 09:07 GMT Total Posts: 419 | heh, you are right. So focused on my project I just put down the first thing I knew would work, without looking to see if it was optimizable... :P
--- Bringing you Pokemon, for your calculator. |
1337h4kor Wraith
Posted: 15 Oct 2007 10:18 GMT Total Posts: 612 | Ok thanks Lunchbox. I'll optimize it.
P.S. Is that optimizer on cementech any good. I mean I've used it thus far to see if it could be optimized.
--- I wish i could swim in the sea of probabilty but once during my life. |