Why does this 'double pick evaluate' not work?

Get help using Construct 2

Post » Tue Apr 21, 2015 6:42 am

(I don't have enough rep to link my .capx yet. I linked to it from the imgur image instead, so you can get it from there.)

Image

The dungeon generation algorithm is intended to work like this:
1) 200 times, generate a new RoomBlueprint. A RoomBlueprint is 128 pixels (two tiles in every direction) larger than the WallBlueprint which represents the room itself, because we want each room to be surrounded by some hallway tiles later. It's OK for hallways to overlap, but not for a room to jut into a hallway (and force it to be narrower than two tiles).
2) For each new room we make, we pick the RoomBlueprint (the one that is new) and all other WallBlueprints (ones that aren't new).
3) If our picked RoomBlueprint overlaps any other WallBlueprint or is outside the layout boundaries, then we REJECT and delete it.
4) Otherwise, we ACCEPT it and set it to no longer being new (and also do a pick all/pick evaluate so that we can select the new WallBlueprint and delete it)

However, I can't figure this out - The double pick evaluate never runs its sub events, ever, no matter what you try. Notably, if I set the Pick WallBlueprint by evaluating WallBlueprint.NewWall = 0 to = 1 instead, then it immediately works (and of course destroys every new room created, because it's destroyed by the own WallBlueprint it carries) - but this isn't useful for obvious reasons.

One idea I had was 'maybe if one of the pick evaluates returns an empty pick, it prevents subevents from running'. So I put in an Else event after the double pick evaluate so that the very first room can be set non-new, and then maybe the second room on will have non-new WallBlueprints to compare to so the pick will be non-empty - no luck. It still doesn't run, ever. So that idea was wrong.

We are going insane. Please help at once. (What I REALLY want to know is why the double pick evaluate never runs as written - because it means there is something I fundamentally don't understand, that I need to learn for future C2 writing.)
B
3
Posts: 4
Reputation: 183

Post » Tue Apr 21, 2015 9:00 am

I'm not sure why you are picking the wallblueprint at all..
wouldn't an "is overlapping wallblueprint" with the condition wallblueprint.newwall = 0 do the trick?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Apr 21, 2015 11:35 am

LittleStain wrote:I'm not sure why you are picking the wallblueprint at all..
wouldn't an "is overlapping wallblueprint" with the condition wallblueprint.newwall = 0 do the trick?

Good idea, but I tried this and it's also doing nothing:
Image
Everything gets set non-new but nothing gets destroyed for overlapping, ever.
B
3
Posts: 4
Reputation: 183

Post » Tue Apr 21, 2015 11:39 am

I guess the issue is the picking.

created instances can't be picked untill the next top level event, if I remember correctly
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Apr 21, 2015 11:53 am

LittleStain wrote:I guess the issue is the picking.

created instances can't be picked untill the next top level event, if I remember correctly


That contradicts this:

If I go back to the original code and change WallBlueprint.NewWall=0 to =1 in the first pick, it correctly picks newly created RoomBlueprint and WallBlueprint pairs, detects that it's overlapping itself and destroys it. So I am definitely picking newly created instances there without waiting for a new top level event to occur first.

Similarly:

In the second attempt I posted in the reply, if I set NewWall = 0 to NewWall = 1, it picks the new RoomBlueprint and WallBlueprint, detects that it's overlapping and destroys it, also resulting in new rooms in the same fashion.

So the ONLY combination that doesn't work is RoomBlueprint being new and WallBlueprint being anything but new. In these cases it NEVER EVER detects the overlap even when it's really obvious, and all rooms are kept alive. And I want to know why these cases are different, because right now I am missing some fundamental knowledge about how C2 works that stops me from seeing this, and it will drive me nuts until I know it.
B
3
Posts: 4
Reputation: 183

Post » Tue Apr 21, 2015 12:29 pm

So re-reading your events.

I assume wallblueprint is in a container with roomblueprint, for you are not creating wallblueprint seperately.

Ah.. I think I see..
There is no wallblueprint with newwall=0 within the selection you are picking from.
You will first have to pick all wallblueprints.
being that this is a subevent of the event creating the wallblueprint, automatically the just created instance is picked.
It has newwall=1 so no wallblueprints are picked.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Apr 21, 2015 1:40 pm

Hi, I am also working on this project. On the version I am working on, we have tried that solution (changing the first pick to pick newwall = 1 and it didn't work. We have also tried picking all instances before picking more specific ones and this too fails.
B
5
Posts: 15
Reputation: 505

Post » Tue Apr 21, 2015 2:07 pm

I can see a couple of problems there. There's the picking newly created objects problem and then there's a container picking problem (assuming WallBlueprint is in a container with RoomBlueprint).

I think what you are trying to do is: you create a room and a wall and then you want to pick the newly created room plus all of the previously created walls and check for overlaps. Right?

When you create an object, it is picked in that event and any sub-events but you can't pick it through a condition until the next top-level event (except for pick by UID). So, in the first iteration of the loop you create a room and a wall. They are both picked for the rest of the sub-events. In the second iteration, you create a new room and wall. Now those two are picked. The objects created in the previous iteration of the loop are no longer picked and can't be picked again by conditions (except by UID).

The other problem is that if you pick an object in a container then it picks all the other objects in that container. When you pick a room, its matching wall gets picked and when you pick a wall its matching room is picked. You can't pick them separately. You can't pick just a room from one container instance and the walls from another.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Tue Apr 21, 2015 2:18 pm

ramones wrote:I think what you are trying to do is: you create a room and a wall and then you want to pick the newly created room plus all of the previously created walls and check for overlaps. Right?


Yes, that's correct. We're trying to get it so that the red hallway will only check to see if it is overlapping walls that it was not created with. I am still personally very new at Construct 2 and I'm not asking to have every little thing done, but if you could point towards a solution that would be incredibly helpful!
B
5
Posts: 15
Reputation: 505

Post » Tue Apr 21, 2015 2:44 pm

The first problem you can get around by creating all of the objects first in one event and then do the checking in another. Like:
on start of layout -> create 200 rooms
on start of layout -> check for overlaps

For the container picking problem, you can use families. If rooms are in RoomFamily and walls are in WallFamily then picking RoomFamily won't pick the matching walls so you can pick them separately. There are probably other ways to do it like using another sprite that you place on top of a room and check if it is overlapping any other walls (or more than 1 wall?).
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Next

Return to How do I....?

Who is online

Users browsing this forum: Armench, Baidu [Spider], brunopalermo, dand, TRMG and 28 guests