• 🏆 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] Crash on TimerStart

Status
Not open for further replies.
Level 17
Joined
Dec 11, 2014
Messages
2,004
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?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
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.
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
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.
Top