| 06-20-2007, 06:56 AM | #1 |
1. How are you supposed to deal with functions that need to call each other? If function A calls function B then function B needs to be above it in order to compile. But then what if B needs to call A also? And I need to be able to pass arguments to the functions. 2. Speaking of passing arguments...Say I am creating a unit group and it needs a boolean expression "filter", so I create a function to filter which units I want. But what if I need to use variables beyond GetFilterUnit() to decide which units to pick? Do I have to use global variables or attach variables to handles or is there a way to pass local variables to the filter function? Same with the ForGroup function, do you have to use global variables with the function that ForGroup calls? |
| 06-20-2007, 07:28 AM | #2 |
1.) You can't do that normally, but you can use ExecuteFunc that can execute a function in front. 2.) ForGroup passes event responses, so you can use GetTriggerUnit() in it, same with filters. But if you have a filter in an other function where you cannot use event responses (some function that isn't "actions" function), the best way is to use globals, because the transfer is instant and you don't have to worry about MUI |
| 06-20-2007, 07:38 AM | #3 |
If function A needs to call function B and vice versa, you're kind-of screwed. You could, however, create function C which does the same as function A but is above function B in the map script. If you show me exactly what you mean, I may be able to help you out. |
| 06-20-2007, 03:46 PM | #4 |
ExecuteFunc can't pass variables can it? Plus I hear it is really slow. I guess I could use it though and use globals to transfer stuff. The situation is that I have a spell called Parasite, a debuff. If a hero dies with the Parasite buff on them the parasite will "jump" to a nearby ally of that hero if it finds one. So I have a function to periodically apply the effect of the buff (incrementally dropping the Strength of the hero) and check that the hero is alive each time it applies the effect. If the hero isn't alive it calls the other function to check for a hero to jump to. When it finds a hero it calls the original function again on the new hero. I guess now that I think about it I could just incorperate the second function entirely inside the first in this situation, but in some situations it could be annoying that you can't modularize. |
| 06-20-2007, 04:05 PM | #5 |
If you want recursion, vJass allows it to a certain extent. The .evaluate and .execute mechanics aren't as fast as a function call, but they're still faster than ExecuteFunc() and support the passing of "parameters". |
| 06-22-2007, 12:33 AM | #6 |
Thanks. I'm gonna upgrade my version of Jass Helper and use .execute because it keeps the code neater for me. |
| 06-22-2007, 12:46 AM | #7 | ||
Quote:
Quote:
|
| 08-23-2007, 12:50 PM | #8 |
*BUMP* It's stupid to make a new thread if the subject already exists. What's the difference between .evaluate and .execute? And can I use the return value with that, like this: JASS:function blabla takes nothing returns nothing local unit u = SomeFunctionThatReturnsUnit.execute() endfunction Can I call any function from the map header with .evaluate/.execute? |
| 08-23-2007, 01:25 PM | #9 | |
You could try reading the vJass documentation... http://www.wc3campaigns.net/vexorian...permanual.html Quote:
|
