How do I Rotate through Array values based on timers?

Get help using Construct 2

Post » Thu Apr 09, 2015 11:06 pm

I have a simple premise, you see every 30 seconds (a date keeper) I want a text value to change to the next array value I've placed on the x axis. Now, I have a faint clue as to the use of Curvalue but my attempts have ended in failure. If someone can let me know how to do this I would be grateful.

Note: I've read the Array tutorials and know about appending values and such but not how to cycle through the NEXT value. As in there isn't a "do next value". Unsure how I would even loop them.
B
4
Posts: 33
Reputation: 266

Post » Thu Apr 09, 2015 11:14 pm

You could use the Array.At(x) expression, where x is the index you'd like to get the value for and 'Array' is the name of your Array.

Assuming you have a global variable called "CurrentIndex", you could do something like this:

Every 30 seconds:
-- Set text to Array.At(CurrentIndex)
-- Add 1 to CurrentIndex
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053

Post » Thu Apr 09, 2015 11:17 pm

Dalal wrote:You could use the Array.At(x) expression, where x is the index you'd like to get the value for and 'Array' is the name of your Array.

Assuming you have a global variable called "CurrentIndex", you could do something like this:

Every 30 seconds:
-- Set text to Array.At(CurrentIndex)
-- Add 1 to CurrentIndex


Thats almost exactly what I had tried.. but perhaps I forgot to assign the value as an array.

EDIT: I'll let you all know how it turns out and post a capx.
B
4
Posts: 33
Reputation: 266

Post » Thu Apr 09, 2015 11:22 pm

Rotate Array With Push and Pop

Run it, then UP and DOWN arrow keys to "rotate" the array.

Using this method you can just get the value of a fixed index like..

DateKeeper = Array.At( 3 )

Using Pop and Push, the value at (3) will be different.

Hope that helps!
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Thu Apr 09, 2015 11:23 pm

Ahhh seems I might've misunderstood what you wanted. Although my method still works, it might be a bit of overkill...
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Apr 10, 2015 3:33 am

Alright everyone, I hope this helps you all:I am hoping someone knows of maybe a better way to do something like this, but this is the 'proof of concept' as it were. It needs more polish. Right now its set to a 1.0 second cycle. Which should be made longer for more use but is convenient for testing purposes.


EDIT:
[dl.dropboxusercontent.com/]
[s/g8g8ictk18lloau/time_runner.capx?dl=0]
B
4
Posts: 33
Reputation: 266

Post » Fri Apr 10, 2015 4:54 pm

You code does not look very much to the point and your times will produce slight inaccuracies (since it sets timervariable to 0 instead of timervariable - 1 (the time of your cycle))
https://copy.com/q46Og7yBAVnJkZWu
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Fri Apr 10, 2015 7:18 pm

Yes I agree there is a time delay so its not going to be exactly 1 second each time.

EDIT: Well I checked yours out and although I cant understand it I think its way more efficient and it taught me that you can list Values in one variable? GlobalVar: Stuff1;Stuff2;Stuff3;
B
4
Posts: 33
Reputation: 266


Return to How do I....?

Who is online

Users browsing this forum: COGames, loz666, Mogador, Odin, Sumyjkl and 1 guest