cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Maxscript nested structs

Maxscript nested structs

Allow nesting structs and rollouts inside structs. This would be very helpful for organizing large scripts. There are some workarounds that make it sort of possible, but they are too verbose. You can already nest structs and rollouts in other rollouts, but you can't make them private or public like you can with structs.

2 Comments
Swordslayer
Advisor

Doesn't really feel overly verbose to me:

 

struct mainStructDef
(
	private subStructPrivate = struct subStructPrivate (propA, propB);,
	public subStructPublic = struct subStructPublic (propC, propD);
)

mainStruct = mainStructDef()
mainStruct.subStructPublic propC:10 propD:20
dankeroni
Explorer

Also forgot to mention, you can only create the nested struct from an instance and not from definition - you'd have to use functions, but you'll get ugliness like this:

struct mainStructDef
(
    private fn subStructPrivate = (struct _ (propA, propB);)(),
    public fn subStructPublic = (struct _ (propC, propD);)()   
) 

And you'd lose access to the nested struct definition. Or you could make the function just return the definition, but then you'd first have to assign the result to a variable and then instantiate it.

 

Idk, this feels better:

struct mainStructDef
(
    private struct subStructPrivate (propA, propB),
    public struct subStructPublic (propC, propD)      
)  
mainStructDef.subStructPublic propC:10 propD:20

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea