How to add compound CONDITIONS

0 favourites
  • 8 posts
From the Asset Store
Customize the animation of character when item changed
  • I have some OR block code. but when I use the mouse I have to pick which object I clicked so I need to add ANDs but you can't mix AND and ORs

    so I did it with 2 different events, but its not working. how is this done without repeating the code for a mouse specific event?

    dropbox.com/s/zq5lp8zpl91cuuv/mouseCapClick.c3p

  • Here's a different issue, but its the same problem...as my game starts to get closer to being finished, adding lots of options for different controls and I start programming more complex AI I've been running into this issue a lot. How to add an OR to a string of ANDs? I know it can't be done, but shy of duplicating code what are the expert Construct users doing?

    like here, how do I add an OR to this? or rather how do I work around this? if I create a subevent then it won't bounce out to the else. (I have a few else's with the final else being an error sound)

  • Here's a different issue, but its the same problem...as my game starts to get closer to being finished, adding lots of options for different controls and I start programming more complex AI I've been running into this issue a lot. How to add an OR to a string of ANDs? I know it can't be done, but shy of duplicating code what are the expert Construct users doing?

    like here, how do I add an OR to this? or rather how do I work around this? if I create a subevent then it won't bounce out to the else. (I have a few else's with the final else being an error sound)

    You could combine them into one condition using System > Evaluate expression - 'grid_piece.in_range_player <> grid_piece.hasLRRD'.

  • birdboy o_O

    that works! thanks!

    but I can't do that with the first mouse-click-object issue. unless I can do picking with expressions somwhow?

  • Oh, my proposal wasn't even the correct one. Use System > Pick by evaluate instead. Taking a look at the first problem right now.

    Is there a specific reason why you aren't using a function instead of a boolean? Like this:

    I have no clue what I'm talking about to be honest but I think the reason why your solution doesn't work is because the boolean is set in a trigger event. They are handled individually, so the boolean is set back to false directly after.

  • I have some OR block code. but when I use the mouse I have to pick which object I clicked so I need to add ANDs but you can't mix AND and ORs

    so I did it with 2 different events, but its not working. how is this done without repeating the code for a mouse specific event?

    https://www.dropbox.com/s/zq5lp8zpl91cuuv/mouseCapClick.c3p?dl=0

    The issue is that you are using a local Variable which it will reset the value on the next Top event

    Example:

    -On Event 2: >>>>> Left Mouse click set the mouseclicked to = True

    -On the Next Top Event which is "Event 3" it will reset the mouseclicked to = False because that is the default state

    -So by the time it checks "OR Is MouseClicked" the state of the local var mouseclicked is = False

    The easy fix will be to drag the local variable outside the group to make it global so it retains the state once you change it

    or

    Save it in a dictionary

    or

    Just add an object in the layout just for instance variables so you can use it as global variables by making it global you will be able to use it in any layout.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh, my proposal wasn't even the correct one. Use System > Pick by evaluate instead.

    birdboy yeah I figured out what you meant, thanks!

    in the first problem I don't use a function just because it doesn't feel like it needs one. the only reason would be to allow different controls.

    tarek2 wow that is not very intuitive, I thought the variable would reset to false at the top of each sheet. so this means I have to turn it back to false in the event - which is fine.

    but now I am worried about using the mouseclick bool many other places and in #includes etc.. so I am worried about the order. I can't really see it in my head right now, but maybe it works out? is this the standard way to add mouseclicks/keyboard keys/gamepad buttons to the same condition?

  • wow that is not very intuitive, I thought the variable would reset to false at the top of each sheet. so this means I have to turn it back to false in the event - which is fine.

    They are very useful once you get used to it, the local variables think of it as a temporary variable that you will use and modify on that same tick in that scope for temporary calculations and values that once you leave that scope you will not need them anymore and it resets it to default for you.

    but now I am worried about using the mouseclick bool many other places and in #includes etc.. so I am worried about the order. I can't really see it in my head right now, but maybe it works out?

    Not sure which problem you referring to with the order but if you want to access the Boolean in any event sheet just set it as Global as it should work exactly the same but it will retain the values.

    is this the standard way to add mouseclicks/keyboard keys/gamepad buttons to the same condition?

    For me, I will recommend you not to worry about the standers and choose the way that is much easier for you because is more important that when you look at your code you recognize what each event does as quickest as possible other ways you will waste hours looking at your events just to find out what they do or how they work. So choose the way or method that is more comfortable for you for readability as you dealing with mostly triggers so is not gonna hurt your performance doesn't matter which way you do it.

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