Simplifying?

*if (Rosa > 50) and (Adam <= 50) and (Akoi <= 50)
*if (Adam > 50) and (Rosa <= 50) and (Akoi <= 50)
*if (Akoi > 50) and (Adam <= 50) and (Rosa <= 50)

*if (Rosa > 50) and (Adam > 50) and (Akoi <= 50)
*if (Akoi > 50) and (Adam > 50) and (Rosa <= 50)
*if (Akoi > 50) and (Rosa > 50) and (Akoi <= 50)

*if (Akoi > 50) and (Rosa > 50) and (Akoi > 50)

These are the possible combination of variables I have so far, and I’m probably going to add one more variable (which will be… a lot more code).

The text IN these is repeated (letters from each of the NPCs if the relationship is high enough).

I thought about using a *gosub but that just puts the same letters and repeat text (to my knowledge) in a different spot and doesn’t really fix the problem. There’s slight variations in the flavor text based on how many letters you get and from who, but they’re basically a paragraph at the start and at the end.

How can I simplify this? I’d like to reduce the amount of code necessary for this to work.

Multireplace? I don’t know if that’d help here.

Edit:

I also don’t know how multireplace works.

make a subroutine that accepts three parameters in,
call it like this: *gosub_scene logic_file compare_them “Rosa” “Adam” “Akoi”

so, for the cases below:
*if (Rosa > 50) and (Adam <= 50) and (Akoi <= 50)
*if (Adam > 50) and (Rosa <= 50) and (Akoi <= 50)
*if (Akoi > 50) and (Adam <= 50) and (Rosa <= 50)

you only need to switch parameters order,
*gosub_scene logic_file compare_them “Rosa” “Adam” “Akoi”
*gosub_scene logic_file compare_them “Adam” “Rosa” “Akoi”
*gosub_scene logic_file compare_them “Akoi” “Adam” “Rosa”

I tried this out and I think it’s not actually solving the problem – it’s making it so that you can swap out any name, but it’s not making the actual code logic any more efficient. I think Rascal wants to check which of the companions pass the relationship test and which don’t.

*gosub_scene best_girl waifu_competition "Rosa" "Adam" "Akoi"

best_girl.txt:

*label waifu_competition

*params waifu_1 waifu_2 waifu_3

*if (((waifu_1 > 50) and (waifu_2 <= 50)) and (waifu_3 <= 50))
*elseif (((waifu_1 > 50) and (waifu_2 > 50)) and (waifu_3 <= 50))
*elseif (((waifu_1 > 50) and (waifu_2 > 50)) and (waifu_3 <= 50))
*elseif (((waifu_1 > 50) and (waifu_2 > 50)) and (waifu_3 <= 50))
*else
  all the other cases, I'm not doing them all

*return

Here’s my solution instead:

*gosub_scene best_girl waifu_competition "Rosa"
*gosub_scene best_girl waifu_competition "Adam"
*gosub_scene best_girl waifu_competition "Akoi"

*if (rosa_letter)
  You received a letter from Rosa: "Thanks for last night ;)"

*if (adam_letter)
  You received a letter from Adam: "Thanks for last night ;)"

*if (akoi_letter)
  You received a letter from Akoi: "It was cool of you to let Rosa
  and Adam fuck your mom last night. When's she free next?"

In total you have received ${letter_number} letters.
*if (letter_number = 0)
  You're not popular enough to get any letters. Better let more of
  your friends fuck your mom.

*set rosa_letter false
*set adam_letter false
*set akoi_letter false
*set letter_number 0

best_girl.txt

*label waifu_competition

*params waifu

*if (("${waifu}") > 50)
  *set ("${waifu}_letter") true
  *set letter_number +1

*return

This also lets you add way more people as potential letter-senders later on.

Also, multireplace:

You @{rosa_letter received|did not receive} a letter from Rosa.

Adam @{adam_letter fucked your mom|had tea and went to bed} last night.

@{akoi_letter You got a letter from Akoi!|}

Your mother is @{mom_libido entertaining a side of herself she never thought possible|enjoying her newfound sexual awakening|living her best life}.

You received @{letter_number+1 zero|one|two|three} letters in total. @{letter_number=0 You're not popular enough to get any letters. Better let more of your friends fuck your mom.|}
4 Likes

Could you do something like this:

*label set_letter_eligibility
*if rosa > 50
	*set rosa_letter true
	*set letters_received +1
*if adam > 50
	*set adam_letter true
	*set letters_received +1
*if akoi > 50
	*set akoi_letter true
	*set letters_received +1
*label read_letters
*if ((rosa_letter) and ((adam_letter = false) and (akoi_letter = false)))
	*gosub rosa_letter
*if ((rosa_letter) and ((adam_letter) and (akoi_letter = false)))
	*gosub rosa_letter
	*gosub adam_letter
...etc
*label rosa_letter
You get a letter from Rosa.

*if letters_received > 1
	Then you get another letter!
*return
*label adam_letter
You get a letter from Adam.

Adam's letter always comes last in the order so there's no need for an optional "you get another letter here".
*return

Edited to add Will’s number-of-letters-tracking variable.

5 Likes

Thanks everyone. Apologies for the delay. I think I’m sick (exhausted maybe?). I’ve been sleeping 14 hours the past few days and haven’t gotten much done. I’ll try these solutions and see which one works best.

What is *params ? I don’t recognize this command

Edit:

The goal here is to simplify the code I have and reduce repeated text. I’m hoping to make my WiP run smooth when it’s complete and also make sure that it still displays everything it needs to.

As a related note, I’m interested in implementing one of these solutions, though I will have to understand how the code works before I do both so that I don’t need to ask this question again and also to ensure that I know how to fix it if something breaks.

1 Like

With “”_letter true…

Are these temp variables or would I need to create ‘proper’ variables since it’s using a gosub command?

Whichever works for you would be fine. If you make a *temp variable at the top of your scene file, it will be usable throughout the file as long as you’re not using *gosub_scene to go into a different file. *gosub is fine.

If you wanted to use the letter-tracking in another file, for example if you wanted Rosa to be able to say later in the game in a different file, “I sent you a letter but you didn’t even reply!” or something, you’d want to *create the variable in startup.

1 Like

Gotcha. I think I’ll have letters become a recurring thing since it just kind of makes sense to the WiP.

Could I use a gosub to reset the letters to 0 and after it returns it will display the text? Or would I have to do that in the main file after the gosub?

Edit:

Resetting for future use of the variable, I mean.

If you wanted to reset the letters, you’d want to reset them to 0 after all of them have been “read”, but I can’t quite visualise the different options described so probably best to try whichever way makes sense / feels neater to you, playtest it, and check that it works correctly.

1 Like

Got it.

Could you explain this? I don’t quite understand how multireplace would know which one to use nor what it’s based on. Do I need variables for it to read?

You @{rosa_letter received|did not receive} a letter from Rosa.

Adam @{adam_letter fucked your mom|had tea and went to bed} last night.

@{akoi_letter You got a letter from Akoi!|}

Your mother is @{mom_libido entertaining a side of herself she never thought possible|enjoying her newfound sexual awakening|living her best life}.

You received @{letter_number+1 zero|one|two|three} letters in total. @{letter_number=0 You're not popular enough to get any letters. Better let more of your friends fuck your mom.|}```

You may have already, but can I check whether you’ve read the multireplace documentation here?

The page includes a couple of examples to demonstrate:

  • Boolean example: @{variable Text if true|Text if false}
  • Numeric example: @{variable Text if 1|Text if 2|Text if 3|Text if 4}

Whenever you’re using multireplace or *if you need to use *create or *temp to tell ChoiceScript that the variable exists for it to check.

So if you are using multireplace to say You @{rosa_letter received|did not receive} a letter from Rosa you will have needed to use *create or *temp to declare that rosa_letter exists in the first place.

1 Like

I did. I just didn’t quite understand it. Thank you though. I think I understand it now.

Edit:

Would this work for something as large as a short paragraph? And could I use it to display no text at all if there were no letters?

Multireplace works for paragraphs if you don’t have line breaks, as long as you don’t have multireplace inside the multireplace. So you can’t do: @{rosa_letter You got a letter from Rosa! @{adam_letter And a letter from Adam!|} How lovely!|You got no letter from Rosa.} For me personally, if it becomes a long paragraph I find it more readable to use *if / *else but it’s whatever works for the individual.

If you were using the letter-tracking variable, you could do: @{(letters_received = 0) You didn't receive anything.|You did get something.} It depends on how you wants the text to read.

Regarding simplification - I suggest trying one thing at a time, so you’re not trying out several unfamiliar things at once. So, do the script that sets which person sends a letter, for example, use QuickTest and RandomTest to check for errors, then move onto the next thing. Doing a bunch of unfamiliar things at once is always going to be harder to grasp everything at the same time!

2 Likes

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.