using code parameters

Grundy

Ultra Cool Member
Reaction score
35
How do I make a function that has a code parameter and call that function? is it just as simple as:

JASS:

function MyFunction takes code SecondFunction returns nothing
  call SecondFunction
endfunction


I don't think that's right. How would you do it?
 

Flare

Stops copies me!
Reaction score
662
I think you need to add it using TriggerAddAction, then TriggerExecute that trigger.
Or...
JASS:
local boolexpr B = Condition (SecondFunc)
call TriggerAddCondition (SomeSingleTrigger, B)
call TriggerEvaluate (SomeSingleTrigger)
//Just make sure that SecondFunc can return a boolean, false would be best
call TriggerRemoveCondition (SomeSingleTrigger, B)
call DestroyBoolexpr (B) //Not sure if this is necessary
set b = null

since I believe triggeractions aren't able to be completely removed

Alternatively, you could add a single dummy unit to a group, then
JASS:
call ForGroup (GroupWithOneUnit, SecondFunction)


Just make sure you don't refer to EnumUnit unless you actually want to use that dummy for something ^_^
 

Artificial

Without Intelligence
Reaction score
326
You can't call code parameters. Code parameters are what you give to eg. triggers as actions, like this:
JASS:
call TriggerAddAction(trig, function Acts)
The part "function Acts" is the code part, and as you know, you just can't call functions by typing "call function Acts".

If you are able to use vJass, you can achieve what you want pretty easily:
JASS:
function interface MyInterface takes nothing returns nothing

function MyFunction takes MyInterface Secondfunction returns nothing
  call Secondfunction.evaluate()
endfunction

// Example call:
  call MyFunction(MyInterface.DoSomething)
  // DoSomething is the function you want to call
This basically does what Flare just suggested, but it looks neater and is nicer to code (at least IMO). :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top