Notifications
Clear all

[Closed] structs – lost properties

I guess I suffer from a naive understanding of structs.
Please look at this and verify that I’m not going insane:


 (
 	struct person (name, height, age, sex)
 	bill = person name: "Bill" height:72 age:34 sex:#male
 	--joe = person name: "Joseph" sex:#male --uncomment this line to make it work
 	joe = person --uncomment this line to break it
 	
 	bill.age  --returns 34
 	joe.age  --Unknown property: "age" in #Struct:person
 	
 	--Since the height and age members are not assigned values, and do not have 
 	--optional initial values supplied in the structure definition, they default to 
 	--a value of undefined.
 	
 	--* a struct instance must be constructed with at least one property defined
 	--otherwise, the struct instance doesn't have access to it's properties
 )
 

The important bit is this: “a struct instance must be constructed with at least one property defined, otherwise the struct instance doesn’t have access to it’s properties”.
Is this an accurate statement?
Would the above snippet work if the struct properties were initialized to some value?

Thanks, I’m trying to get a better understanding of how structs work in maxscript.

2 Replies

actually, i was just missing the () after person. d’oh!

you forgot to set brackets…

EDIT: you are too quick. or I’m too slow… already fixed.