Picking instances in Functions

0 favourites
  • 4 posts
From the Asset Store
Dungeon generation
$4 USD
60% off
Template for dungeon/maze generation, using wave function collapse
  • Hello all,

    I'm working on designing some utility functions in my game. They each have a specific purpose e.g. pick all the instances in an area, pick all the instances with a specific frame displayed, count all the instances in an area, etc.

    I was hoping if I called a second function inside a function that the instances picked from the first function would be passed to the second function. That would have allowed me to combine all the variations as needed. I tested things and this doesn't seem to be the case and the instances aren't passed along.

    Can anyone think of a way around this? The alternative is designing a giant function that includes all variations.... which is not preferred.

    Thanks all!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can you use an instance variable to mark the picked instances, then one event can pick them later.

  • Instance variable is the easiest way to do it. You can also try something like this:

    build a string with UIDs of all picked instances in the first function and pass it as a parameter to the second function.

    Make sure to separate UIDs with some character, say "#".

    In your second function pick the same set of instances using find(function.param(0), "#"& str(Sprite.UID) &"#" )>-1

  • Ah! Great suggestions. Both are totally doable but I think I may go with the instance variable method.

    Thanks all!

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