• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] ExecuteFunc Parameter issues

Status
Not open for further replies.
Level 7
Joined
Jun 16, 2008
Messages
253
Well um. You guys probably already know that ExecuteFunc doesn't take any parameters aside from string.

I'll give you a rundown.

My trigger has an ExecuteFunc(string)

Now that string can change based upon the trigger. E.g, the string could be Function1 or Function2.

But what I want to do is transfer information, such as local integer i = 3 into the function as a paramenter.

So it would look like this.
call ExecuteFunc(string(i))

But obviously it doesn't work, because it only accepts oine paramenter, or something like that. (I don't truly know, that's my guess.)

Also, I cannot just go
call string(i)

Because that will literally look for a function called "string", instead of looking for what the string local actually equals. If you get what I mean. As far as I know, judging from what the jass compiler thingy is telling me.


And I don't know anything about handles.


Do you guys know a way to solve my above problem? Would be a huge help. If you can think of a simple solution, (i.e, doesn't involve handles or whatever) that would be fantastic!

Cheers. :D
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
No, but you can do this, which happens to be just as good, or better.

JASS:
function interface fint takes integer i, real r returns nothing

function blarg takes integer i, real r returns nothing
endfunction

function blah takes integer j, real f returns nothing
endfunction

function lolwut takes nothing returns nothing
endfunction

function CallMe takes fint func returns nothing
    call func.execute(5,4)
endfunction

function RunMe takes nothing returns nothing
    call CallMe(fint.blarg) //valid
    call CallMe(fint.blah) //valid
    call CallMe(fint.lolwut) //invalid
endfunction
 
Level 7
Joined
Jun 16, 2008
Messages
253
Gaaah! It says function interface! o_O

Lol. I don't really understand it now, but I'll take it home with me (when I get off work, which should be tomorrow afternoon), and try to figure it out. The jasshelper manual could probably help me as well, though it too is a mindboggler.

The only thing I can think of at the moment is that it sort of looks like a more flexible version of ExecuteFunc.

o_O 'fint' becomes a type thingy! Wow that is cool! I think I mostly undersatnd it now, but like I said, I'll take it home and play with my new jass toy! :D

Cheers mate!

SOLVED
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
A function interface (I'll call them fints) is pretty much a set of rules which a function has to abide by (IE parameters, and return type, but I think a fint that returns nothing can have valid functions which have a return, it just ignores that return). Any function which abides by those rules can be used as an instance of this fint.

The fint can then be treated like a function object in vJass, IE .evaluate() (unthreaded, faster, returns, can't wait), and .execute() (threaded, slower, does not return, can wait).

For more info, try here for both function objects and function interfaces.
 
Status
Not open for further replies.
Top