←  SWiSH Max4 - Components

SWiSHzone.com Support Forums

»

Changing Component Parameters At Runtime

swzone's Photo swzone 05 May 2012

Hello,

Is there any way to change component parameter at runtime ? by using code ?

I want to change the Frames parameter of fuse component using code.
also I want to change SegmentAngle of Toroid_segment component using code.

Thanks
Quote

glsmall's Photo glsmall 05 May 2012

Check the script in Scene_1
Attached File  fuse.swi (17.36K)
downloads: 27
Edited by glsmall, 05 May 2012 - 09:27 AM.
Quote

swzone's Photo swzone 05 May 2012

Hi glsmall,

Thanks for your code,

Where can I find detail info about component methodes,events and parameters ?

Regards.
Quote

swzone's Photo swzone 05 May 2012

If there is no direct way to change component parameter at runtime ,

is it possiple to create component at runtime with intilazied paramters ?
Quote

glsmall's Photo glsmall 06 May 2012

I guess I don't understand because the example I posted set the Frames parameter at run time. So I guess the simple answer is yes but it may require some scripting. Please explain and give some detail as to what you are trying to achieve.

Also, it would be good if you could post your swi so whomever may work on your request desn't have to create something from scratch. ;)
Quote

glsmall's Photo glsmall 06 May 2012

Oh, and as far as learning about components...
Quote

swzone's Photo swzone 07 May 2012

Thanks for links and tutorials ,

I can access and read the Frames parameter using fuse.parameters.Frames
But changing Frames value does not refelect to internal script ,
Yes your code is working well, but how about other compenet like SegmentAngle of Toroid_segment ? or any other compenet parameters ?
I dont want to go inside the creating script.

Regards
Quote

glsmall's Photo glsmall 07 May 2012

If the component doesn't have the functionality you need and you don't want to go in and modify the script then it may not be possible. I tend to think of the included components as a good starting point and if I need some functionality that the component isn't designed for I either modify it or design my own. I don't know what else to say. I guess I don't understand why you would not want to modify the script if it would get it to do what you want.
Quote

OutCast**NL's Photo OutCast**NL 07 May 2012

Parameters are basicly just initial values,.. and values can be changed.
The problem here is that some components refer directly to the hardcoded parameters like ie:

if (!parameters.Repeat){...

instead of storing the parameters value in a var first, like ie:

myvar = parameters.Repeat;
if (!myvar){... 

using the last scenario,
changing value of "myvar" will overwrite the value from the parameters panel.

;)
Quote