I’m not sure if I’ve set up the *if statements correct.
*choice
#"I wanted to explore the area surrounding the camp"
*if crush Ike then +5 ikefriendship
*if crush Rhys then +5 rhysfriendship
*if crush Tibarn then +5 tibarnfriendship
*if crush Gatrie then +5 gatriefriendship
"That sounds exciting." ${crush} said. "Yeah and then it got even more exciting when that guy decided to try to attack me." You said. "I was gald when you came to save me. I don't think I would have been able to make it out by myself." "It was nothing really but I'm glad you're ok." The two of you make it back to the camp without any other excitement happening.
*finish
*choice
#"I wanted to explore the area surrounding the camp"
*if crush = "Ike"
*set ikefriendship +5
*goto crush_answers
*if crush = "Rhys"
*set rhysfriendship +5
*goto crush_answers
#Other dialog option.
*goto other_label
*label crush_answers
"That sounds exciting." ${crush} said.
*line_break
"Yeah and then it got even more exciting when that guy decided to try to attack me." You said. "I was gald when you came to save me. I don't think I would have been able to make it out by myself."
*line_break
"It was nothing really but I'm glad you're ok."
*line_break
The two of you make it back to the camp without any other excitement happening.
*finish
My option and previous poster’s option require different types of variables for defining the crush.
My option requires a string variable, so it goes like this:
*create crash “” when creating the variable;
*set crash “Name of your crash” when the MC “crashes”.
For previous poster’s option:
*create crush_ike false and so on for every potential RO when creating variables;
FWIW using string comparisons is much more prone to human error.
It’s easy to make a mistake like, say: *set my_crush “ikr” which you won’t necessarily notice right away (and this where if/elseif/else:bug comes in handy!). With boolean checks it’s either False, True or the interpreter complains immediately.
Both ways are perfectly valid, and you should use whichever you’re comfortable with, of course. That said, when advising newcomers, I think these sorts of differences are worth highlighting.
and what I changed the part I asked about originally too
*choice
#"I wanted to explore the area surrounding the camp"
*if crush_Ike
*set ikefriendship +5
*goto answer
*if crush_Rhys
*set rhysfriendship +5
*goto answer
*if crush_Tibarn
*set tibarnfriendship +5
*goto answer
*if crush_Gatrie
*set gatriefriendship +5
*goto answer
*label answer
"That sounds exciting." ${crush} said. "Yeah and then it got even more exciting when that guy decided to try to attack me." You said. "I was gald when you came to save me. I don't think I would have been able to make it out by myself." "It was nothing really but I'm glad you're ok." The two of you make it back to the camp without any other excitement happening.
*finish
As for the [crush] variable, there’re two ways to work around them.
This is @CJW’s suggestion, by using different variables: [crush_ike], [crush_rhis], [crush_tibarn], [crush_gatrie].
Yes, those are different variables and you need to *create them on “startup.txt.” They’ll be a boolean variable, meaning you want to do true/false instead of “Ike,” “Rhis,” “Tibarn,” or “Gatrie.”
This is what I believe you’re going from your code example, by using single variable [crush].
In this case, you want to switch the conditional checks into something like
*if crush = "Ike"
Then this
*elseif crush = "Rhys"
That one
*elseif crush = "Tibarn"
No, not that one
*else
Yes, that one
Beware: mind the capitalization. They’re CaSe SenSitiVE.
I’m not sure if this has been asked before or not but I’m asking anyway. I’ve been getting the error message Invalid set instruction, no expression specified: crush for this code and was wondering what was wrong. I tried looking up the error message but couldn’t find anything.
What are you setting the crush variable to? You’ve told ChoiceScript you’re going to set the variable crush to a certain value… but there’s nothing in your sample to indicate what you want that value to be.
In general, code requires very strict formatting, so you should look at the tutorials and follow them exactly. It’s very important that no code can have two meanings, because the computer would have to pick one basically at random.
Here, the command to set a variable to a fixed value has three parts:
1.*set, to indicate you’re setting a variable
2.the name of the variable you’re setting
3.the value you’re setting it too
Then generally you want to end the line to signal you’re done so the computer knows not to look for a + and another value; you might be able to get around that using parenthesis but I haven’t checked because I’d recommend not doing that.
There’s multiple different ways to structure *set for different tasks, but they’re all equally strict. If you’re getting errors off a line right away it generally means you’ve made a mistake in following the rules for what you’re trying to do so that the line doesn’t match any rules and thus means nothing to the computer. You’ll probably solve it faster by going to the relevant wiki page and finding the example code for the thing you want to do then duplicating it rather than asking on the forum. These sorts of errors are pretty much like screwing up punctuation in prose; they happen all the time and are usually easy to fix if you check reference material.
Now, if that doesn’t help, or worse, the computer accepts a line but doesn’t do what you want it to, take that to the forum. Also, while error messages are useful don’t rely on them to be perfectly accurate; they’ll come at the point where it’s definitely impossible for the code to mean anything and may be some distance from the mistake.
@James_Marsh I have checked the tutorials or wiki pages for whatever my issue was but in some cases it’s either not exactly what the error was. In some cases I post to the forum as I wanted a fresh pair of eyes to look at it incase it was a simple error but I just keep missing it since I’ve been looking at the same thing for a while.