Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Problem with "def" property of objects in Sugarcube

I must be really dense, or there's a really obscure bug lurking somewhere. I'm defining some objects to initialize monster data, and I keep getting this error: "Error: <<set>>: bad evaluation: missing : after property id".

I've cut down the data to a small test subset that illustrates the problem.

This set works:
<<set $enemy = {
  hp: 12,
  int: 3
}>>

This set does not.
<<set $enemy = {
  hp: 12,
  def: 2
}>>

What's wrong with a property called "def"? What am I missing? The error message is entirely unhelpful since I clearly have a colon there. I can rename the property, but why is this particular name a problem? Some internal conflict with some kind of definition statement, maybe?

Comments

  • If you look at the list of TwineScript conditional operators in the <<if>> macro documentation you will see that def is one of them.

    When the SugarCube javascript engine processes your 2nd <<set>> macro it is removing the def keyword, which is causing your error. You should not use reserved words as javascript Object property names.
Sign In or Register to comment.