• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

vJASS query...

Status
Not open for further replies.
Level 6
Joined
Sep 5, 2007
Messages
264
I'm still getting a complete grasp on vJASS.
I know how to do thing the old gamecache way, but I'm creating a struct based "ability-tracker", a single timer & array that remembers all the spells that need remembering and their stats (caster,target,etc.)

My query is:
Is it possible to use
JASS:
struct whatever
    code ability_func
endstruct

And call whatever function that var has been set to, with parameters?
IE:
JASS:
set whatever.ability_func = function SomeFunction

call whatever.ability_func(caster, target, ability_level)

I would've thought that this approach would work, but it doesn't... :sad:
 
Level 6
Joined
Sep 5, 2007
Messages
264
Interfaces???

I don't get what you mean by interfaces? :confused:

The way I've got it to work so far is:
JASS:
struct whatever
    integer execution_id = -1
endstruct

function Action_1 takes nothing returns nothing
endfunction
function Action_2 takes nothing returns nothing
endfunction

function Check takes nothing returns nothing
    if (whatever.execution_id == 1) then
        call Action_1(caster, target, ability_level)
    elseif (whatever.execution_id == 2) then
        call Action_2(caster, target, ability_level)
    endif
endfunction

Is this the only REAL way of succeeding with this? I don't really like having to loop through all the possible values to get the right one... :thumbs_down:

Blizzard made a good game, but the engine is really crap in a whole lot of different ways.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
You could always use function interfaces.

JASS:
function interface blah takes integer i, real r returns nothing
//pick whatever params you want, all funcs which are
//a subtype of this need the same param list.

function example1 takes integer i, real r returns nothing
endfunction

function example2 takes integer hi, real arr returns nothing
endfunction

function example3 takes nothing returns nothing
endfunction

struct someStruct
    blah actionFunc
endstruct

function testing takes nothing returns nothing
    local someStruct test = someStruct.create()
    set test.actionFunc = blah.example1 //valid
    set test.actionFunc = blah.example2 //also valid
    set test.actionFunc = blah.example3 //invalid
    call test.actionFunc.execute(5,3.2)//runs actionFunc
                                       //threaded and does not accept returns
    call test.actionFunc.evaluate(5,3.2)//runs actionFunc
                                        //non-threaded and accepts returns                             
endfunction
 
Level 6
Joined
Sep 5, 2007
Messages
264
Got a grasp of that...

Thanx for that...
I've got the hang of it now.

I got stuck trying to put an "endfunction" on the end of the "function interface" and it kept syntax erroring...
I've gathered that you just plain can't have one...

Thanx again...:thumbs_up:
 
Status
Not open for further replies.
Top