Stack (and Queue) in Construct 2?

Get help using Construct 2

Post » Tue Dec 20, 2011 6:59 am

Hey guys,

I'm trying to develop some "logical" puzzles. The array is cumbersome for my purposes. I've searched but could only find some implementations of stack (and queue) for Construct Classic.

Is there an implementation available for Stack (LIFO) and Queue (FIFO) in Construct 2?

Thanks.
B
14
S
5
G
7
Posts: 235
Reputation: 5,175

Post » Tue Dec 20, 2011 7:48 am

You could try the string expressions, such as these:

[code]
find(src, text)
Find the first index within src that text occurs, else returns -1.

left(text, count)
Return the first count characters of text.

len(text)
Return the number of characters in text.

lowercase(text)
Convert the given text to all lowercase.

mid(text, index, count)
Return the count characters starting from index in text.

replace(src, find, rep)
Find all occurrences of find in src and replace them with rep.

right(text, count)
Return the last count characters of text.

tokenat(src, index, separator)
Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

tokencount(src, separator)
Count how many tokens occur in src using separator. For example, tokencount("apples|oranges|bananas", "|") returns 3.
[/code]

Basically treat the string as an array, separated by character of choice (comma or such). With these expressions you can make your own FIFO and LIFO implementations.

Or you can use one of user made plugins.Mipey2011-12-20 07:49:20
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Tue Dec 20, 2011 7:32 pm

Thanks Mipey, nice suggestions and great link. However I wanted a cleaner approach, and couldn't find a plugin.

So I went ahead and created one myself :). Well, actually, transformed the array into a stack. But it's good enough.

In case anybody wants to use LIFO STACK plugin, here it is:

http://www.mediafire.com/?zf9bqcfnrg9bimg

Please add it to the big list, if you think it will help others too.

Thanks!
Geo.

PS: I <3 Construct 2 already. Great piece of work!
B
14
S
5
G
7
Posts: 235
Reputation: 5,175

Post » Tue Dec 20, 2011 7:44 pm

@Geo: I think it might helpful to others, but please make a proper topic in the plugins section. I'll then add it to the list.

PS: agreed on your PS Kyatric2011-12-20 19:45:01
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Tue Dec 20, 2011 9:15 pm

Thanks :) Done
B
14
S
5
G
7
Posts: 235
Reputation: 5,175

Post » Tue Dec 20, 2011 9:56 pm

Thank you, added.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Braus, supreme676 and 8 guests