0 Favourites

How do I make groups of conditions lead to the same result?

  • Hi everyone, so basically I'm trying to find an easier way to do this than just making a unique function to call every single time.

    I basically have 2 groups of conditions I want to do the same set of actions, so as an example: (click object 1 + sprite visible) and (click object 2 + sprite visible) both lead to (object 3 visible). The only way I can think is to make it so when Function "X" is called, object 3 becomes visible, and then put call Function X as the only action for both sets of conditions. But I am doing this on a huge scale, so as opposed to making an entirely new function every time, is there an easier way to do this?

    I mean, right now, I'm just copying and pasting the same thing twice for both, because it feels less messy than having a thousand functions, somehow:

    https://imgur.com/9wwpEOM

    Many thanks in return!

    Josh

  • There are lots of ways to optimize your code.

    You can add TextChoice1 and TextChoice2 to a family and bam - you already can combine those 2 conditions into one.

    Mouse On clicked on TextChoicesFamily
    Rubix is visible
    Text is not visible
    TextChoicesFamily is clickable
       TextChoicesFamily text is "Sure..."
       or 
       TextChoicesFamily text is "Uhm..."
    [/code:2fsunr36]
    
    I'm sure you it's possible to compress all this even further with functions, but I need more examples of your code.
    Could you share the capx?
    
    Also, you might want to check the FAQ on this forum - there are a few good examples of how to build a dialogue system in games.
  • There are lots of ways to optimize your code.

    You can add TextChoice1 and TextChoice2 to a family and bam - you already can combine those 2 conditions into one.

    > Mouse On clicked on TextChoicesFamily
    Rubix is visible
    Text is not visible
    TextChoicesFamily is clickable
       TextChoicesFamily text is "Sure..."
       or 
       TextChoicesFamily text is "Uhm..."
    [/code:2ho3ykzk]
    
    I'm sure you it's possible to compress all this even further with functions, but I need more examples of your code.
    Could you share the capx?
    
    Also, you might want to check the FAQ on this forum - there are a few good examples of how to build a dialogue system in games.
    

    Hi there, thanks for responding. My problem is basically I don't want to be making hundreds of families for each dialogue branch. And I have actually looked at (and bought a plugin) for dialogue choices but, my coding knowledge is super limited, and this works best for me right now unfortunately Can't seem to find any simple enough for me.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • You don't need hundreds of families because you should not have a separate text objects for every dialog line in your game. This approach is definitely wrong.

    You need a more universal system.

    All text (dialog lines and possible dialog answers) should be in some kind of data storage - XML or CSV or something similar.

    Then create a few functions that will build your dialog interface, handle responses etc.

    See this post for an example (there is a working link to CAPX at the bottom of the page):

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