Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

iterate through an object sugarcube 2

$
0
0
I know how to iterate through arrays with for loops, but is it possible to do it with objects such as?
<<set $char={
	stats:{
		health:{name:"health",val:90,max:100,min:0,type:0},
		mana:{name:"mana",val:10,max:50,min:0,type:0},
		str:{name:"str",val:8,max:10,min:0,type:0},
		int:{name:"int",val:2,max:10,min:0,type:0}
	},
	desc:{
		name:{name:"name",val:"bob"},
		age:{name:"age",val:29}
	}
}>>

How can you iterate through that object and get the val for all of the objects in stats for example? I have tried using Object.keys, but once i get the name of the object i am stuck.

Thanks

Viewing all articles
Browse latest Browse all 1844

Trending Articles