Optional Parameters for your extension

Hello I was making an extension that consists of one expression. The expression calls for 2 parameters, one which requires a number and one which requires a string. I would like to add a third optional parameter that would return a string if it is entered into the expression, but not return an error if left empty. For now I have not found a way to make the expression not need exactly 3 parameters so I was just double checking here if that is possible and I am overlooking it or not. For a work around, entering “auto” into the field will return the default value, but I wanted to come make sure there is not something simple I am overlooking.

1 Like

Lucky,

I am going to give my response, as a classic developer of the past.

1 - use 3 parameters as you said
2 - with values returned by the function, examine specially the value of the third parameter
3 - if this string is empty then ignore it, otherwise take in account it.
You cal also verify if the string (the third param) contains good value (string or in cas of number, integer or decimal number, etc.)

You can also in addition, create a counter variable which 'll determine the number of valid passed parameters (in you case TWO if third parameter is empty)
If needed, in option, you can use a string with ordinal numbers which will contain each parameter number which are valid.

Ex: you have 6 parameters possible in your fonction and this string would contain “1346”, showin that only first, third, fourth and sixth parameters are valid.

A+
Xierra

1 Like

Thank you @Amigo54, most of what you said went right over my head but sometimes I find things will click for me later. Also it’s late so I think I will understand better after a good night sleep.

A option field would be nice. There are a few built-in events that have optional fields like the for each child, ray cast for the X, Y variable and the physics joint functions use optional joint IDs.