Problem with Repeating Code - UPDATED [may be bug]

0 favourites
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • I have been working to get this particular down light to turn on if the switch is clicked or if the mouse moves over it and to be off in any other situation (switch clicked to the off position *unlit* or mouse not hovering over the downlight).

    However what is currently happening is as follows :

    1 - Downlight starts off turned on and Light switch is lit up (due to global variable Light_Switch being set to 1 by default)

    2 - Downlight turns on when turned off and the mouse moves over the down light but flicks off when the mouse is not over the down light

    3 - Light turns off when the switch is clicked and the switch also stops being lit.

    PROBLEM : when I click the light switch again... the down light does not come back on.

    Only when I then move my cursor over the down light does it turn back on again and stay on. but for some reason it requires the mouse to move over the downlight sprite for it to update and realise that the variable has changed back to 1 and therefore should already be on permanently again.

    CODE in QUESTION : below :

    <img src="http://a1.ec-images.myspacecdn.com/images02/130/adde15e2a741472b8dda32b2f6800e15/l.png" border="0" />

  • Read the 3rd paragraph before reading this one

                                                   V

    I know what is happening , when you click with the mouse , you click on the two objects at once ... Try to re-group the two light buttons into 1 unique button with 2 animations !

    In the catalogue group , I don't understand your events ... one is set to or block , try to tweak that ...

  • would it help if I were to upload the capx for you to see?

    I'm not sure of exactly how I would go about putting both states of my light switch into a single animation. I know that for my top menu buttons, they are not done this way and they have no problems working.

    I'll upload the capx for you, this will likely be the best way to figure out what is going on because to me, I think my code is problem free (a little bloated perhaps but I can't spot any errors I mean technically it should work)

    The error is happening in the Catalogue Event Sheet

    temp-share.com/show/KdPfm0yoh

    That is a link to my capx

  • Can't open the project , damn you , missing plugin message !

    Try to set the first event in the catalogue group to not "or" ...

    Whiteclaws , if that doesn't work ...

  • I've just got the scirra.com/FORUM/behavior-easetween_topic53288_page13.html

    plugin and the

    scirra.com/forum/behavior-moveto_topic44845.html

    Moveto plugin from this page.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tried to remove the OR but by getting rid of the or from that statement, it does not function how it needs to operate.

  • Fix'd it !

    Told you it was in the "or"

    <img src="http://dl.dropbox.com/u/89532891/Others/Fix.png" border="0" />

    Cheers !

  • please do tell me what the logic is behind why inverting this works but the way I had it would not as it makes no sense to me, both should technically work.

  • Actually I just tried to invert the or like shown in your example but it does not work.

    downlight_1 does not start visible like it should

    and changing the light switch does not change the state of the down light either :s

  • If anyone is able to help me with this please advise as I really need to try and have it working and as far as I can tell it's quickly becoming more of a bug than it is broken code as I can't see any logical reason why the light switch is not toggling downlight 1 off and on but only works when the layout first starts up.

  • 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.

    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.

  • 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.

  • 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.

  • 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:

    <img src="https://dl.dropbox.com/u/8367729/construct/pics/orPicking.png" border="0">

  • 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:

    <img src="https://dl.dropbox.com/u/8367729/construct/pics/orPicking.png" border="0" />

    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.

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