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

Get help using Construct 2

Post » Sun Oct 01, 2017 9:30 pm

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
B
12
S
2
G
1
Posts: 47
Reputation: 781

Post » Mon Oct 02, 2017 1:12 am

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.
Code: Select all
Mouse On clicked on TextChoicesFamily
Rubix is visible
Text is not visible
TextChoicesFamily is clickable
   TextChoicesFamily text is "Sure..."
   or
   TextChoicesFamily text is "Uhm..."


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

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
66
Posts: 1,010
Reputation: 36,081

Post » Mon Oct 02, 2017 1:19 am

dop2000 wrote: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.
Code: Select all
Mouse On clicked on TextChoicesFamily
Rubix is visible
Text is not visible
TextChoicesFamily is clickable
   TextChoicesFamily text is "Sure..."
   or
   TextChoicesFamily text is "Uhm..."


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.
B
12
S
2
G
1
Posts: 47
Reputation: 781

Post » Mon Oct 02, 2017 4:10 am

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):
zelda-dialogue-system-capx-and-demo-included_t182559
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
66
Posts: 1,010
Reputation: 36,081


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Maako and 5 guests