Hey everybody,does anybody know if it is possible to return multiple values in a ur script def() function like return[x,y,z]. It only worked for me to return one value.Thanks,Dan
you can return a list, the list must be of the same type for all list elements. You can only return numbers, poses and booleans in a list.
Thanks for the answer. So it is not possible to return more than one variable like return [Var_1, Var_2] and do something like in python [Var_1, Var_2] = function. So I have to put var_1 and var_2 in a list like var_3 = [var_1,var_1] and then return it, return var_3. But if var_1 and var_2 is a list this var_3 = [var_1,var_1] would not work. Right?
You can return the list directly but there are limited types that can be in the list. Here’s an example that would work as the values are of the same type and they are numbersdef describeCircle(radius): local circumference = 6.28*radius local area = 3.14*radius*radius return [circumference,area]endThis would not work as center is a point, either list or pose, and radius is a number so types are mismatched. def describeCircle(a,b,c): local center = findCenter(a,b,c) local radius = findRadius(a,b,c) return [center,radius]end
Never tried it but maybe it is possible to return different types by returning a list of list :smile: [[point],[value],[...]]
Thanks Matthew,I tried it the way you did. def describeCircle(radius): local circumference = 6.28*radius local area = 3.14*radius*radius return [circumference,area]endand then I tried to call/store the new variables and this didn't work.[circumference, area] = describeCircle(radius)
Yeah, it won’t spread them like that. You would have to do this. local values = describeCircle(radius)local area = values[1]local circumference = values[0]Or I could use them like this local volume = getVolumeFromAreaAndHeight(values[1], height)
bcastets said: Never tried it but maybe it is possible to return different types by returning a list of list :smile: [[point],[value],[...]] Unfortunately a list is not a supported list element type, sucks since a pose (modified list) is a supported list element type
Hey everybody,
does anybody know if it is possible to return multiple values in a ur script def() function like return[x,y,z]. It only worked for me to return one value.
Thanks,
Dan