Invalid @{} variable substitution at letter 1

I’m having trouble figuring this problem out.

I made sure the variable “romancecaivral” was created, and there is a path where it is *set true, so I’m stumped on what is invalid.

Here’s what the code looks like

@{romancecaivral He winks at you as he shakes your hand and then joins the others in leaving the castle.|He shakes your hand and then joins the
other in leaving the castle.}
1 Like

put the closing brace after the variable, not the end of the sentence.

Oh wow, I fee dumb, because I know what’s how you’re supposed to do that.

Thank you!

@LordOfLA Now it’s saying there should be a space after the first word?

Any idea what that means

You do have it as follows right?

@{romancecaivral} He winks at you as he shakes your hand and then joins the others in leaving the castle.|He shakes your hand and then joins the
other in leaving the castle.

Although looking at that, I don’t think that’s going to work how you want it to. You’d have to refer to CS reference documentation on conditional stuff. I’ve not learned CS coding but where things line up with other coding I do I can point things out or spot where things might not work as expected but I’d need to try my hand with CS coding to get down to specifics.

@LordOfLA Yes, now I do
But now it’s giving me error: invalid @{} at letter 1;there should be a space after the first word

Here’s some documentation that seems relevant: https://choicescriptdev.fandom.com/wiki/Multireplace

Going by that it seems you want:

@{romancecaivral “He winks at you as he shakes your hand and then joins the others in leaving the castle.” | “He shakes your hand and then joins the other in leaving the castle.”}

The error makes me think it’s trying to read your sentence as a variable. Try putting quotes in

@{romancecaivral “He winks at you as he shakes your hand and then joins the others in leaving the castle.”|”He shakes your hand and then joins the

other in leaving the castle.”}

That’s, unfortunately, not working either

The standard syntax for multireplace is indeed.

@{(condition) IFTRUE|IFFALSE}

Normal brackets aren’t necessary.
For numeric variable, it goes like this.

@{variable 1|2|3|4|etc.}

Can we have a bigger picture of your code?

So the condition is romancecaivral.

#Ask General Caivral to dance
  *set romancecaivral true
  *set caivral %+20

This is how you get the variable to become true.

@{romancecaivral He winks at you as he shakes your hand and then joins the others in leaving the castle.|He shakes your hand and then joins the
other in leaving the castle.}

This is what I want to happen depending on whether romancecaivral is true or still false.

I have the variable created, and it is false in my startup.

If you need more code, just let me know what exactly you need :slight_smile:

Hmm, my first instinct is to see whether you have a typo on the variable. “Romancecaivral” doesn’t look human friendly.

Try going the old way:

*if romancecaivral
   He winks at you
*else
   He doesn't wink

This way, at least we can see if the error is on the variable or your code syntax. I’m convinced the error takes place somewhere else, though. Like immediately above it.

Seeing if it was a typo was the first thing I checked, and that wasn’t it. I switched to the old fashioned way, and it works perfectly fine.

The line above the condition is:

The general comes up to you at one point. “Thank you for your heroism,” he says.
@{(romancecaivral) He winks at you as he shakes your hand and then joins the others in leaving the castle.|He shakes your hand and then joins the
other in leaving the castle.}

While I have you, I got another error, and I can’t for the life of me figure it out either.

The error doesn’t give me a scene, like how it usually will say “error: chapterone line 28; and then the error”

This on just says error: line 945: Not a number:. No scene at all in the error message.
Only one of my scenes has a line 945, and the line is:

${heirname} looks shocked, but quickly composed @{heirhis hiself|herself}. ${friendname} looks less than happy to hear you say that to the ${heirtitle}.

I know I’m not being helpful here, but bear with me. Is there any reason why you are set on having it as a multireplace, rather than an if-else? It seems to me there’s no clear advantage if you’re going to have to type both sentences in full either way. Am I missing something?

Quick curiosity. Are you on CS-IDE or any other third-party IDE, or going rambo through notepad and all those shell commands? When is the last time you have CS updated?

That is worth finding out, right now I’d recommend Visual Studio Code and the extension linked in this thread: New Choicescript extension for VS Code

Good question. It looks a lot like you’re working with an old version of ChoiceScript, and so Multireplace is not behaving as expected. At a glance, your code looks like it should work.

1 Like

I’m using Notepad++. Going to update CS now to see if that helps my problems

What does it look like where you created the variable?

What does your code currently look like? What does the error currently say?

For 945 try placing heirhis in parentheses. Also, does the error appear when you run quicktest or randomtest in CSIDE? Does it give more information?

I had no idea you don’t need to put parentheses () around a variable to see if it is true. That is going to save my left pinky even more by having to put less stress on it. That would be a good update in the wiki. Thanks for showing this Szaal.