Problem with Repeating Code - UPDATED [may be bug]

0 favourites
From the Asset Store
Two levels with two sistem Wave. with 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="" border="0" />

  • Read the 3rd paragraph before reading this one


    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

    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

    plugin and the

    Moveto plugin from this page.

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

    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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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:

    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="" border="0">

  • It's working as intended actually according to this:

    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="" 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 1 visitors browsing this topic (0 users and 1 guests)