new set() syntax and array creation

  • hi klaus,

    i noticed, that you cant create a new array with the new set() syntax for multiple properties...

    Code
    // we have a new array
    	set(local.testarray[test].enabled, true);
    	set(testarray[test].align, topleft);
    	
    	// throws error "invalid array access"
    	set(local.testarray[test], enabled=true, align=topleft);


    this is just fyi...
    but if it doesnt bloat the code, it would be nice if that works, too ofc *smile*

    best and a happy new year,
    index

    by the way...
    the new set() syntax is a great addition!
    it makes the source much more readable
    thanks for that!

  • hi klaus,

    a follow up ..
    is it intended, that the new set() syntax can't create sub objects ?

    if you do this:
    set(image, hfov=360, vfov=180, sphere.url='plugin:scene_video');

    set doesnt create an object image.sphere, it creates a string variable called "image.sphere"
    the output of debugvar(image); is:
    image.sphere.url=[plugin:scene_video] type=string

    while with set(image.sphere.url, 'plugin:scene_video'); it is:
    image.sphere=[Object] type=object

  • Hi,

    i noticed, that you cant create a new array with the new set() syntax for multiple properties...

    Right, in the next version it will be able to do that.

    is it intended, that the new set() syntax can't create sub objects ?

    Yes, that was basically intended - the 'multi-variable-set' actions first gets (or creates) the given object and then only sets/adds the given properties. This is way faster then resolving the whole 'path' again for each property.

    But I have now added an fallback solution for such case - that means when a variable name will contain a '.', then internally automatic a normal set() call will be done for that variable.

    Best regards,
    Klaus

  • Hi Klaus

    Does it affect subnodes in generally?
    Using multiple 'set' command does not work fpr hotspot points at the moment:

    only the following conventional code works:

    best regards,
    Oliver

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!