| 12-26-2006, 05:42 PM | #1 |
Hi, well I made this function and it gives me syntax error on line 1: JASS:function RecipeMatch takes integer array recipe, integer array itOn returns boolean local boolean array used local boolean found local integer i set i = 1 loop exitwhen i > 6 set used[i] = false set i = i + 1 endloop set i = 1 loop exitwhen i > recipe[0] set found = false set j = 1 loop exitwhen j > 6 if (recipe[i] == itOn[j] and used[j] == false) then set used[j] == true set found = true endif set j = j + 1 endloop if (found == false) then return false endif set i = i + 1 endloop return true endfunction Is there any problem about passing arrays as parameters? |
| 12-26-2006, 05:51 PM | #2 |
yes, you can not take arrays, you have to split up the array into several variables. (As much as i know) Also you didn't declare j as variable. |
| 12-26-2006, 06:01 PM | #3 |
JASS doesn't have any pointers. When a function takes values, the function you're passing the values from creates a copy of them and sends them to the new function (I think). |
| 12-26-2006, 06:30 PM | #4 | |
Quote:
Jass does have pointers, depending on the variable. Integer, string, boolean and real when passed into a function are created as a copy, a handle when passed in is a pointer to it. EDIT: And so solve your problem, you cannot use arrays as as function parameter |
| 12-26-2006, 09:59 PM | #5 | |
Quote:
I'm not really disagreeing with you, your statement just struck me as a confusing way to reason about JASS. JASS doesn't have pointers in the sense that you have no 'address of' operation. Passing arrays doesn't need this, since you declare them as an object to begin with. We do have some hacks if you really need arrays, but for this application you can do fine with game cache or lists. Actually since you're limited at 6, why not use dummy units to store the recipes? Fill its inventory with the recipe items, iterate through them and check if the triggering UnitHasItem(). |
