HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with function interfaces.

01-20-2009, 07:18 PM#1
Gwypaas
I've tried to make the user able to specify a function that runs on every timer interval but I'm having problems. If this function would work then "xxx = <value>","before evaluate", "after evaluate" and "create completed" should show up but I'm only able to see "create completed" and "before evaluate" so somehow the thread is crashing with my usage.



My code:
Collapse JASS:
library Shortened initializer Tester requires TT 

function Lol takes Shortened p returns Shortened
    call BJDebugMsg("xxx = " + R2S(p.xxx))
    return p
endfunction

function interface USF takes Shortened p returns Shortened

struct Shortened
    real xxx
    USF usf
    
    static method Callback takes nothing returns boolean
        local Shortened p = TT_GetData()
        call BJDebugMsg("before evaluate")
        set p = p.usf.evaluate(p)
        call BJDebugMsg("after evaluate")
        return false
    endmethod
    
    static method create takes nothing returns Shortened
        local Shortened p = .allocate()
        set p.xxx = 1000
        
        set p.usf = Lol(p)
        
        call BJDebugMsg("create completed")
        return p
    endmethod
endstruct

private function Tester takes nothing returns nothing
    local Shortened p = Shortened.create()
    call TT_Start(function Shortened.Callback, p)
endfunction

endlibrary


EDIT - Solved.

I had to do
Collapse JASS:
set p.usf = USF.Lol