*if (crossbow =true)#Shoot, somehow gets "2-village line 828: Non-existent variable 'shoot'"

I’m having trouble with using *if choices.

For some reason, when I make the choice *if (crossbow =true)#Shoot, I for some reason get the error “2-village line 828: Non-existent variable ‘shoot’”

My code looks like this:

*choice
	*if (greatsword =true)#Charge them
		*comment fight goes outside
		*set demons -6
    *if (crossbow =true)#Shoot one of them
	    *set demons -1
    *if (greatsword =true)#Use a wide horizontal swing
	    *set demons -2
    *if (shortsword =true)#Kill the first one to reach you
    *if (clearhouse =false)#Flip up a table to use as a shield
		*set head +1
    #Dodge out of their way
	#There's no end of them...

I’m using the automatic “random tester,” that’s what’s picking it up. Presumably I would get the same error for the other choices if the random test got that far.

I’ve also tried supplementing *if with *selectable_if to the same effect.

Also, if I put a space between between the check and the option, I instead get
“2-village line 1755: Expected choice body”
I don’t even know where to start with that.

Are you remembering to finish every choice with a *goto statement? You can only fall out of a *fake_choice (unless they’ve changed it with the last update…)

The crossbow scene hasn’t been written yet so I put a *finish under it.
In any case, it’s a *choice, not a *fake_choice.

You can see the entire script for the scene here, if you want to see it:
https://dashingdon.com/play/interestedparty/daemoniacus-altor/mygame/scenes/2-village.txt

Be warned though, it’s quite long.

Does it help if you put a space after the equal sign? :thinking: I’m just wondering if it’s reading that as part of the variable.

Or does it clear up if you just have the #choices in a new indented line after the *ifs?

You can’t have empty choices, you need *gotos after each choice, and your *if statements are unneccesarily complicated.
If you use *fake_choice, you don’t need gotos if you want them to all go to the same place.

*choice
	*if (greatsword) #Charge them
		*comment fight goes outside
		*set demons -6
		*goto Blah
	*if (crossbow) #Shoot one of them
		*set demons -1
		*goto Blah
	*if (greatsword) #Use a wide horizontal swing
		*set demons -2
		*goto Blah
	*if (shortsword) #Kill the first one to reach you
		*set something
		*goto Blah
    *if not (clearhouse) #Flip up a table to use as a shield
		*set head +1
		*goto Blah
	#Dodge out of their way
		There's no end of them...
		*goto Blah
*label Blah

I used to have it that way.

I kept getting the “2-village line 1755: Expected choice body”

That didn’t do it either.

Is this the problem?

  		*if (greatsword =true) #Charge them
				*comment fight goes outside
				*set demons -6
				*could be 4 or 3
				Timidity has no place when fighting the forces of Satan.

The 4th line looks like a comment, but hasn’t been commented out. (Sometimes when you don’t know where an error is, it’s a lot earlier in the code than the error message claims.)

1 Like

Wasn’t the problem, but I probably would have run into that later down the line. Thanks for pointing it out early.

That did it.

Put a “*goto end” at all the empty choices, which took it too “under construction. *finish”
Finally able to start making progress again. thanks.

2 Likes

[quote=“Interestedparty, post:6, topic:27035”]
I kept getting the “2-village line 1755: Expected choice body”[/quote]

Okay, well, that’s way later than line 828, so I expect that is fixing the issue at hand… but at the end you have “#Dodge out of their way” and “#There’s no end of them…” and neither of these choices have anything under them. I think that must be the “expected choice body.” So if you just stick some *goto under each of those two choices, and you do the separate line *if thing, does that clear the error?

Or I guess it’s already fixed :sweat_smile:

Check the other choices I find the error could be on a different line if you accidentally put shoot in a (insert variable) slot further down on the same indent