Weird variable error


Hi all.

I keep getting a weird error and I don’t know why. It doesn’t particularly matter - I can work around it, but it’s the principle of the thing!

In my WIP, it’s possible for the player to have a pet. The details of this pet are recorded so I don’t have to type every aspect of the pet’s variations each time eg:

*set pet_gender “male”
*set pet_pronoun_him_her “him”
*set pet_pronoun_he_she “he”
*set pet_pronoun_his_hers “his”
*set pet_pronoun_selves “himself”

There’s a point where the player has a conversation where they reference the pet, but to make sure it still makes sense for players without a pet, I created a short check that subs in one of the player character’s friends’ names instead, assigning his name and characteristics for the duration of the conversation, and then another check later that returns the status of the pet to blank so it doesn’t throw up any weird stuff down the line.

All works fine, except in one place.

This line of the conversation:
"$!{pet_pronoun_he_she} ended up covered in cake mix," she finished lamely.

Prints as:
" ended up covered in cake mix," she finished lamely.

I thought it might be because there’s a page break (although that’s never caused problems anywhere else) so I added in another check that sets the details again after the break just to see. Same thing happens.

Then I thought maybe it’s because the !{pet_pronoun_he_she} comes directly after a quotation mark and that might be messing things up (although I'm sure I've done that elsewhere without problems), so I changed it to: "So then {pet_pronoun_he_she} ended up covered in cake mix," she finished lamely. And it just printed as:
“So then ended up covered in cake mix.“
The ${pet_pronoun_he_she} works absolutely everywhere else I’ve put it, so this has me tearing my hair out! I think I’m going to end up just changing it to
”… ended up covered in cake mix,” she finished lamely.
But I wanted to see if anyone knew what I was doing wrong first!

EDIT: Am retesting and now this variable seems to have stopped working everywhere. Not sure what the heck I’ve done!


Hmm not sure what you have done but I would reset like you had it, from my experience I would hazard a guess is your setting the var “” some how. To clarify can you post the code so we have a better idea.

Edit I would approach it a little different myself, there is no right or wrong but always better ways of doing it and I am sure it can be do better then my example but I like to set mine up once that way I do not worry about changing back and fort durning the game.

Would you like a male or female dog?
  *set pet_male true
  *gosub gender
  *goto next_step
  *set pet_female true
  *gosub gender
  *goto next_step
*label gender
*if (pet_male)
 What will you name your pet
 *input_text pet_name
 *set pet_gender "male"
*set pet_pronoun_him_her pet_name
 *set pet_pronoun_he_she "he"
 *set pet_pronoun_his_hers "his"
 *set pet_pronoun_selves "himself"
*if (pet_female)
 What will you name your pet
 *input_text pet_name
 *set pet_gender "female"
*set pet_pronoun_him_her pet_name
 *set pet_pronoun_he_she "she"
 *set pet_pronoun_his_hers "her"
 *set pet_pronoun_selves "herself"


Is name defined as “”?


Yep, will go back to an earlier version.

This is the bit where it sets everything:

It was working fine on that bit, displaying like this:

But then the next bit doesn’t work:

Which outputs as:


Sorry on a phone so not able to see it all clearly but I am sure that other will help you. It is often better to copy paste your code as many or on phones and is simpler to veiw as text then images.


When you created pet_pronoun_he_she in your startup file, I assume it’s:

*create pet_pronoun_he_she ""

If so, odds are good that what’s happening is you’re finding a path through the story where that ends up never getting *set as anything else, so stays a blank. (Or else, like Old Guard said, you might be setting it blank somewhere, but that seems less likely).

This is likely obvious to you already, but with the code you’ve posted, a story path that doesn’t have a blank “” pet name at small talk check will skip the pet pronoun *set there; and a pet named anything but “my friend, Dietmar” will skip it after *label visits.

Without seeing all your code it’s hard to pin down the exact point where it goes wrong… but I’d put good odds that when you run carefully through the code path, you’ll find that thanks to some condition or other you’re never actually setting the pronoun to be anything other than the “” it was created to be.

If that’s completely wrong, all I can offer is a more thorough diagnostic if you’re willing to share the actual scenes.


Yeah, I think you’re right - I’m going to go back to an earlier version & check, but all I can think is I’ve accidentally deleted a crucial line where it sets the variable, as I’m sure it was working previously. However, what I don’t get is how in the version I’ve posted where I’m forcing it to set to “he” after I know it’s already set to “my friend, Dietmar” it still comes up blank the next time pet_pronoun is used. (I just did that bit as an extra test - it wasn’t like that originally.)


Okay, so, I’ve narrowed it down to being an issue somehow related to the smPlugin. If I comment out the save stuff, everything works fine, but when I have it running, the saving works fine, but certain conditional choices and variables no longer appear correctly.

I’m guessing it’s either that I’ve inadvertantly downloaded an old version of the plugin (I had a good scroll about through this thread: Saving System Plugin, but couldn’t be sure.)

OR I’ve set up the plugin slightly wrong somehow, either in terms of the .sj stuff in index.html, or the position of the *sm_init command.

index.html (in my ‘web’ folder) looks like this:

While the *sm_init command is like this:

*title Writers Are Not Strangers
*author Notagoth
*comment testing save system, remove before submission to CS
*create career 5
*create positivity 5
*create family 5
*create dreams 5
*create billie 5
*create annie 5
*create rating 0
*create billie_present false
*create coffee false
*create billie_drinks false
*create billie_waiting false
*create myboxx1 false
*create hospital1 false
*create party1 false
*create writing1 false
*create video1 false
*create auntmaudeadvice false
*create alix 5
*comment myboxx1, hospital1 and party1 all determine whether or not these sections have already been visited. Will set to
*comment true once visited to prevent circular paths forming.
*create relative “”
*create relative_gender_him_her “”
*create relative_gender_he_she “”
*create relative_gender_his_hers “”
*create pet_type “”
*create pet_gender “”
*create pet_pronoun_him_her “”
*create pet_pronoun_he_she “”
*create pet_pronoun_his_hers “”
*create pet_pronoun_selves “”
*create petname “”
*create pettreat “”
*create shortstorytype “”
*create anniescarf false
*create videotype “”
*create rock false
*sm_init mygame | 2

Any ideas?


Aha. Then I will be useless. :slight_smile: I only speak vanilla ChoiceScript, and neither use nor understand smPlugin.


Ah well, thank you anyway!


Hi there, I’m the author of smPlugin. Sorry to hear you’re having trouble with it. To implement the necessary behaviour the plugin does have to overwrite some core CS stuff, so it is plausible that it’s causing issues here, particularly if certain elements of cs have been updated recently.

Do you think you could pm me a link to download a .zip of your mygame folder? I’d be happy to look into this for you :slight_smile:


Thank you so much, that’s very kind! Will send the link shortly. (It’s most likely me doing something stupid. I’m new to all this stuff!)