Stack (and Queue) in Construct 2?

0 favourites
  • 6 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • 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.

  • You could try the string expressions, such as these:

    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.
    

    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.

  • 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:

    mediafire.com

    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!

  • 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 <img src="smileys/smiley1.gif" border="0" align="middle">

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks :) Done

  • Thank you, added.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)