Howdy, Stranger!

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

displaying one set of text if male and a different set of text if female not working

edited December 2015 in Help! with 2.0
im sure there is an easier way to do this that works but as i just stared using twine today i do not know it but this is what i have so far


story start

is your character going to be male or female

female
(set:$gender to "female")
(set: $rivalGender to "male")
(set: $selectedfemale to "yes")
start of story

male
(set: $gender to "male")
(set: $rivalGender to "female")
(set: $selectedmale to "yes")
start of story

start of story
your gender $gender
your rivals gender $rivalGender

(if: $selectedmale eq "yes"
this is the text to display if pc is male

)
(if: $selectedfemale eq "yes"
this is the text to display if pc is female

)


the error msgs i get are :

☕ Unexpected identifier►
This error message was reported by your browser's Javascript engine. I don't understand it either, but it usually means that an expression was badly written.

☕ Unexpected identifier►
This error message was reported by your browser's Javascript engine. I don't understand it either, but it usually means that an expression was badly written.

Comments

  • note: If you want to include code/passage examples in your question/comment you should use the C button in the toolbar above the comment field, this will wrap the code example in a set of code tags which will make it more readable. A method you can use if you want to include the contents of multiple passage inside a single example is to use Twee notation (i.e. :: Passage Name) like my answer.

    You need to state which story format you are using, as answers can be different for each one. Based on your code example I will assume you are using Harlowe.

    1. Your code example has syntax errors in it, the (if:) macros are missing an end ) parenthesise and the associated hooks are missing both the start [ and end ] square brackets. The following should work:
    :: story start
    is your character going to be [[male]] or [[female]]
    
    :: female
    (set:$gender to "female")
    (set: $rivalGender to "male")
    (set: $selectedfemale to "yes")
    [[start of story]]
    
    :: male
    (set: $gender to "male")
    (set: $rivalGender to "female")
    (set: $selectedmale to "yes")
    [[start of story]]
    
    :: start of story
    your gender $gender
    your rivals gender $rivalGender
    
    (if: $selectedmale eq "yes")[
    this is the text to display if pc is male
    ]
    (if: $selectedfemale eq "yes")[
    this is the text to display if pc is female
    ]
    
    2. Because both $selectedmale and $selectedfemale can't equal "yes" at the same time you could replace both of the (if:) macros in the start of story passage with the following:
    (if: $selectedmale eq "yes")[
    this is the text to display if pc is male
    ]
    (else:)[
    this is the text to display if pc is female
    ]
    
  • thanks for that info greyelf i made those changes but am still getting 2 errors

    ☕ Unexpected identifier►
    This error message was reported by your browser's Javascript engine. I don't understand it either, but it usually means that an expression was badly written.
    
    this is the text to display if pc is male
    
    There's nothing before this to do (else:) with.►
    I tried to use a macro, but its call wasn't written correctly.
    
    this is the text to display if pc is female
    

    and yea im using harlow as it is set up as the default though i will eventually check out the other 2 formats after ive had some time learning how twine works
  • Try
    <<print $gender>>
    
    instead of
    $gender
    
    .

    Although if you are doing a lot of substitutions
    <<print "You are " + $gender + " and your foes are " + $rivalGender>>
    
    can save some typing.
  • edited December 2015
    MacGabhann wrote: »
    thanks for that info greyelf i made those changes but am still getting 2 errors
    Sorry, I forgot that Harlowe does not support the eq operator you were using, change it to the is operator instead.
    (if: $selectedmale is "yes")[
    this is the text to display if pc is male
    ]
    (else:)[
    this is the text to display if pc is female
    ]
    
    learning how twine works
    The Twine application is used to edit the Story Passage / Story Stylesheet / Story Javascript content, and to assemble the different passages together to create a story HTML file.

    Everything else is controlled/defined by the Story Format you choose to use, this includes the macro syntax, what core macros are available, the structure of the story HTML, the base look of the story and any other features the story format supports.
  • thank you greyelf changing the eq to is fixed it now i can get started on the rest of the char creation :)
Sign In or Register to comment.