My *ifs are not behaving as one might expect

I am having trouble.

There are no codes or error popping up and nothing here is game crashing for the scenes referenced.
However. The scenes being displayed as a single gender with no regard to the if statements.


*if ((sexual_orientation_preference= "male") and (romantic_orientation_preference= "male"))
    *gosub mlf_scene
*if ((sexual_orientation_preference= "femle") and (romantic_orientation_preference= "female"))
    *gosub flf_scene
*if ((romantic_orientation_preference= "female") and (sexual_orientation_preference= "none"))
    *gosub frf_scene
*if ((romantic_orientation_preference= "male")  and (sexual_orientation_preference= "none"))
    *gosub mrf_scene
*if ((sexual_orientation_preference= "male and female") and (sexual_orientation_preference= "male and female"))
    *gosub mlf_scene
*if ((sexual_orientation_preference= "none") and (sexual_orientation_preference= "none"))
    *gosub frf_scene

mlf/flf is reference to romantic/implied sexual flashback (male/female lover flashback)
mrf/mrf is reference to romantic flashbacks. (male/female romantic flashback)
The scenes are labeled further in the same .txt. file

The scenes will continue but only in referencing this flashbacks past person as a female.

Each scene I just copied and pasted and created a *set list of commands to control the gender. As well as a list of commands for each scene in the startup.
(example from one scene
*set Abbey +70
*set mrf_name “Abbey”
*set mrf_malefemale “male”
*set mrf_heshe “he”
*set mrf_hisher “his”
*set mrf_himher “him”
*set mrf_boygirl “boy”
*set mrf_handsomebeautiful “handsome”
*create mrf_name “unknown”
*create mrf_malefemale “unknwn”
*create mrf_heshe “unknown”
*create mrf_hisher “unknown”
*create mrf_himher “unknown”
*create mrf_boygirl “unknown”
*create mrf_handsomebeautiful “unknown”)

Also, I tried to *set :arrow_up: this list within the *if statement (in many different attempts) but I could not make the program happy.

The game continues just fine except for this.
What is wrong?? :sweat: :disappointed:

(PS I filled in the option of men+women and none label with one of the scenes because I can’t figure out *rand coding just yet.)

The last two if statements check the same condition “sexual_orientation_preference”.

Other than that, I don’t know what could be an issue.

1 Like

All *create commands (or *temp commands) should be before anything else in the scene.

If you have
*set mrf_name “Abbey”

followed by

*create mrf_name “unknown”

That, I believe, eradicates what you just *set.

4 Likes

That was a copy paste from the startup, just to show I *creat(ed) the commands I am trying to set.
The actual sets are at later scenes.

I will try changing the terms and see how that goes. I honestly did not even think of that. Thank you!

A bit of protip: it’s probably a good idea to write the code so the terms tested are aligned in a column. You have [sexual] and [romantic] preferences mixed as a column, which can make the debug process a tad confusing.

3 Likes

:sweat: :sweat: :sweat:
I don’t mean to be a bother. That spasm of coding I erased. Rather I just copy/pasted pertinent text with pronoun changes for sexual_orientation_preference, and romantic_orientation_preference into whole new scenes and moving forward.
Now, *if is still a problem.
I spent a handful of hours reworking and changing things and trying to simplify. I have only a few characters I would like to alternate gender based on preference and I try to revolve it around *if statements, but I cannot seem to get it right.
There are no errors cs-ide is showing me, and the game continues on, but only with gender pronouns of A being male.
I have completely redone a lot of coding thinking it would work, however, my code causing issues is now.

*if (sexual_orientation_preference= "male")
    *gosub A_2
        
*if (sexual_orientation_preference= "female")
    *gosub A_1
        
*if (sexual_orientation_preference= "men and women")
    *gosub A_2
        
*if (sexual_orientation_preference= "none")
    *gosub A_1
        

*label A_2
*set A_gender "male"
*set A_heshe "he"
*set A_hisher "his"
*set A_himher "him"
*set A_boygirl "boy"
*gosub continue

*label A_1
*set A_gender "female"
*set A_heshe "she"
*set A_hisher "her"
*set A_himher "her"
*set A_boygirl "girl"
*gosub continue

*label continue
blah blah text stuff

Whenever a gosub is called, there needs to be a return command. What you did there is putting gosub two times. Instead, try using a return command.

*if (sexual_orientation_preference= "male")
    *gosub A_2
        
*if (sexual_orientation_preference= "female")
    *gosub A_1
        
*if (sexual_orientation_preference= "men and women")
    *gosub A_2
        
*if (sexual_orientation_preference= "none")
    *gosub A_1

*label continue
Blah blah

.
.
.
*finish

*label A_2
*set A_gender "male"
*set A_heshe "he"
*set A_hisher "his"
*set A_himher "him"
*set A_boygirl "boy"
*return

*label A_1
*set A_gender "female"
*set A_heshe "she"
*set A_hisher "her"
*set A_himher "her"
*set A_boygirl "girl"
*return

It’s totally fine, you’re not :upside_down_face:

2 Likes

Thank you!
You’re so nice! :grin:
I shall give that a try!

1 Like

The “femle” in the above snippet is a misspelling and will cause you grief down the line. Trust me. :slight_smile:

5 Likes

My first assumption is that your problems are due to flow through the code because you are using *gosub instead of *goto - *gosub inside of *gosub is like a coding nightmare :sweat:

Why not just do this:

*if (sexual_orientation_preference= "male")
    *comment A_2
    *set A_gender "male"
    *set A_heshe "he"
    *set A_hisher "his"
    *set A_himher "him"
    *set A_boygirl "boy"
    *goto continue
        
*elseif (sexual_orientation_preference= "female")
    *comment A_1
    *set A_gender "female"
    *set A_heshe "she"
    *set A_hisher "her"
    *set A_himher "her"
    *set A_boygirl "girl"
    *goto continue
        
*elseif (sexual_orientation_preference= "men and women")
    *comment A_2
    *set A_gender "male"
    *set A_heshe "he"
    *set A_hisher "his"
    *set A_himher "him"
    *set A_boygirl "boy"
    *goto continue
        
*else
    *comment A_1
    *set A_gender "female"
    *set A_heshe "she"
    *set A_hisher "her"
    *set A_himher "her"
    *set A_boygirl "girl"
    *goto continue
        
*label continue
blah blah text stuff
2 Likes

here’s a standard use of the rand command to randomise which scene you see

*create dice_roll 0
*rand dice_roll 1 3
*page_break
*if dice_roll = 1
    *set [variable] "something"
    text 1
    *goto scene_continues
*elseif dice_roll = 2
    *set [variable] "something"
    text 2
    *goto scene_continues
*else
    *set [variable] "something"
    text 3
    *goto scene_continues

*label scene_continues
*page_break
Text onwards....

and here’s one just to randomize a variable

*create important_variable
*create dice_roll
*rand dice_roll 1 100
*set important_variable dice_roll
4 Likes

Thank you so much! When I get off work I will give this a go! :grin: :grinning:
I appreciate your assitance!

This seems easier than my attempt!
I will also give this an attempt when I get off work today! I appreciate your assistance, thank you! :grin:

i do see these issues crop up repeatedly with people just starting out, but once you get the hang of how the choicescript engine handles the code you will find that it is like the easiest programming language ever.

personally i never use *gosub, if I have a subroutine which will be repeatedly accessed i would always put it in a separate scene file and use *gosub_scene to go to it and then return to whichever “chapter” scene i am calling it from. And if you simply have a one use piece of code i would leave it in one of your main “chapter” scene files “in text” so to speak, like my first example above. Calling subroutines which are stashed somewhere in a chapter scene file just seems to be a recipe for confusion imo

2 Likes

I am having issues with this format.
Rather that alternating the genders with *set commands it continues only with my filler word on the startup text. rather than the proper pronouns of he/she/his/her/etc it is only unknown.

I am having issues with this format.
Rather than having alternate gender pronouns being uses, he/she/his/her/etc it only displays female pronouns.

*if ((sexual_orientation_preference= "male") or (sexual_orientation_preference= "men and women"))
    *set A_gender "male"
    *set A_heshe "he"
    *set A_hisher "his"
    *set A_himher "him"
    *set A_boygirl "boy"
    *gosub continue
        
*else
    *set A_gender "female"
    *set A_heshe "she"
    *set A_hisher "her"
    *set A_himher "her"
    *set A_boygirl "girl"
    *gosub continue

I tried a direct copy/paste after inputting the code in myself, and it repeats the female pronouns.
I redid the scenes around this section. It is in a stand-along scene (abut mid-way) and continues into a choice that leads into a new scene. But the issues repeats.
This is the only section I am having issues with now. The other *if statements I’ve gotten down and understood how to interact/code to have them display properly without looping.
Should I just attempt a *rand for this character with your previous response coding?

(PS your statement about *gosub’s versus *goto’s helped a lot :grin: :grin:)

I think you don’t have the ‘continue’ as a subroutine but instead a label, so double check if it should be goto instead of gosub.

And just to make sure again, this is not the MC right, the person A I mean?

i cant really answer any of these questions because i dont really know what it is that you want to do; i simply took your code and reformatted it to make it run as it appeared to be intended to run.

if you were to break down what you want the code to do then maybe i could help

The code looks correct, so that suggests there’s something wrong with the condition — ((sexual_orientation_preference= "male") or (sexual_orientation_preference= "men and women")) is not true when the program hits that line of code.

Have you modified the code that sets sexual_orientation_preference since you last posted? Because there

*choice
	#A man I once knew.
		*set sexual_orientation_preference "men"
		*set romantic_orientation_preference "men"
		*goto_scene scene3_chapter1

you’re using men and women instead of male and female. If you haven’t changed this bit of code, this is probably your problem.

As an aside, is there any particular reason you’re using sexual_orientation_preference to set A’s gender, rather than romantic_orientation_preference? A character who is romantically but not sexually attracted to men might want to romance male A, but the game will always give them female A.