Problem with Repeating Code - UPDATED [may be bug]

Get help using Construct 2

Post » Tue Dec 18, 2012 5:23 am

Appologies for the quad post but I have now removed the extra plugins from it so this file linked to THIS post is a vanilla install of construct 2 latest version. It still shows the same bug and I have now got the variable in question displaying and updating on every tick.

As you can see, whilst on every tick the text field updates what it shows, the visible / invisible property on the Downlight_1 does not.

therefore either this is a bug in the software where only some elements update when variables their properties rely upon change or it's just not making sense.

http://temp-share.com/show/dPf3gjo5W%20

I do not want to post this as a bug just yet in case (as annoying as it may be) this is how the software was intended to function. I understand that functioning like this will not burden resources scanning for changes every tick but at the same time, how else can this be fixed so it achieves my intended result.
B
6
S
1
Posts: 72
Reputation: 723

Post » Tue Dec 18, 2012 6:01 am

It appears that it may be a bug. It's acting like the "or" is not in the event.

A workaround would be to split the event into two, one condition each, both with the same actions.
B
79
S
24
G
55
Posts: 4,755
Reputation: 41,273

Post » Tue Dec 18, 2012 6:18 am

Thank you for confirming this. I think that will be my best work around as well.

If I get a chance and someone else has not stated otherwise then I will post this as a bug so that others do not have to lose their hair haha.
B
6
S
1
Posts: 72
Reputation: 723

Post » Tue Dec 18, 2012 1:57 pm

It's working as intended actually according to this:
http://www.scirra.com/FORUM/r91-or-block-and-picking_topic52579_post330550.html#330550

The 'mouse cursor over downlight_1' condition being false means that no downlight_1's are picked. You could have it like this:
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Tue Dec 18, 2012 2:56 pm

[QUOTE=ramones] It's working as intended actually according to this:
http://www.scirra.com/FORUM/r91-or-block-and-picking_topic52579_post330550.html#330550

The 'mouse cursor over downlight_1' condition being false means that no downlight_1's are picked. You could have it like this:
[/QUOTE]

I'm not sure that I follow what you mean so I'll try my best to describe what I think you are saying is happening.

Because the mouse is not over Downlight_1, it completely ignores the other possible event that can trigger this action ** the light switch variable = 1.

If that's true, then this Or block does not function like a standard OR argument as in my mind an or argument should react :

If mouse cursor is not over Downlight 1 or if light switch variable does not = 1 then do not perform the corresponding actions, however if either of these 2 conditions are met, then perform all corresponding actions triggered by this event.


that's a very strange usage of the Or argument. I'm not quite sure why it would be needed to operate like this if what I'm re-stating is accurate.
B
6
S
1
Posts: 72
Reputation: 723

Post » Tue Dec 18, 2012 6:27 pm

No the event does run because the second condition is true. The problem is with object picking.

In C2 each event has a selected object list (SOL) that contains all the objects that the actions should act on (AKA the picked objects). The conditions filter that list. If you have an event:
[code]
System: Every tick
    -> Sprite: Set visible
[/code]
it will set all Sprites visible because all the Sprite objects are in the SOL by default.

If you have a condition that references Sprite objects eg.
[code]
Mouse: Cursor is over Sprite
    -> Sprite: Set visible
[/code]
That condition filters the SOL to only contain Sprites that are under the mouse.
So the action (Sprite: Set visible) only applies to those Sprites.

In an OR block, the actions will run if any condition is true BUT the SOL is filtered by all of the conditions. So your event runs when Light_Switch = 1 but your Downlight_1 object isn't picked (because of the first condition) and so it doesn't get set visible.

I hope that makes sense.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Tue Dec 18, 2012 10:58 pm

That makes sense as far as, I now understand why the script does not work though it's not a genuine OR statement based on my previous programming experiences.

In normal OR statements, the actions are all performed as long as one of the possible events that can trigger them are true.

As pointed out the only work around to achieve a true OR statement seems to be creating 2 identical actions but with separate condition events.

thanks again for the further explanation, I might post a reply in that forum topic that you linked in your post relating to the Or Block and see if they are able to make the following adjustment :

Traditional OR Block (works as normal or statements do

Conditional Or Block (works the same way as the current or block)
B
6
S
1
Posts: 72
Reputation: 723

Post » Tue Dec 18, 2012 11:10 pm

Jax ? Didn't my post fix it ?
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Tue Dec 18, 2012 11:19 pm

[QUOTE=Whiteclaws] Jax ? Didn't my post fix it ?[/QUOTE] Unfortunately it did not, though I do appreciate the effort that you made to help get things up and running. Sadly, we were up against an odd situation that unless you know how the OR Block is meant to function, would not have known why unexpected results were occurring.
B
6
S
1
Posts: 72
Reputation: 723

Previous

Return to How do I....?

Who is online

Users browsing this forum: ETgirl79 and 19 guests