| 02-23-2008, 03:36 AM | #1 |
I'm trying to find a fast way to do: JASS:globals code func_b endglobals function callB takes nothing returns nothing call func_b endfunction function B takes nothing returns nothing call DisplayTextToForce(GetPlayersAll(), "B") endfunction function regB takes nothing returns nothing set func_b = function B endfunction I know I can create a trigger, add an action, etc, but apparently that is a very expensive operation for something so simple. Assuming I have a code variable, what is the fastest way to call it? NewGen gives no errors if I put "call func_b"... but nothing happens when it is executed. I thought of using ForForce or ForGroup but I don't know how expensive they are. I looked at all the functions that take type code ( http://jass.sourceforge.net/doc/api/...pes-code.shtml ) but I don't actually know what many of them do. |
| 02-23-2008, 04:57 AM | #2 |
Wrong forum, you want Triggers and Scripts. Also, I don't really get what you're trying to do. |
| 02-23-2008, 01:54 PM | #3 |
JASS:globals code func_b timer T = CreateTimer() endglobals function callB takes nothing returns nothing call TimerStart(T, 0.00, false, func_b) endfunction function B takes nothing returns nothing call DisplayTextToForce(GetPlayersAll(), "B") endfunction function regB takes nothing returns nothing set func_b = function B endfunction |
| 02-23-2008, 02:13 PM | #4 |
Pyrogasm has just posted the lamest possible way to do it. Just use TriggerEvaluate, it is the fastest way, it is not that expensive either, and when something is the only way, you really have no choice, do you? |
| 02-23-2008, 02:14 PM | #5 |
If you use vJASS, I think struct methods might be a good approach... JASS:// This is vJASS, requires jassnewgenpack globals myInterface caller endglobals interface myInterface method theActions takes nothing returns nothing endinterface struct myStructA extends myInterface method theActions takes nothing returns nothing call DisplayTextToForce(GetPlayersAll(), "B") endmethod endstruct function callB takes nothing returns nothing call caller.theActions() endfunction function regB takes nothing returns nothing set caller=myStructA.create() endfunction |
| 02-23-2008, 03:06 PM | #6 | ||
Quote:
If you look at the script for that you might be pleasantly surprised to see TriggerEvaluate, lol. Quote:
Understood. (How expensive is it, compared to a normal call?) |
| 02-23-2008, 04:00 PM | #7 | |
Quote:
No idea. While a function call gets slower the more functions you declare in a map, TriggerEvaluate, doesn't. |
| 02-23-2008, 07:02 PM | #8 | |
Quote:
|
| 02-23-2008, 08:36 PM | #9 |
Your very tests for the proportion between them TriggerEvaluate() / function call is 30.0 when there are few functions and 2.54 when there are a lot of functions like in the caster system map. |
| 02-23-2008, 09:45 PM | #10 | |
Quote:
|
