For Each Object w/ Particular Value

0 favourites
  • 9 posts
From the Asset Store
Create your own wss server and ws server with ssl and without ssl.
  • I'm having an issue where I only want to call objects with a certain value in a for loop, however, I'm having huge issues.

    <img src="https://dl.dropboxusercontent.com/u/72855875/Untitled.jpg" border="0" />

    So I only want to call walls with a areatype of areaselector (in this case, the number is 0)

    It works great, except when there is more than one group of walls with a different area type. As soon as I add a second set of walls to clone, the walls get all messed up in size and position.

    Is there an easy way to fix this or even an alternative? I briefly considered making a new family of walls for each room but that seems extremely tedious.

  • when you filter/pick instances of a family, it doesn't automatically filter the individual objects that may or may not be in that family.

    (To avoid confusion I'll refer to 'Walls' as 'Family' and 'Wall' as 'object')

    So you may be correctly picking what Family instance.. but it's still ambiguous as to what Object instance you want..

    hope that makes sense..

    a way to pick the same object as the family you've alread picked is, for example

    For each Family

       Object | Pick instance with UID: Family.UID

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • when you filter/pick instances of a family, it doesn't automatically filter the individual objects that may or may not be in that family.

    (To avoid confusion I'll refer to 'Walls' as 'Family' and 'Wall' as 'object')

    So you may be correctly picking what Family instance.. but it's still ambiguous as to what Object instance you want..

    hope that makes sense..

    a way to pick the same object as the family you've alread picked is, for example

    For each Family

       Object | Pick instance with UID: Family.UID

    Yeah it kind of makes sense, but it didn't work at all unfortunately. Here's what I did.

    <img src="http://puu.sh/4hIGZ.png" border="0" />

    Just to make sure, I ran that same thing with all the walls deleted except for areatype 0 and it works as it should. Only when there are multiple area types is the problem happening.

  • The purpose of the 'pick object instance with UID' was to pick the same object as the family you had filtered..

    now you've put 'for each object', and then you try and pick an object with the UID of an unspecified family..

    I think it'd help if I understand the context better..

    now that i look at it more carefully..

    is 'wall' a tiledbg within the 'walls' family? or is it a sprite that isn't part of the family?

    also what's this for? are you swapping out editor placeholders for actual objects on start up?

  • keepee

    Yes, Wall is part of the Walls family.

    Basically what I am trying to do is create rooms of walls that are off screen, and then clone those walls and re-position them in different areas in the game.

    I don't really understand the problem with what I did as you explained. Do I put the for loop in the same spot as the UID check? I'm pretty sure I tried that.

  • uh..sorry, i see now you are only using the family as a way to differentiate from the created wall object

    In which case, your events in the original post actually look correct, so are you sure it's not a problem with the way you position it after creation? You could check if the wall have been created or not by using a text object to display wall.count

    if they're not being created, it could still be a problem with the AreaSelector, or ZoneSelector... you can check these with a debug text object too.

    If all that stuff is fine, try reshuffling the conditions so the 'For each' is before the variable check, it shouldn't make a difference, but I remember having to do this in some cases

    like:

    +On start of layout

    +Zones | ZoneNumber = ZoneSelector

    +For each Walls                     

    +Walls | AreaType = AreaSelector      >Create object wall etc

  • uh..sorry, i see now you are only using the family as a way to differentiate from the created wall object

    In which case, your events in the original post actually look correct, so are you sure it's not a problem with the way you position it after creation? You could check if the wall have been created or not by using a text object to display wall.count

    if they're not being created, it could still be a problem with the AreaSelector, or ZoneSelector... you can check these with a debug text object too.

    If all that stuff is fine, try reshuffling the conditions so the 'For each' is before the variable check, it shouldn't make a difference, but I remember having to do this in some cases

    like:

    +On start of layout

    +Zones | ZoneNumber = ZoneSelector

    +For each Walls                     

    +Walls | AreaType = AreaSelector      >Create object wall etc

    It cant be a way I position it after creation, because like I said, if the only area that exists is area 0, it works perfectly. The Walls family has a value called Area Number that I change for which group of wall objects I want to spawn.

    Area and Zone selector are set to 0 for now for testing purposes.

    I did the count thing and it says the right amount of walls have been added. It looks like there are only 2 or 3 walls. I suspect they are stacked on top of each other so the X and Y values aren't really getting changed properly or something.

    So far I have reshuffled the 3 conditions into every different order that makes sense. All together, and with the loop being the sub event, and with the wall and area selector being a subevent. It doesn't seem to make a difference...

  • If this is the correct flow:

    1) You want to select from family zones whatever matches ZoneNumber

    2) You want to select from family walls whatever matches AreaType

    3) You want to loop through the list of objects selected by 2) and create a new object for each with coordinates from the current zones and the current walls object

    then this should have worked (basically your first try with just one small change):

    + on start of layout

    ++ Zones | ZoneNumber = ZoneSelector

    ++ Walls | AreaType = AreaSelector

    +++ System | For each Walls

    ---> Create Wall at ...

    If it doesn't then the coordinates you refer to seem to keep generic. The only thing that comes to my mind is that you have to make sure that the zones condition really only selects one object from zones. When applying zones.x and .y C2 has to have an explicit object to get the values from.

  • keepee

    tulamide

    Well, It actually is starting to seem like the looping for that particular event is not causing me the huge problems. At least I think so. It actually seems to be the way I was indicating the X and Y values. Here's a picture of what I'm doing there:

    <img src="http://puu.sh/4iueu.png" border="0" />

    And of my game layout

    <img src="http://puu.sh/4iupi.png" border="0" />

    I added the for loop right where I'm assigning X and Y values and that fixed the original problem I'm having...but now only area 0 will recreate properly. Area 1 and 2 seem to have broken X and Y positions on the walls and my feeling is that it's part of the first "on start of layout" block.

    I did your suggestion tulamide but the result didn't change from the picture above.

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