Howdy, Stranger!

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

What am I doing wrong with these objects [SC2]

edited December 2015 in Help! with 1.x
I'm using SugarCube 2, and when I put the following code into the StoryInit passage, it starts messing up and when I start it says unexpected token.
<<set $weapdh= {
	name: "",
	type: 0,
	dam: 0,
	def: 0,
	agi: 0,
	fai: 0,
	int: 0,
	str: 0,
	hp: 0,
}>>

<<set $weapoh= {
	name: "",
	type: 0,
	dam: 0,
	def: 0,
	agi: 0,
	fai: 0,
	int: 0,
	str: 0,
	hp: 0,
}>>

I do have other objects and they're fine, but these two are causing problems. I've tried it in SugarCane and it works fine with no errors.

Oddly, if I cut and paste the other objects that are set and change their names (so $a is $b for instance) then they work fine, it's only once I start changing them to the above that the problem starts. I'm probably doing something completely obvious, but I don't see what.

Edit to add: The full StoryInit is...
<<set $player= {
	fname: "",
	lname: "",
	lfname: "",
	llname: "",
	title: "",
	gender: "",
	gennum: 0,
	gentitle: "",
	class: "",
	classt: 0,
	classat: 0,
	classst: 0,
	agi: 0,
	fai: 0,
	int: 0,
	str: 0,
	hp: 0,
	trade: 0,
	rep: 0,
}>>

/% Armor Values
	name : Name of item
	name + at: Armor type (1: cloth; 2 leather; 3 mail; 4 plate)
	name + av: Armor value 
	name + st: Stat type (1: agi; 2: fai; 3: int; 4: str)
	name + stv: Stat value

	Neck, back, rings and pendants do not have at or av %/

<<set $armor= {
	head: "",
	headat: 0,
	headav: 0,
	headst: 0,
	headstv: 0,
	neck: "",
	neckst: 0,
	neckstv: 0,
	shoulder: "",
	shoulderval: 0,
	shouldertype: 0,
	shoulderst: 0,
	shoulderstv: 0,
	back: "",
	backav: 0,
	backst: 0,
	backstv: 0,
	chest: "",
	chestat: 0,
	chestav: 0,
	chestst: 0,
	cheststv: 0,
	arm: "",
	armat: 0,
	armav: 0,
	armst: 0,
	armstv: 0,
	wrist: "",
	wristat: 0,
	wristav: 0,
	wristst: 0,
	wriststv: 0,
	waist: "",
	waistat: 0,
	waistav: 0,
	waistst: 0,
	waiststv: 0,
	leg: "",
	legat: 0,
	legav: 0,
	legst: 0,
	legstv: 0,
	feet: "",
	feetat: 0,
	feetav: 0,
	feetst: 0,
	feetstv: 0,
	ringl: "",
	ringlst: 0,
	ringlsv: 0,
	ringr: "",
	ringrst: 0,
	ringrsv: 0,
	pendant: "",
	pendantst: 0,
	pendantsv: 0,
}>>


<<set $weapdh= {
	name: "",
	type: 0,
	dam: 0,
	def: 0,
	agi: 0,
	fai: 0,
	int: 0,
	str: 0,
	hp: 0,
	str: 0,
	hp: 0,
}>>

<<set $weapoh= {
	name: "",
	type: 0,
	dam: 0,
	def: 0,
	agi: 0,
	fai: 0,
	int: 0,
	str: 0,
	hp: 0,
	str: 0,
	hp: 0,
}>>

Comments

  • "def" is a TwineScript operator in SugarCube, so you'll need to quote it within the object literal. For example:
    <<set $weapdh= {
    	name: "",
    	type: 0,
    	dam: 0,
    	"def": 0,
    	agi: 0,
    	fai: 0,
    	int: 0,
    	str: 0,
    	hp: 0,
    }>>
    
    <<set $weapoh= {
    	name: "",
    	type: 0,
    	dam: 0,
    	"def": 0,
    	agi: 0,
    	fai: 0,
    	int: 0,
    	str: 0,
    	hp: 0,
    }>>
    
  • Ah right. Many thanks. I was scouring the code for typos, missed commas, and even ran it through Notepad++ to see if there were any zero-width spaces or any odd non-visible characters that had some how got into it (I had character map open at the time).

    I'll just change the name of that variable anyway :)

    Once again, many thanks.
Sign In or Register to comment.