[JASS] Crash on TimerStart

Status
Not open for further replies.
Level 17
Joined
Dec 11, 2014
Messages
2,003
This is causing a crash -__-

JASS:
        static method talk takes string s, real dur, sound snd returns nothing
            local real x = 1 - (I2R(StringLength(s))*.004)
            local real y = (R2I(I2R(StringLength(s))/70) + 1)*.1
            // x and y will now create centered text

            if snd != null then // check if sound is not null
                call StartSound(snd)
                if UseSoundDur then //use sound duration instead of parameter
                    set dur = I2R(GetSoundDuration(snd))*.001
                endif
            endif

            call TimerStart(CreateTimer(), dur, false, function ClearTextMessages) //CRASHES HERE
            call DisplayTimedTextToPlayer(Player(0), x, y, dur, "\n\n\n\n\n\n" + s + "\n\n\n\n\n\n\n\n\n\n\n\n") // create centered text.
        endmethod

Any ideas on why?
 
maybe it doesnt support natives? I have never actually seen anyone try that.

Maybe change it to call your pre-defined function, that will look like this:

JASS:
function ClearTheMessages takes nothing returns nothing
    call DestroyTimer(GetExpiredTimer())
    call ClearTextMessages()
endfunction

that will prevent the timer handle from leaking as well as clearing the chat.
 
maybe it doesnt support natives? I have never actually seen anyone try that.

Maybe change it to call your pre-defined function, that will look like this:

JASS:
function ClearTheMessages takes nothing returns nothing
    call DestroyTimer(GetExpiredTimer())
    call ClearTextMessages()
endfunction

that will prevent the timer handle from leaking as well as clearing the chat.

So the code : function SomeNative will crash? Because it compiles.
 
So the code : function SomeNative will crash? Because it compiles.

That appears to be the case judging by your script.

Even though a script compiles, it can still crash on runtime. For example, if you type local player p = Player(-1), it will compile, but it'll crash ingame. Same with this. Pretty interesting. :)
 
Status
Not open for further replies.
Back
Top