Hello, could someone explain how find:replace functions work in Snowman 1.3 I'd like to use it as means to assign a player's gender. The current code I'm working with looks something like this, and it doesn't make the writing process any easier.
I wish <% if (s.player_sex == "female") { %>she<% } %><% if (s.player_sex == "male") { %>he<% } %> was still here.
Comments
For example, a `he()` function: (goes in Story JavaScript)
Usage:
How might I let the player choose the pronoun assignment if I were to use a popup window? I might also need to prevent progress until one is selected, or find a way to code a default pronoun like 'they' or 'theirs' if nothing is chosen.
And is this the correct way of adding additional pronouns to that list?
Usage:
Usage:
Using a popup complicates things. Is there a good reason for wanting to use a popup?
The former should be easy, if you use a passage rather than a popup.
The latter is also easy, in theory, just add a default case to the switch and remove the error—I say in theory, because, as shown below, pronouns may vary depending on context, so you have to give it a little forethought. I can provide examples if necessary.
Here's a version which makes the function declarations part of the initial window.gender object literal, rather than adding them to the object afterwards—which might make it a bit easier to wrap your head around. It also improves the error message and addresses an issue in your his() function when combining it with a noun—specifically, when to use "her" versus "hers". You may find it more palatable to use separate functions to handle the "her"/"hers" distinction, rather than using a parameter—e.g. gender.his() & gender.hisWithObject() versus gender.his() & gender.his(true). Either way, it's something you're going to have to keep an eye out for while writing.
Usage:
How would I implement buttons that use an existing style-sheet?
I'm comfortable with using a passage instead. And I'd really appreciate some examples. Most of that went over my head.
Alright, if I need to add any more options, I'll work with that example.
Great, that clarifies it a bit. Thank you for taking the time to code that.
Here's gender.his(), from the all-in-one object literal example, rewritten to return neutral pronouns when player_sex is either undefined or any value other than 'male'/'female', rather than throwing an error: Usage, with varying values for player_sex:
I've found a tiny grammatical error, but I think I know how to correct it. I'm just gonna run it by you to see if you've got an alternative solution, this one is a bit clunky. So, when they, them, theirs is the variable used for sex, sentences that use 'he' and 'she' no longer work with 'they' because of its default plurality.
e.g. The sentence "I wish he/she was still here." becomes "I wish they was still here". Was needs to be replaced with were. So it's now written. "I wish <%= gender.he() %> <%= gender.was() %> still here."
Here's my JavaScript with this new variable implemented.
As long as you allow players to choose not to choose a gender, then you're going to have this issue.
TIP: Assuming you'll be typing these in a lot, you might want to consider shortening the namespace object's name a bit—just don't clobber a built-in. For example: