Sugarcube 2.28.2 error- <<set>> Bad Evaluation

So, a total noob here, emphasis on noob. My total coding experience consists of a brief class I took in high school that covered html (which I remember nothing of). Despite all that, however, I’ve been flying by on the seat of my pants and using whatever resources I can get my hands on, but this error BAFFLES me-

Error [StoryInit]:Set:Bad Evaluation: Unexpected Token Default
(edit- I removed the <'s from around set in the error message because it was causing the set to vanish.)

So, I poured over story Init until I figured out what the issue is-

<<set $PlayerPhysicalTrait to {
“Hair” : default,
“BodyThickness” : default,
“SkinColor” : default,
“EyeColor” : default,
“EyeType” : default,
“BodyType” : default,
“BodyTone” : default,
}>>

At first, I thought It was being picky about and wanted me to use true/false instead of default, but I went through line by line deleting lines, editing them so they’d use true/false, retesting the story, and moving on untill I was only left with
<<set $PlayerPhysicalTrait to {
}>>
and STILL the error persists. To top it off, I have this-

<<set $PlayerGender to {
“Male” : false,
“Female” : false,
“Default” : true
}>>

Right above it. I’ve obviously searched for this particular error on google, but haven’t found it anywhere else.

1 Like

You likely have multiple issues going on at once.

  1. The value default is not a predefined identifier, so that will be one of your issues, unless you’ve defined it somewhere prior to that bit of code.
  2. If your examples are representative of your actual code, then you seem to be using typographic (i.e. curly) quotes, rather than regular quotes—i.e. the difference between “Male” and "Male". Typographic quotes are not valid syntax, so use regular quotes. At a guess, you’re copy-pasting from a word processor of some variety and it’s “helpfully” replacing your regular quotes with typographic ones.

There may be other issues. Without seeing the code, we can’t really say.

2 Likes

FYI - This forum itself uses typographic quotes, as you can see on your “helpfully” line.

@RuinedSilver: You can use the “Preformatted text” button in the forum’s text editor to prevent problems with text inside angle brackets (e.g. <<this>>) and to keep it from changing your standard quote markers to fancy ones (e.g. "this").

Anyways, as TheMadExile said, the problem is that the code doesn’t know what “default” is, since it’s undefined. You’ll want to do something like this instead:

<<set $PlayerPhysicalTrait to {
"Hair": "default",
"BodyThickness": "default",
"SkinColor": "default",
"EyeColor": "default",
"EyeType": "default",
"BodyType": "default",
"BodyTone": "default"
}>>

(Note: I also got rid of the trailing comma you had on the last item.)

Since "default" is now a string, the code should be able to handle that properly.

Hope that helps! :slight_smile:

2 Likes

The preformatted text button is the </> one. Highlight your code and click. Inline, it places backticks around your text, which you could also type in manually. You can also place three backticks ``` on a single line before and after lengthy multi-paragraph code to mark it as such.

Preformatted text in individual paragraphs within a message also gets a “copy” button on hover so you can pull it verbatim and paste it elsewhere.

1 Like

You got me, I did do a copy/paste. thanks for letting me know about that- I’m gonna have to go back and check all my syntax now. I’ve… got a lot of work ahead of me >->"

1 Like

Ah, Thank you! This fixed it. The code I was using for reference didn’t have the second set of quotes so I didn’t even think about it. Also, thanks for letting me know about the text editor! ^-^

Oh? I’m not usually one to mess around with text editors, so I just kinda ignored it and worked around it. Thanks for letting me know!

1 Like

Unless you need the fancy quotes in some parts, you can just do a search-and-replace to replace all instances of and with ". At the bottom of the Twine story editor window, where it says “Quick Find”, click the little “application window” icon to bring up the “Find and Replace” window.

1 Like