Multiple *choice error

You’re welcome! :slight_smile:

@aaster23 Sorry :cry: Sleep summoned me.
@Wraith Arcania #2 :fist:

It was a pleasure, had spare time to beat! :smiley:

Once again I am summoing both of you :smiley: :smiley:
Here is my problem. So i have the "*create weapon "
Here is my Weapon definition:

 #You reach out for your bow.
    *set Bow +25
    You are a mighty hunter.
    *set weapon Bow
    *goto_scene meeting
 #You reach out for your staff.
    *set Magic +25
    You are a mighty mage.
    *set weapon Staff
    *goto_scene meeting
 #You reach out for your dagger.
    *set Dagger +25
    *set weapon Dagger
    You are a mighty assassin.
    *goto_scene meeting

When setting the weapon as Staff i get an error “startup line 56: Non-existent variable ‘staff’”
The other work just fine but this one does not work …
Thanks for the help once again :slight_smile:

When you use the *set command with words other than True/False, you need to put it in “”
Example:
*set Weapon True
*set Weapon “Staff”
*set Weapon “Bow”

I have no idea why the others work, normally they shouldn’t

2 Likes

I don’t know what’s happening! The other weapons work without “” just fine!
By the way do you mind testing out my script that i’ve made untill now ?
If you want just send me a message.
Thank you A LOT for helping me !

As a side thought, do you believe it would be easier just to create each weapon individually?
E.g.

*create dagger false
*create bow false
*create staff false

Then simply setting them to true when taken.

*if (bow)
–> Using *if’s to show the weapons in use when the time comes as a Boolean.


Didn’t notice you were using the weapons as a percentage there, I take it that’s referring to the MC’s skill use in the stat then.


From what I see you’re trying to ask CS if the MC has a staff, but what CS is saying (from your code) “I don’t have a staff for you, but I have a weapon that’s a staff.” If that makes sense.

Staff, bow, and dagger don’t exist. They exist as stats though. And they also exist as a weapon, but only if weapon is brought into the equation.

E.g.

*if (weapon = dagger)
–> I’ve got myself a dagger.

Vs

*if (dagger)
–> Error. Dagger isn’t true/false it’s been created as a number.

My main thought is to use the weapon as a class.
RPG alike.
Dagger for the Assassin,
Sword for the Warrior and etc.
On the other side the idea of staff bow and dagger T/F is not bad but i don’t see a very big difference since i give it a value at the beginning and use the same value for the whole game.
It’s

*if (weapon = "dagger")
*choice 1
*if (weapon = "sword")
*choice 2

and etc
versus

*if (dagger = true)
*choice 1
*if (sword = true)
*choice 2

And so on.

Those ones “work” – but only in the sense that they’re not crashing the game. :slight_smile: When you *set weapon "bow", if you then type “I attack with my ${weapon},” the game will display “I attack with my bow.”

But when you *set weapon bow, you’re telling ChoiceScript to set one variable (weapon) to the value of another variable (bow). With the code you’ve shown us…

#You reach out for your bow.
    *set Bow +25
    You are a mighty hunter.
    *set weapon Bow
    *goto_scene meeting

“I attack with my ${weapon}” would be displayed as, “I attack with my 25” – which I think is not what you’re going for.

The reason it’s crashing with Staff is that your variable there is Magic, not Staff. So you’re telling the game to set one variable (weapon) to the value of a variable that doesn’t exist (Staff).

By the way, it’s best if you don’t capitalize variables – it can lead to various problems in the code. (For notable example, if you’ve set weapon “Dagger”, *if weapon = "dagger" won’t give you anything.) If you want the game to display a variable in caps, just put an exclamation point in like this: $!{weapon}. E.g. if weapon = “bow”, “I attack with my $!{weapon},” will display “I attack with my Bow.”

5 Likes

Hello. I have a question again. Can i use *if like this:

*if (charaf = Love) or (charaf = Attracted)
*choice 

Probably like this.

*if (charaf = "Love") or (charaf = "Attracted")
  *choice

Note the quotes around love and attracted (which per my last comment, you’ll need unless you mean “if the variable charaf is the same as the variable Love”) and the indent before *choice.

And just remember that if you use capitals in your string variables, you have to use them consistently (that is, if you’ve *set charaf "Love", then *if charaf = "love" will not be triggered).

Thanks for the fast answer !
I have another question.
When i use *temp do i have to create it like that:

*temp smstat 0
*temp smstats “”

or like that:

*temp smstat

Thanks for helping me out once again :slight_smile:

The former. It tells ChoiceScript what kind of variable you’re creating – string (""), Boolean (true/false), or numeric (1234).

Worth noting that only the first kind of variable needs to use quote marks with *set, *if, etc. as in the examples we’ve been discussing above.

@wraith and @Havenstone you two are code wizards. Thanks for the lessons.

1 Like

Worth noting that this is also perfectly valid - provided that you *set a value before the *temp variable is actually referenced, e.g. the following would work just fine:

*temp tunnel

*if found = 1
  *set tunnel "Tom"
*if found = 2
  *set tunnel "Dick"
*if found = 3
  *set tunnel "Harry"

"Sorry, old chap, the blasted jerries have found ${tunnel}!"
1 Like

I’d not realized that still worked. :slight_smile: Thanks for the correction…

1 Like