Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Male or Female Back-and-Forth

Hello all, I'm brand new to Twine and would like to start the story off with the ability to choose whether you want to be a male or a female. The problem with this is that I don't know if you can have a passage somehow "learn" your choice and go back and forth between "he" and "she" respectively. Is this possible or do I have to write two seperate passages completely to fit either choice?

Comments

  • You need to state which story format you are using, as answers can be different for each one. I am going to assume you are using Harlowe!

    You can use a $variable to track which gender the character is and display different text based on the value of that $variable.

    Your story should have a passage in which you initialize (give default values to) your $variables, in Harlowe this passage is the one you have tagged as startup. If you don't have such a passage yet then do the following:
    a. Create a new passage, its name is not important but I call mine Startup.
    b. Assign a startup tag to this new passage.

    In your startup tagged passage place the following code:
    (note: the following starts the character off as male, if you want them to start off as female just change the "male" part of the code to "female")
    (set: $gender to "male")
    
    You now have a variable named $gender which can be used to decide what text to display. You could use code like the following in any of your story's passage to do so:
    (if: $gender is "male")[
    The text you want to show the male.
    ]
    (else:)[
    The text you want to show the female.
    ]
    
    When you want to change the character from male to female you would use the following code within one of your passages and they would be female from that passage onwards:
    (set: $gender to "female")
    
  • Hi!

    Greyelf's answer is absolutely correct, of course.

    I am only going to add, in case your language isn't like English and you actually have gendered words (I am Italian, we do have gendered words, so a guy, for example, would be bello, while a girl would be bella), you don't have to rewrite an entire paragraph twice.

    You can write the last bit of a gendered word as a variable - for example, in my case, it could be "bell$x" and set $x to be either "a", or "o" (or whatever works in your language), depending on the gender chosen by a user.

    Let me know if you need more info on this, though I am sure whatever I have done, Greyelf will have a much more elegant solution. :)

  • Melyanna wrote: »
    Greyelf will have a much more elegant solution...
    Thank you for the complement, but you came up with a solution to a potential problem I had not even thought about! lol
    I will blame my lack of ability to speak any language besides English (or a regional version of it). :)
  • greyelf wrote: »
    Melyanna wrote: »
    Greyelf will have a much more elegant solution...
    Thank you for the complement, but you came up with a solution to a potential problem I had not even thought about! lol
    I will blame my lack of ability to speak any language besides English (or a regional version of it). :)

    Ahah! :)
    Well, in my case, it's basically the first issue I encountered when writing a story in Italian in which users could select their own character - the joys of speaking an old and dusty language, LOL.

    On the other hand, since I am a bit of a Twine newbie, I am still kind of trying out different attempts (not all successful) to find workarounds for things like this.

Sign In or Register to comment.