HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

running code

12-09-2007, 02:26 PM#1
cohadar
I have a function like this: function test takes code func returns nothing
And I want to run the code inside the test function,
is there any way to do that except adding code as action to trigger ?
12-09-2007, 02:28 PM#2
moyack
Expand ups!!!:
12-09-2007, 02:32 PM#3
cohadar
not even close...
12-09-2007, 04:33 PM#4
hldzhuzhu
Quote:
Originally Posted by cohadar
I have a function like this: function test takes code func returns nothing
And I want to run the code inside the test function,
is there any way to do that except adding code as action to trigger ?
three ways.
you may use timer,trigger condition ,trigger event.
Collapse JASS:
function RunFunc1 takes code func returns nothing
        local trigger  temp_t=CreateTrigger()
        local conditionfunc temp_c=Condition(func)
        call  TriggerAddCondition(temp_t,temp_c)
        call  TriggerEvaluate(temp_t)
        call  DestroyTrigger(temp_t)
        call  DestroyCondition(temp_c)
        set   temp_t=null
        set   temp_c=null
endfunction


function RunFunc2 takes code func returns nothing
        local trigger  temp_t=CreateTrigger()
        call  TriggerAddAction(temp_t,func)
        call  TriggerExecute(temp_t)
        call  DestroyTrigger(temp_t)
        set   temp_t=null
endfunction

function RunFunc3 takes code func returns nothing
    local timer t=CreateTimer()
    call  TimerStart(t,0,false,func)
    set t=null
endfunction
12-09-2007, 05:01 PM#5
moyack
ohhh fuck!!! then let's do this:

Collapse JASS:
function b takes code c returns nothing
    local timer t = CreateTimer()
    call TimerStart(t, 0, false, c)
    call DestroyTimer(t)
    set t = null
endfunction
12-09-2007, 05:14 PM#6
cohadar
Using code as triggercondition is known to cause desyncs (because it does not return boolean)

Timer idea is nice but it fails because it does not immediately pass thread control to code func.

Anyone else? Vex?
12-09-2007, 09:49 PM#7
Captain Griffen
There is no other way, I think.
12-09-2007, 10:22 PM#8
PandaMine
You could possibly do it with text macros (i.e. physically replacing the code through the parser) but other then that I got nothing apart from what was mentioned with the timer and trigger
12-10-2007, 05:47 AM#9
cohadar
Well I guess triggeractions are the way to go about this.
Witch means gamecache users are fucked,
but since they are fucked by the mere fact that they are using gamecache it does not really matter
12-10-2007, 06:12 AM#10
Malf
call func.evaluate()
12-10-2007, 06:29 AM#11
cohadar
lol, why do you people post code without even trying to see if it compiles.
12-10-2007, 06:34 AM#12
Malf
Does it not compile?

If it doesn't..

Collapse JASS:
function interface Code takes nothing returns nothing

function wtf takes Code func returns nothing
    call func.evaluate()
endfunction

But I'm sure as hell it would compile, because every function is treated as an object.
12-10-2007, 06:43 AM#13
cohadar
I am not talking about function interfaces, read the first post again.
12-10-2007, 08:05 AM#14
PandaMine
Is there any reason u wanna do this?
12-10-2007, 10:27 AM#15
Malf
Quote:
Originally Posted by cohadar
I am not talking about function interfaces, read the first post again.

Excuse me sir, did you even analyze my post? It's the only goddamn sane way to do it! >_<
Collapse JASS:
function interface Code takes nothing returns nothing

function wtf takes Code func returns nothing
    call func.evaluate()
endfunction