Having some trouble with *selectable_if with a specific boolean

Hello everyone. I’ve scoured the forums for help with this issue, but every thing I’ve looked through so far has not helped, and at this point I have no idea why it’s not working. (Sorry a little long post, plus if this has been asked and answered before, please let me know where I can find the solution.)

Originally I had a *selectable_if command be available if the following conditions were met:

(In startup)
*create watch false
*create novskill1cd false

(In scene1)
*set watch true (if player did something specific)

(In scene2)
*selectable_if ((novskill1cd = false) and (watch = true)) #Use skill.

I believe the parenthesis should be correct for this code to work. (I never got an error for it, and I’ve gotten more complex *selectable_if conditions to work in the same scene.) However, I noticed while playing through that no matter what I did, the option was always disabled. I checked to make sure both conditions were met and they were, but still no luck.

I tried making this a single variable when I read that *selectable_if may not be able to process more than one condition effectively:

(In startup)
*create watch false
*create novskill1cd false
*create watchcd false

(In scene1)
*set watch true (if the player did something)
*if (novskill1cd = false) and (watch = true)
   *set watchcd true

(In scene2)
*selectable_if (watchcd = true) #Use skill.

At this point I decided to check with just the original variable:

*selectable_if (watch = true) #Use skill.

It still didn’t work. I even went into startup and created the watch variable as “true”, but the option remained disabled.

I also tried:

*selectable_if (watch) #Use skill.

…but I got this error:

So now I have no idea what’s wrong. It seems like the game isn’t registering the fact that the variable “watch” was set to “true”. I’ve not had this problem with any other variable, and all my other *selectable_if commands work with the correct conditions.

Maybe, I’m really tired and this has a simple answer, but I’d appreciate any help on this matter as I can’t seem to think of any other explanations. Thank you!

I’ve read through your code and I can’t see anything wrong with it. It should work (unless I’m missing it too)… perhaps someone with sharper eyes can see it?

In the meantime, try changing from Boolean to number (I use 0 and 1). This is the same thing but let’s you also add a third or more options later if necessary.

Edit: is there a CS function called watch??

From what you’ve posted, I believe the problem lies around the [watch] variable, so let’s check it out.

  • Are you sure that you already declared the [watch] variable properly? e.g. *create watch true or *create watch false
  • Perhaps, for some reason, you “double-declared” that variable. Try to make sure that there’s only one [watch] variable on that particular scene (no *temp watch anywhere on the scene)
  • If not, you probably have *label watch and *create watch somewhere. Having a label name which is as exactly as same as a [variable] name is a no go. Try to put something unique even for your label name.
  • Capitalization. Is it watch, Watch, or WaTCh?

To the best of my limited testing, watch cannot be the name of a variable.

I ran the following code in the old, web-based legacy version of CSIDE, my own oldest installation of ChoiceScript (which I downloaded on April 8, 2016,) and my own newest installation of ChoiceScript (which I downloaded a couple minutes ago, just for this.)

*title Code Test
*author @Minnow
*scene_list
	startup
*create watch false
*create novskill1cd false
*create watchcd false
*label startloop
Variable 1, watch, is ${watch}.
*line_break
Variable 2, novskill1cd, is ${novskill1cd}.
*line_break
Variable 3, watchcd, is ${watchcd}.
*choice
	*selectable_if (watch) #Set variable 1, watch, to false.
		*set watch false
		*goto startloop
	*selectable_if (not(watch)) #Set variable 1, watch, to true.
		*set watch true
		*goto startloop
	*selectable_if (novskill1cd) #Set variable 2, novskill1cd, to false.
		*set novskill1cd false
		*goto startloop
	*selectable_if (not(novskill1cd)) #Set variable 2, novskill1cd, to true.
		*set novskill1cd true
		*goto startloop
	*selectable_if (watchcd) #Set variable 3, watchcd, to false.
		*set watchcd false
		*goto startloop
	*selectable_if (not(watch)) #Set variable 3, watchcd, to true.
		*set watchcd true
		*goto startloop
	#Quit
		*ending

The legacy CSIDE and my old installation of ChoiceScript provide indentical results, and I feel more useful clues than the newer version does:

Notes:

  • Line 9 reads Variable 1, watch, is ${watch}. in the code, which should produce Variable 1, watch, is false. in the output. However, it instead outputs Variable 1, watch, is function watch() {[native code]}.
  • It initially displayed an error dialog box reading line 15: Neither true nor false: function watch() {[native code]}. I clicked past that to make it easier to see the incorrectly-displaying variable.
  • I did create a choicescript_stats file, and it also displayed watch as function watch() {[native code]}.

The newer version throws the error, but doesn’t display the malformed variable.

Code Test 2

3 Likes

Oh!
Does that means we can’t name our variable as [watch]?
That… sucks :frowning_face:

Is there any additional names that we can’t use as variable? And probably label as well?

1 Like

@Minnow Thank you very much! I thought I was going crazy. I changed the variable and it works now. I think I may switch to CSIDE since it definitely gives more accurate descriptions of errors.

Although, I do have the same question as @Szaal, are there other functions like watch that can’t be used as labels or variables? Also, do you happen to know what the function watch() does? I wasn’t able to find it on the wikia yet, but I haven’t looked through the forums.

Either way, thank you again. I would have never figured that out with the slightly more vague error message that popped up. Or at least, it would have taken me a long time.

Edit: Thank you Szaal for the summon!

Let me summon the developer of the CScript himself. Perhaps, he bestow upon us the enlightenment.
@dfabulich

1 Like

Thanks for letting me know! it’s fixed in the latest version of ChoiceScript up on Github.

(Goodness, this was a fascinating bug.)

9 Likes

Whilst I’m glad it helped with debugging here, I implore people who wish to use CSIDE to use the new one at
ChoiceScript IDE, not the legacy one. The latter will never be updated, and is accessible purely for entertainment/reference purposes. :slight_smile:

2 Likes