• 🏆 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] filterfunc question

Status
Not open for further replies.

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Does this syntax?

JASS:
function superman takes unit u returns nothing
    call SetUnitX( u , GetUnitX( u ) + 1 )
    call SetUnitY( u , GetUnitY( u ) - 1 )
endfunction
function go takes nothing returns nothing
    local unit u = CreateUnit( Player(0) , 'hfoo' , 0,0 )
    local filterfunc f = superman(u)
    local timer t = CreateTimer()
    call TimerStart( t , 0.02 , true , f )
    set t = null
    set u = null
    set f = null
endfunction
function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterPlayerEvent( t , Player(0) , EVENT_PLAYER_END_CINEMATIC )
    call TriggerAddAction( t , function go )
    set t = null
endfunction
 
Level 13
Joined
Mar 16, 2008
Messages
941
No :D People did millions of tries of attaching stuff to timers without achieving anything. The most funny is a very small timeout that is calculated with the HandleId while I2U was still "alive", so getting the old timeout after executing gets the HandleId :D
In jass, there is not a single function that stores it's parameters. Each function with parameters is executed immediatly!
 
Level 9
Joined
Nov 28, 2008
Messages
704
I use a simple timer attaching system. You create a timerdata variable, init it like a timer and start it and everything, then you can do td.int1 = so and so, and then the function it calls takes a timerdata variable, so you can use everything there.

Not the most elegant, but a great deal easier than hashtables, IMO. Although, the system does internally use hashtables. >.>

JASS:
function funcaloid takes timerdata td returns nothing
    call BJDebugMsg(GetPlayerName(Player(td.pid)))
endfunction

function something takes nothing returns nothing
    local timerdata td = timerdata.create(funcaloid, 1, false)
    set td.pid = 1
endfunction

Would recommend making your own. If you know how function interfaces work, its an easy 30 lines of code. If you dont know, try the JassHelper Manual.
 
I'm trying to learn everything I can but my brain can only render so much at a time o_O

I started using GUI for the first time in August, my only programming experience prior being Excel, HTML and CSS ... and since then I've learned standard JASS and am just now learning the extended vJASS functions

at least you know some languages, I don't know even one (hmmm, a little bit of HTML)
 
Status
Not open for further replies.
Top