Sorry about the non descriptive name, but I had no more space...
Ok so the problem is that when I try to add a unit group to another unit group on the second parameter of the function I can only select variables and custom scripts, no functions, no parameters, nothing.
If it matters I'm creating an action here. Here's a screenshot of the problem:
Does anyone know what I'm doing wrong here?
Thank you in advance for the help provided.
you can only add units to a variable unitgroup. all others are predefined (basically a function that returns a unitgroup). create a variable unitgroup, add the units from the first unitgroup and the units of the 2nd unitgroup.
Adding a unit group to a return value would not make sense since there would be no way to reference this group later (rvalue)
However, the fact that you cannot select parameters as destination is a weird GUI editor thing. For some reason Blizzard does not allow overwriting parameters, even though its perfectly legal in Galaxy and can make perfect sense for various scenarios.
You can get around this problem by defining a local unit group variable and initializing it with the parameter unit group. Since unit groups are complex objects the variables will just store references (pointers) to them, so if you modify your local variable you will also modify the linked unit group of the functions parameter.
The most clean way is, as ive said, defining a local variable within your function and setting its value to the passed parameter. This variable can then be used to modify the unit group because it references the same data.
Another way is to type the modified unit group in custom script to directly access the parameter (lp_<paramname>). I only recommend that in rare cases though because it can have unwanted side effects. (Script obfuscation breaking, compilation error on parameter rename etc.)
PS: Parameters are always passed by value, but all complex data types are pointers, allowing you to modify the passed data, except Strings (immutable).
Sorry about the non descriptive name, but I had no more space...
Ok so the problem is that when I try to add a unit group to another unit group on the second parameter of the function I can only select variables and custom scripts, no functions, no parameters, nothing.
If it matters I'm creating an action here. Here's a screenshot of the problem:
Does anyone know what I'm doing wrong here? Thank you in advance for the help provided.
@ShiroAisu: Go
you can only add units to a variable unitgroup. all others are predefined (basically a function that returns a unitgroup). create a variable unitgroup, add the units from the first unitgroup and the units of the 2nd unitgroup.
Adding a unit group to a return value would not make sense since there would be no way to reference this group later (rvalue)
However, the fact that you cannot select parameters as destination is a weird GUI editor thing. For some reason Blizzard does not allow overwriting parameters, even though its perfectly legal in Galaxy and can make perfect sense for various scenarios.
You can get around this problem by defining a local unit group variable and initializing it with the parameter unit group. Since unit groups are complex objects the variables will just store references (pointers) to them, so if you modify your local variable you will also modify the linked unit group of the functions parameter.
Ok thanks, I was trying to do this because I thought the parameters were passed by reference and so I thought I could change the parameter given.
What would be the best way to change the parameter that was given to the action then, should I be using a function for this?
There are two ways.
The most clean way is, as ive said, defining a local variable within your function and setting its value to the passed parameter. This variable can then be used to modify the unit group because it references the same data.
Another way is to type the modified unit group in custom script to directly access the parameter (lp_<paramname>). I only recommend that in rare cases though because it can have unwanted side effects. (Script obfuscation breaking, compilation error on parameter rename etc.)
PS: Parameters are always passed by value, but all complex data types are pointers, allowing you to modify the passed data, except Strings (immutable).
Alright, thanks, the first way works.
Solved.