"Else" forgets picking and fires at strange times [SOLVED?]

For questions about using Classic.

Post » Mon Nov 16, 2009 7:57 pm

Hi!

So yeah, I have this puzzle thing where you place irregular pieces and they snap to their destination. It's all good there.

When a piece doesn't snap in place, I want it to snap back to it's source position. I am using "Dragdrop" behavior, so I had an "On Drop" event that checks if placement is proper.
I placed an "Else" event after it, but one can't use "Else" after events in Construct. So I just put everything inside a sub-event of the "On Drop" event that picks the proper puzzle piece. Now I can use "Else" against the other conditions (distance to proper destination, etc).

Turns out that when that "Else" event fires, it doesn't remember the piece picked with the "On Drop" event, and after it has fired once it will also fire every time, even if the conditions do not match.
O.o what gives? I already went around "Else" in another game, is it completely broken now?

[url:1vyqypnk]http://www.udec.cl/~jfuente_alba/regiontest.cap[/url:1vyqypnk]
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Mon Nov 16, 2009 10:17 pm

I prefer else forgetting the selected objects - if it didn't work that way, there's some stuff that I don't know how it would be possible to do. Else events run if the event preceding it does not run - so if you want it to run only once, a trigger once condition after the else should work. (I haven't checked the .cap)

Example:

value = 1
- action 1
else
- action 2

So if value does not equal 1, else will repeatedly fire until it does. IIRC, else events don't work properly if there's a subevent between them, like this:

value = 1
- action 1
subevent conditions
subevent actions
else
- action 2

I don't know if that's been fixed or not, but it sounds like it hasn't.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Mon Nov 16, 2009 11:05 pm

What I have in the .cap I posted is something like this

event OnDrop A
+condition
-action 1
+else
-action 2


What's happening is that action 2 happens OnDrop EVEN IF CONDITION IS TRUE. Which doesn't make any sense.

I do have a subevent between them. Urgh. I'll try reversing the condition, as the "else" doesn't have any subevents.

Edit: Can't really reverse the condition, as it involves picking =( Please look at the posted .cap!
Edit2: Tried using function object to avoid having a subevent between condition and else and it does exactly the same =(
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Mon Nov 16, 2009 11:23 pm

Else does not remember picked objects properly, and due to the architecture of the event engine, it probably can't be fixed until Construct 2. To be honest, if you need Else to pick properly, don't use it (just invert conditions).
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Mon Nov 16, 2009 11:44 pm

If you do invert conditions as an alternative, remember that changes in the preceding event with non-inverted condition CAN influence the one after it.

If you want to do switching, you may have to be creative...
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Wed Nov 18, 2009 2:44 am

Added a global variable and set it to 0 just before, then set it to 1 if the condition was true, then instead of else, I check the variable.

Which is sort of what I expected Else to do. Can't it be done in such a fashion within Construct?
I mean, it was misfiring AND forgetting picking from a PARENT event.... I've never been able to use it, as whenever I need it, it just bugs out.

Anyway, FIXED, sorta.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Nov 18, 2009 6:59 am

Ah, such a simple solution! I haven't really thought of that.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests