Page 1 of 1

Help on simplifying conditional dialogue choice branches?

Posted: Thu Aug 27, 2020 12:51 am
by Ilysis
Wasn't really sure how to word the topic, but basically, my game is a short dating sim with five characters with a good number of different endings depending on what you do in each characters' paths and who you rank up with.
It also involves any of the candidates being made unavailable to interact with as a result of the player reacting badly to them.

In both instances, I have a problem... the "if-then" branch count is huge on both ends, making the script very cluttered and confusing.
I tried doing something like

Code: Select all

menu:
  if charRoute != -1:
    "Go with Char"
  
  if dharRoute != -1:
    "Go with Dhar"
but this just gives me an "ExpectedMenuItem" error.

Does anybody know if there is a way I can simplify this and how?
Thank you.

Re: Help on simplifying conditional dialogue choice branches?

Posted: Thu Aug 27, 2020 2:30 am
by namastaii
I would have one menu and put all the conditionals inside that menu

Re: Help on simplifying conditional dialogue choice branches?

Posted: Thu Aug 27, 2020 4:37 am
by HEXdidnt
Not sure I'm interpreting your variables right, but you can add your if statements to each menu item, such that it will only be displayed on screen if those conditions are met. Something like:

Code: Select all

menu:
	"Chizza" if croute >= 1:
		jump chizzaEnding
	"Macy" if froute >= 1:
		jump macyEnding
	"Mariel" if droute >= 1:
		jump marielEnding
	"Edna" if nroute >= 1:
		jump ednaEnding
	"Chizza and Macy" if croute >=1 and froute >=1:
		jump chizzaMacyEnding
	"Chizza and Mariel" if croute >=1 and droute >=1:
		jump chizzaMarielEnding
	"Chizza and Edna" if croute >=1 and nroute >=1:
		jump chizzaEdnaEnding
	"Macy and Mariel" if froute >=1 and droute >=1:
		jump macyMarielEnding
	"Macy and Edna" if froute >=1 and nroute >=1:
		jump macyEdnaEnding
	"Mariel and Edna" if droute >=1 and nroute >=1:
		jump marielEdnaEnding
It's still going to end up pretty long code-wise, depending on how many characters you have but, on the upside, as you list the pairings, there's one fewer each time, since the preceding characters have already dealt with some of the permutations.

I'm still wrapping my head around menus myself, but I think the 'unexpected menu item' is the if statement preceeding the menu item.

Re: Help on simplifying conditional dialogue choice branches?

Posted: Thu Aug 27, 2020 7:04 am
by philat
HEXdidnt is correct, but looking at your logic, I would say pulling the logic out into python entirely and generating the menu programmatically would also be beneficial.

Code: Select all

# logic goes here - do whatever needs to be done, return the list of possible options

$ returned_list = ["Chizza", "Macy", "Edna"] # is whatever you set it to from the logic above, here we assume it's ["Chizza", "Macy", "Edna"]
$ renpy.say(None, "Choose an ending", interact=False) # creates a caption for your menu
$ result = menu([(x, x) for x in returned_list], screen="choice") # this creates a menu that will return either "Chizza", "Macy", or "Edna"
jump expression result+"Ending" # this would jump to ChizzaEnding or MacyEnding or EdnaEnding / obviously you would need to name the labels in a manner where this is possible
You also don't need to necessarily feel like you need to use the in-built menu -- you could just as well create a separate screen with Jump() options based on the returned list. Of course, feel free to ignore if you're more comfortable using renpy script menus.

Re: Help on simplifying conditional dialogue choice branches?

Posted: Thu Aug 27, 2020 2:10 pm
by Ilysis
Ooh, these help a lot! Thank you guys very much!