Ok so I was able to follow your tutorial alright, but now I am having trouble adjusting this to my needs. This is my first real attempt at using functions and I keep getting the error "expected a return value" but as far as I understand it I have a return value. I'm using the fuction to try to call back the integer value a a unit variables array from the unit rather than from the variable. This is something I will have to do frequently in my map so I thought a function would be a good approach. I want the function to return an integer. I want the parameter to be a specific unit. By setting this parameter equal to a local variable I attempt then run an integer loop for all numbers 1-10. The loop is an if than statement, if local variable unit=global variable (picked integer) then return value pick integer. If I read the above correctly the function should end after it successfully makes a return so I do not see what I am doing wrong. I am calling the function with a custom script in place of an integer (gf_unitarray(EventUnitTarget()) My function is as follows:
unitarray
Options: Function
Return Type: Integer
Parameters
parameter(unit) = No Unit <Unit>
Grammar Text: unitarray(parameter(unit))
Hint Text: (None)
Custom Script Code
Local Variables
localUnit = No Unit <Unit>
Actions
Variable - Set localUnit = parameter(unit)
General - Pick each integer from 1 to 10, and do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
Nevermind, figured it out. I had to create a local integer variable, assign the picked integer to it and return the value from outside of the loop.
Ok so I was able to follow your tutorial alright, but now I am having trouble adjusting this to my needs. This is my first real attempt at using functions and I keep getting the error "expected a return value" but as far as I understand it I have a return value. I'm using the fuction to try to call back the integer value a a unit variables array from the unit rather than from the variable. This is something I will have to do frequently in my map so I thought a function would be a good approach. I want the function to return an integer. I want the parameter to be a specific unit. By setting this parameter equal to a local variable I attempt then run an integer loop for all numbers 1-10. The loop is an if than statement, if local variable unit=global variable (picked integer) then return value pick integer. If I read the above correctly the function should end after it successfully makes a return so I do not see what I am doing wrong. I am calling the function with a custom script in place of an integer (gf_unitarray(EventUnitTarget()) My function is as follows:
unitarray
Options: Function
Return Type: Integer
Parameters
parameter(unit) = No Unit <Unit>
Grammar Text: unitarray(parameter(unit))
Hint Text: (None)
Custom Script Code
Local Variables
localUnit = No Unit <Unit>
Actions
Variable - Set localUnit = parameter(unit)
General - Pick each integer from 1 to 10, and do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
localUnit == Zerglings[(Picked integer)]
Then
General - Return (Picked integer)
Else