"Invalid expression" error

I keep running into “Invalid expression, couldn’t extract another token”

so, I’m trying to work on the multireplace (I think that’s what I would need in this situation) and I keep running into this error. I have an option in my choices to allow players to choose heterochromia and type in their own eye colors.

my code for startup:

*create eyecolor " " 
*create eyecolor2 " "

but I’m having trouble in my stats screen where I give the player a run down of their character customization (hair, eye color, gender, whatnot).

my stat screen code:

Eye color: $!{eyecolor}
*if (eyecolor2 != " ") 
     *set Eye color 2: $!{eyecolor2}

is the code supposed to read:
*if eyecolor2 != true
*if eyecolor2 !=false

note: this sorta reminds me of algebra and I was horrible at algebra so something’s clearly going over my head and I’m not noticing it. like trying to pin a sticky note without the sticky part. please be patient, I do have learning difficulties. thank you.

Where do you actually have that error? And where it points out?

Ohh wait, I see it now.

You’re setting the variable incorrectly, it should be:
*set variable_name = value
and not
*set variable name with spaces = ${text to show the player}

1 Like

wait, I still feel a little lost. where would I make the value if it has to be a number? would that go on the same page (my stats) or would I have to create another thing on startup?

the value can also be another variable, but you have to put it without ${}, just the name

1 Like

Maybe try removing the *set because I don’t think you mean to set the variable at this point in the code.

1 Like

^ Try removing the *set. If I’m reading the code right, the *if is meant to determine whether the line Eye color 2: will appear in the text.

that is what I’m going for, for eyecolor2 to pop up next to eyecolor so if someone types “green” and then “gray”, I want it to pop up om the stats as
Eyecolor: Green (and Gray)

but if I remove *set it makes it regular text and just pops up as eyecolor = eyecolor2, it doesn’t type out say the word “gray” which would be the example I’m going for. I hope this made sense;;

What if you use it like this?

Eye color: $!{eyecolor} (and $!{eyecolor2})

1 Like

oh god that is so much easier and worked like a charm. I wanted to do the *if thing with another stat so I figured if I could master this one, I would be able to copy it and get a feel for the *if variable thingies.

1 Like

Use *if when you need to differentiate one thing from another, when you want to separate a result, an outcome. This command ${variable} only shows to the player the content of a variable. If you want to show the player the value inside the variable “strength” you use ${strength} which will show 15 for example, and if you need to work with the value “15” inside the variable you only use the name, *if strength >= … When the program runs it takes the value inside of the variable named strength, not the text “strength”

2 Likes

this was worded a bit tricky for me, but if I’m understanding correctly, by using ${variable}, I’m only showing text.
when numbers get involved, I get a little lost, sorry.

Yes, ${variable} shows what’s inside the variable.

In essence, you have a value and a name you give it to identify it from the rest
*create variable_name variable_value
*create strength 15
If you want to work with the value of the variable you don’t use 15
*if 15 >= 20
You use the name that holds the value
*if strength >= 20

The program will recognize “strength” as a variable and it will take its value to work with, in this case, 15.

2 Likes

Youll still need the *if in there since not everyone has a second eye color.

Eye color: ${eyecolor1}
*if eyecolor2 != " "
  and ${eyecolor2}

For someone who didn’t set a second eye color, they’ll only see the first line.

3 Likes

ok, yeah, this is what worked. I didnt realize I had to actually TYPE OUT THE “AND” PART😭 thank you very much, to everyone.

2 Likes