*if statements within choices and what to do with them

So, I set up a choice, where 1 of the stats that can be changed depends on what the stat is currently. Here is my code, actually coppied this time, notjust freehanded:

*choice
	# Well? I say, deciding that the Detective is being troothfull.
		*set optimistic %+10
		*set genuin %+10
		*set D_relationship %+3
	*if logical >60
		*set logical %+10
		*goto D_conversation truthfull
	*elseif emotional >60
		*set emotional %+10
		*goto D_conversation truthfull
*label D_conversation truthfull
"Well, I say. It's blood, now.

So, yeah. Also, how to turn on, think it was "Implisit control, something? Might play around with that, just cause getting tired of having to put a GOTO after every single *if statement, and makeing me mmore reluctant to put in *if statements, even though I, if I am correct, think that they can be very, very, very useful in little nudges depending on your choices.

In your code, this entire part needs to have one more indent

	*if logical >60
		*set logical %+10
		*goto D_conversation truthfull
	*elseif emotional >60
		*set emotional %+10
		*goto D_conversation truthfull

Also the label D_conversation truthfull won’t work because there’s a space between conversation and truthfull.

To turn on implicit control flow, you have to put

*create implicit_control_flow true

in startup.txt

1 Like

Also you don’t really need icf in this case, just restructuring.

*choice
	# Well? I say, deciding that the Detective is being troothfull.
	   *if logical >60
		*set logical %+10
		*goto D_conversation truthfull
	   *elseif emotional >60
		*set emotional %+10
		*goto D_conversation truthfull
           *else
		*set optimistic %+10
		*set genuin %+10
		*set D_relationship %+3
		*goto D_conversation truthfull
*label D_conversation truthfull
"Well, I say. It's blood, now.

However, in cases such as this you can do the following:

*choice
	# Well? I say, deciding that the Detective is being troothfull.
	   *if logical >60
		*set logical %+10
	   *if emotional >60
		*set emotional %+10
           *if ((emotional <60) and (logical <60))
		*set optimistic %+10
		*set genuin %+10
		*set D_relationship %+3
           "Well, I say. It's blood, now.
           *goto x

I’d need more of the code to see if this would work.

ICF isn’t a miracle cure as some make it out to be. all it does is remove the ‘need’ for a *goto in if/elseif/else trees. If you structure your code ‘wrong’ it will only go to the wrong things.

1 Like

I… think you have a problem with the indents in the emotional part of the sample code, MeltingPenguins (what’s the point in checking if a value is under 60 in a block where you’ve already established it’s over 60?)

i’m just going by the OP’s code.

There is no *else in your code now, so such structure 1) will give errors during test or play; 2) doesn’t account for a character who is both unemotional and illogical. Also, indentation is incorrect. Depending on how you want to deal with unemotional and illogical PC, I suggest either something like this:

*choice
	# Well? I say, deciding that the Detective is being truthful.
		*set optimistic %+10
		*set genuin %+10
		*set D_relationship %+3
		*if logical >60
			*set logical %+10
			*goto D_conversation_truthfull
		*elseif emotional >60
			*set emotional %+10
			*goto D_conversation_truthfull
		*else
			*set logical %+5
			*set emotional %+5
			*goto D_conversation_truthfull
			*label D_conversation_truthfull
			"Well, I say. It's blood, now. More text.
			*goto end_conversation
	#I decide the Detective is deceiving me.
		*set optimistic %-10
		*set genuin %-10
		*set D_relationship %-3
		Text for lying.
		*goto end_conversation
*label end_conversation

or this:

*choice
	# Well? I say, deciding that the Detective is being truthful.
		*set optimistic %+10
		*set genuin %+10
		*set D_relationship %+3
		*if logical >60
			*set logical %+10
		*if emotional >60
			*set emotional %+10
		"Well, I say. It's blood, now. More text.
		*goto end_conversation
	#I decide the Detective is deceiving me.
		*set optimistic %-10
		*set genuin %-10
		*set D_relationship %-3
		Text for lying.
		*goto end_conversation
*label end_conversation

The 2nd option is simpler, but ignores a main character with both logical and emotional under 60 entirely.

I also noticed something about the content of this option. It seems to me the player decides if the Detective is lying or not, but the main character’s motivation for such a decision in handled in the code, not by the player. So, if the main character was mostly relying on emotions, the game just assumes that’s the case here, regardless of what the player thinks. Did I understand correctly?

  1. Don’t care if there’s an indent error that happened upon copypasting the code from a different post, and neither should you.

  2. Lovely how no one points out the mistakes I actually made while working with the OPs code.

I thought about that. I remember my difficulties with formatting the code in a comment. What’s why I copy the code into ChoiceScript IDE, format there, copy to my comment and then hit Preformatted text. We should show the correct version when we are giving an advice, shouldn’t we?

Yeah, true. but to be fair, it is tricky trying to offer alternative formats of code without the full quote, so good advice is hard here.

1 Like

Yeah, sort of. In this case, what I tried to do is make it so if the player is mostley logical, also I set up logical and emotional as an aposed_pair, to make things easier, the current MC logicly figures that the Detective is being truthfull. If emotional over 60, MC uses emotion to figure out the detective is being truthfull. Either way, in option 1, the player decides that the Detective is being truthfull with them.
So, if logical is higher, logical goes is raised in the code. If emotional is higher, emotional is raised in the code. That’s how I tried to set it up, anyway. Player still has a choice if they actually believe the Detective, with option 1 and 2.
I hope that helps some.

Also, on the subject of indentation.
When multaple lines of text in a *if statement. I assume you keep it all on the same level? So, if you have 2 tabs on the first line of text, you keep it all at 2 tabs till you reach an Elce/Elceiff/ goto statement? Goto still is indented 2 tabs, I do know that.

Then you don’t need 2 variables. If you want Logical/Emotional show up as opposed pair in stats, you should only create one variable:
*create logical 50
Then set up this code for your stats:

*stat_chart
    opposed_pair Logical
        Emotional

So, adding points to Logical would automatically subtract the same amount from Emotional. If you want to raise Emotional, subtract from Logical instead of using another variable. For more information, read this.
That means your code for the choice option you provided should have this general structure:

*choice
	# Well? I say, deciding that the Detective is being truthful.
		*set optimistic %+10
		*set genuin %+10
		*set D_relationship %+3
		*if logical >60
			*set logical %+10
		*if logical <= 40
			*set logical %-10
		"Well, I say. It's blood, now. More text.
		*goto end_conversation

Notice how emotional > 60 turned into logical <= 40. There is no condition for an unemotional and illogical character because such a character cannot exist if you set up variables like this.
However, if a character made a mix of logical and emotional decisions and now has Logical between 40 and 60, the game cannot decide their motivation!
There are more problems with this choice. Usually, players 1) don’t like their character’s motivation decided for them, 2) want to know how an option will affect their stats when they choose it. Imagine a hypothetical player who started playing as emotional character and decided to make more logical decisions later. They think about the text you presented them, logically decide the Detective is telling the truth, choose the option… Only to realise later their Emotional meter raised for no apparent reason! They are now stuck on the path of making emotional decisions.
To avoid such a scenario, I suggest making separate options for different motivations, like this:

"It's blood," the Detective says.
*choice
	#My logical conclusion is the same as the Detective's.
		*set optimistic %+10
		*set genuin %+10
		*set D_relationship %+3
		*set logical %+10
		*goto D_conversation_truthfull
	#My gut feeling is telling me the Detective is truthful.
		*set optimistic %+10
		*set genuin %+10
		*set D_relationship %+3
		*set logical %-10
		*label D_conversation_truthfull
		"Well, I say. It's blood, now. More text.
		*goto end_conversation
	#According to my calculations, that cannot be blood. The Detective is lying.
		*set optimistic %-10
		*set genuin %-10
		*set D_relationship %-3
		*set logical %+10
		"Something doesn't add up, Detective. Are you honest with me?"
		*goto end_conversation
	#This bastard cop is bullshitting me, and I should tell that!
		*set optimistic %-10
		*set genuin %-10
		*set D_relationship %-3
		*set logical %-10
		"That is not blood! Stop deceiving me!"
		*goto end_conversation
*label end_conversation

Or something more suitable for your game.

Yes. For more information, read this.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.