Growing Text ?

Schyy

New Member
Reaction score
5
hi folks !

because i didnt found anyone who helps us with the jass scripting in our rpg i decided to learn jass :p

and here is my first question ^^

i wanna make a trigger wich shows an floating text if an hero gains a lvl
the floating text should grow very fast but it gows just every second by 1 factor

JASS:
function Trig_LvL_Up_Actions takes nothing returns nothing
local integer a=1
    call CreateTextTagUnitBJ( "LEVEL UP", GetLevelingUnit(), -50.00, 10.00, 100.00, 100.00, 0.00, 20.00 )
    loop 
    exitwhen a>20
    call SetTextTagTextBJ( GetLastCreatedTextTag(), "LEVEL UP", 10.00+a )
    call TriggerSleepAction(0.01)
    set a=a+1
    endloop
    if a==20 then
    call DestroyTextTagBJ(GetLastCreatedTextTag())
    endif
    
endfunction


thx for help
 

Viikuna

No Marlo no game.
Reaction score
265
TriggerSleepAction is very inaccurate and delay in multiplayer really fucks it up. You should use timers instead.
 

Schyy

New Member
Reaction score
5
ok thanks for ur answer

i will try it now ... but i think i have to take the loop in an extra trigger right ?
 

Schyy

New Member
Reaction score
5
i did it !!! i am so good ^^

but there is another problem now ...

it works perfectly at the start but it will be faster and faster with every lvl i gained. i think its because its not cleaned up correctly but i dont know how to do.
excuse me ^^ its my first day in jass programming ...

so here is the new code

JASS:
scope herolvlup
globals
   private integer a=1
   private timer t 
endglobals

function lvl_up_text takes nothing returns nothing
            call SetTextTagTextBJ(GetLastCreatedTextTag(), "LEVEL UP", 15.00+a )
            set a=a+1
        if a==35 then
            call DestroyTextTagBJ(GetLastCreatedTextTag())
            call DestroyTimer(t)
            set a=0
        endif
endfunction

function Trig_LvL_Up_Actions takes nothing returns nothing
    call CreateTextTagUnitBJ( "LEVEL UP", GetLevelingUnit(), 0.00, 15.00, 100.00, 100.00, 0.00, 0.00 )
    set t=CreateTimer()
    call TimerStart(t, 0.015, true, function lvl_up_text)  
endfunction

endscope

//===========================================================================
function InitTrig_LvL_Up takes nothing returns nothing
    set gg_trg_LvL_Up = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_LvL_Up, EVENT_PLAYER_HERO_LEVEL )
    call TriggerAddAction( gg_trg_LvL_Up, function Trig_LvL_Up_Actions )
endfunction


thanks for help
 

Akolyt0r

New Member
Reaction score
33
that wont be MUI ...for a MUI version you will have to attach the floating text to the timer ...e.g. with Vexorians TimerUtils ...
to attach a handle the easiest way is to put the floating text in a struct and attach the struct then, since structs can easily be casted to integers (and basically are) and you dont have to use the evil evil integer2handle typcast...

I could do it for you no problem ...but maybe you want to try it urself ?!
 

Schyy

New Member
Reaction score
5
hehe ... after trying and trying i have noted something ... i have to heroes for player red in my map and an cheat for testing that is "pick heroes of player 1 and set lvl +1"
so i think the code ive written just cant handle 2 heroes at one time because if i lvl 1 hero with tomes everything is working...
ok but ... this is my first code ive ever written in any programming language so i think it was a good start and its kinda good to put it into the trashcan

so

@Acolyt0r
thank ya very much for ur post
i didnt notice that vex´s timer utilitys are existing
thats a little funny because i have much systems of vex and never seen the timer utility before ^^ but i know that vex made very cool systems ... so i will try it
and thanks u want to do it but ure right i think i have to do such "easy" stuff myself ^^
but if u wanna help us ... we could need someone xD

@Gwypaas
thank ya for ur post i will read the thread asap ! =)

@Gwypaas

wow ... i just finished trying the testmap of this system and its very very cool
i pushed ESC around 200 times over 2 minutes :D
THX very much ! =)
 

Schyy

New Member
Reaction score
5
once again ... i could need some help plz ...

i imported the system above into my map with everything it needs (vexorian table and timerUtilitys) and i get 3 compiler errors wich say undeclared variable.

could someone plz look over the code and say me how i have to declare these variables ?
i marked the errors with /////

the code is in my map header

JASS:
//##########################
//   Zoom TextTagSize2Height
//##########################

library ZoomTextLibrary initializer Init requires TimerUtils

    globals
        public constant real TIMER_INTERVAL = 0.02
    endglobals

    function DefaultCall takes nothing returns boolean
        if ZoomedTextData.N <= 0 and ZoomedTextData.State == 0 then
            return true
        endif
        return false
    endfunction

    //==========================================================================
    globals
        timer T = null
        integer N = 0
        public keyword ZoomData
        private keyword InFinish
        ZoomData ZoomedTextData
        public ZoomData array ZoomDatas
    endglobals

    function interface ZoomCallbackFunction takes nothing returns boolean

    public struct ZoomData
        texttag Text = null
        string S = ""
        real SizeMod = 0.00
        real Size = 0.00
        integer State = 0
        real OutSize = 0.00
        real OutDur = 0.00
        real PauseDur = 0.00
        ZoomCallbackFunction ZCF
        integer N = 0

        widget W = null
        real X = 0.00
        real Y = 0.00
        integer I = 0
    endstruct

    private function H2I takes handle H returns integer
        return H
        return 0
    endfunction

    private function ZoomRepeater takes nothing returns nothing
        local integer J = -1
        local ZoomData ZD
        local boolean B
        local integer State

        loop
            set J = J+1
            exitwhen J >= N

            set ZD = ZoomDatas[J]

            set ZD.N = ZD.N - 1
            set ZD.Size = ZD.Size + ZD.SizeMod
            set ZoomedTextData = ZD
            set B = ZD.ZCF.evaluate()
            call SetTextTagText(ZD.Text, ZD.S, ZD.Size)

            if ZD.N <= 0 then
                set State = ZD.State
                if State == 0 and B then
                    call DestroyTextTag(ZD.Text)
                elseif State == 1 then
                    if ZD.PauseDur > 0.00 then
                        set ZD.State = 2
                        set ZD.N = R2I(ZD.PauseDur/TIMER_INTERVAL)
                        set ZD.SizeMod = 0.00
                    else
                        set ZD.State = 0
                        set ZD.N = R2I(ZD.OutDur/TIMER_INTERVAL)
                        set ZD.SizeMod = (ZD.OutSize-ZD.Size)/ZD.N
                    endif
                elseif State == 2 then
                    set ZD.State = 0
                    set ZD.N = R2I(ZD.OutDur/TIMER_INTERVAL)
                    set ZD.SizeMod = (ZD.OutSize-ZD.Size)/ZD.N
                endif

                if State == 0 then
                    set N = N-1
                    if N > 0 then
                        set ZoomDatas[J] = ZoomDatas[N]
                        set J = J-1
                    else
                        call PauseTimer(T)
                        call ReleaseTimer(T)
                    endif

                    call ZD.destroy()
                endif
            endif
        endloop
    endfunction

    function ZoomText takes texttag whichText, string s, real startSize, real endSize, real duration, ZoomCallbackFunction callbackCode returns ZoomData
        local ZoomData ZD = ZoomData.create()

        call SetTextTagText(whichText, s, startSize)
        if callbackCode == null then
            set callbackCode = DefaultCall   ////////////ERROR
        endif

        set ZD.Text = whichText
        set ZD.S = s
        set ZD.N = R2I(duration/TIMER_INTERVAL)
        set ZD.Size = startSize
        set ZD.SizeMod = (endSize-startSize)/ZD.N
        set ZD.ZCF = callbackCode

        set ZoomDatas[N] = ZD
        set N = N+1

        if N == 1 then
            set T = NewTimer()
            call TimerStart(T, TIMER_INTERVAL, true, function ZoomRepeater)
        endif

        return ZD
    endfunction

    function ZoomTextInOut takes texttag whichText, string s, real startSize, real zoomSize, real endSize, real zoomInDuration, real stayDuration, real zoomOutDuration, ZoomCallbackFunction callbackCode returns ZoomData
        local ZoomData ZD = ZoomData.create()

        set ZoomDatas[N] = ZD
        call SetTextTagText(whichText, s, startSize)

        if callbackCode == 0 then
            set callbackCode = DefaultCall   ////////////ERROR
        endif

        set ZD.Text = whichText
        set ZD.S = s
        set ZD.N = R2I(zoomInDuration/TIMER_INTERVAL)
        set ZD.Size = startSize
        set ZD.SizeMod = (zoomSize-startSize)/ZD.N
        set ZD.ZCF = callbackCode

        set ZD.State = 1
        set ZD.OutSize = endSize
        set ZD.OutDur = zoomOutDuration
        set ZD.PauseDur = stayDuration

        set N = N+1
        if N == 1 then
            set T = NewTimer()
            call TimerStart(T, TIMER_INTERVAL, true, function ZoomRepeater)
        endif

        return ZD
    endfunction

    private function Init takes nothing returns nothing
        set TimerData = Table.create()   ////////////ERROR
    endfunction
endlibrary
 

Akolyt0r

New Member
Reaction score
33
hmm ...when you got JassNewHelper you dont have to put them in the CustomScript Section (map header) ...you can just put them in triggers ...(create a trigger ..convert to custom text ...empty it ....paste the libraries in it ...).
Thats one cool function of JNGP, it moves script in library tags automatically to the top of the script file when compiling (well still below the globals of course).
So you dont have to use the CustomScriptSection (map header) of a map anymore at all.

Try if it works when you put every library in a separate trigger....
 

Schyy

New Member
Reaction score
5
oh cool ... i didnt know that ^^ thank ya ...

but ... it still wont work -.- ...
i realy dont know why
 

Akolyt0r

New Member
Reaction score
33
i tried a version ...of that library
i got an error aswell, but a different one ...but i fixed that one ..
whatever..
try this one:
JASS:
library ZoomTextLibrary initializer Init requires TimerUtils
//==============================================================================
    globals
        public constant real TIMER_INTERVAL = 0.02
        Table TimerData
    endglobals

    function DefaultCall takes nothing returns boolean
        if ZoomedTextData.N <= 0 and ZoomedTextData.State == 0 then
            return true
        endif
        return false
    endfunction

    //==========================================================================
    globals
        timer T = null
        integer N = 0
        public keyword ZoomData
        private keyword InFinish
        ZoomData ZoomedTextData
        public ZoomData array ZoomDatas
    endglobals

    function interface ZoomCallbackFunction takes nothing returns boolean

    public struct ZoomData
        texttag Text = null
        string S = ""
        real SizeMod = 0.00
        real Size = 0.00
        integer State = 0
        real OutSize = 0.00
        real OutDur = 0.00
        real PauseDur = 0.00
        ZoomCallbackFunction ZCF
        integer N = 0

        widget W = null
        real X = 0.00
        real Y = 0.00
        integer I = 0
    endstruct

    private function H2I takes handle H returns integer
        return H
        return 0
    endfunction

    private function ZoomRepeater takes nothing returns nothing
        local integer J = -1
        local ZoomData ZD
        local boolean B
        local integer State

        loop
            set J = J+1
            exitwhen J >= N

            set ZD = ZoomDatas[J]

            set ZD.N = ZD.N - 1
            set ZD.Size = ZD.Size + ZD.SizeMod
            set ZoomedTextData = ZD
            set B = ZD.ZCF.evaluate()
            call SetTextTagText(ZD.Text, ZD.S, ZD.Size)

            if ZD.N <= 0 then
                set State = ZD.State
                if State == 0 and B then
                    call DestroyTextTag(ZD.Text)
                elseif State == 1 then
                    if ZD.PauseDur > 0.00 then
                        set ZD.State = 2
                        set ZD.N = R2I(ZD.PauseDur/TIMER_INTERVAL)
                        set ZD.SizeMod = 0.00
                    else
                        set ZD.State = 0
                        set ZD.N = R2I(ZD.OutDur/TIMER_INTERVAL)
                        set ZD.SizeMod = (ZD.OutSize-ZD.Size)/ZD.N
                    endif
                elseif State == 2 then
                    set ZD.State = 0
                    set ZD.N = R2I(ZD.OutDur/TIMER_INTERVAL)
                    set ZD.SizeMod = (ZD.OutSize-ZD.Size)/ZD.N
                endif

                if State == 0 then
                    set N = N-1
                    if N > 0 then
                        set ZoomDatas[J] = ZoomDatas[N]
                        set J = J-1
                    else
                        call PauseTimer(T)
                        call ReleaseTimer(T)
                    endif

                    call ZD.destroy()
                endif
            endif
        endloop
    endfunction

    function ZoomText takes texttag whichText, string s, real startSize, real endSize, real duration, ZoomCallbackFunction callbackCode returns ZoomData
        local ZoomData ZD = ZoomData.create()

        call SetTextTagText(whichText, s, startSize)
        if callbackCode == null then
            set callbackCode = DefaultCall
        endif

        set ZD.Text = whichText
        set ZD.S = s
        set ZD.N = R2I(duration/TIMER_INTERVAL)
        set ZD.Size = startSize
        set ZD.SizeMod = (endSize-startSize)/ZD.N
        set ZD.ZCF = callbackCode

        set ZoomDatas[N] = ZD
        set N = N+1

        if N == 1 then
            set T = NewTimer()
            call TimerStart(T, TIMER_INTERVAL, true, function ZoomRepeater)
        endif

        return ZD
    endfunction

    function ZoomTextInOut takes texttag whichText, string s, real startSize, real zoomSize, real endSize, real zoomInDuration, real stayDuration, real zoomOutDuration, ZoomCallbackFunction callbackCode returns ZoomData
        local ZoomData ZD = ZoomData.create()

        set ZoomDatas[N] = ZD
        call SetTextTagText(whichText, s, startSize)

        if callbackCode == 0 then
            set callbackCode = DefaultCall
        endif

        set ZD.Text = whichText
        set ZD.S = s
        set ZD.N = R2I(zoomInDuration/TIMER_INTERVAL)
        set ZD.Size = startSize
        set ZD.SizeMod = (zoomSize-startSize)/ZD.N
        set ZD.ZCF = callbackCode

        set ZD.State = 1
        set ZD.OutSize = endSize
        set ZD.OutDur = zoomOutDuration
        set ZD.PauseDur = stayDuration

        set N = N+1
        if N == 1 then
            set T = NewTimer()
            call TimerStart(T, TIMER_INTERVAL, true, function ZoomRepeater)
        endif

        return ZD
    endfunction

    private function Init takes nothing returns nothing
        set TimerData = Table.create()
    endfunction
endlibrary
 

Schyy

New Member
Reaction score
5
ok this version fixed the timer variable decleration error but there are still both "set callbackCode = DefaultCall" Errors ...

Edit: tryed to copy only the 3 triggers into a new map but it still wont work ...
i post the whole code
maybe the error is in Tables or TimerUtility ?

JASS:
library ZoomTextLibrary initializer Init requires TimerUtils
//********************************************************************************
//* ZoomTextLibrary
//* ------------
//*
//* This library requires TimerUtils (either flavor) and Table, both by Vexorian:
//*     - TimerUtils: <a href="http://www.wc3campaigns.net/showthread.php?t=101322" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://www.wc3campaigns.net/showthread.php?t=101322</a>
//*
//* The purpose of this library is to provide an easy way to make zooming TextTags
//* Example: local texttag TT = CreateTextTag()
//*          call SetTextTagPosUnit(TT, GetTriggerUnit(), 50.00)
//*          call ZoomTextInOut(TT, &quot;Sweet!&quot;, 0.005, 0.05, 0.00, 0.50, 1.50, 0.30, MyFunc)
//*
//* Explanation of Things:
//*   ZoomText
//*      This function zooms a texttag from size X to size Y over Z seconds; it does not zoom in and out,
//*      but rather only one of the two
//*      However, it can perform both: endsize &gt; startsize = in, endsize &lt; startsize = out
//*
//*      whichText: the texttag you want to zoom (created by the user, not this library) 
//*      s: the string you want the texttag to display (because to set the height you must also set its text)
//*      startSize: the starting size of the text (NOT a font size, see TextTagSize2Height in Blizzard.j)
//*      endSize: the ending size of the zoom
//*      duration: the length of time over which this zoom is to take place; because of how the system works, this and any
//*                other duration-related arguments will only be accurate to the nearest TIMER_INTERVAL, rounded down
//*      callbackCode: the function that is called each iteration of the timer; it is called before sizing the texttag
//*
//*                    It must conform to this: function interface ZoomCallbackFunction takes nothing returns boolean
//*
//*                    - When using this argument you MUST do this (don&#039;t add the word &quot;function&quot;): &lt;YourFuncName&gt;
//*                    - Because .evaluate is used, this function may not have waits or use GetTriggeringTrigger()
//*                    - If the function returns true, the texttag is destroyed (no matter its state); if false, it is not
//*                    - If not destroyed, doing so at a later time is the responsibility of the user
//*                    - If this argument is &#039;0&#039; (without the apostrophes), then the DefaultCall function will be called
//*                    - The relevant ZoomData is automatically destroyed and need not be dealt with in this function
//*      returns ZoomData: this is the ZoomData associated with this zooming instance, so that some arguments may
//*                        be modified by the user
//*
//*   ZoomTextInOut
//*       This function zooms a texttag from size X to size Y, then down to size Z, taking A seconds to zoom to Y,
//*       B seconds paused at Y, and C seconds to zoom to Z
//*
//*       whichText: see above
//*       s: see above
//*       startSize: see above
//*       endSize: see above
//*       zoomSize: size Y in the above description
//*       zoomInDuration: time A in the above description
//*       stayDuration: time B in the above description
//*       zoomOutDuration: time C in the above description
//*       callbackCode: see above; however, this is only called at the end of time C, and nowhere else
//*       returns ZoomData: see above
//*
//*   DefaultCall
//*       This function is the default function if callbackCode is &#039;null&#039;; you can set it to whatever you want,
//*       but remember that this system does not destroy the texttags by default
//*
//*   ZoomData
//*       This is the struct used by the system to store all of the relevant zooming data
//*       Any of these members may be modified in a callback function, at the risk of the user
//*       This struct is public so you can use it if you need it
//*
//*       Text: the texttag that is being zoomed
//*       S: the string that the texttag will have
//*       SizeMod: how much the size is changing by each interation
//*       Size: the current size of the texttag
//*       State: whether or not this texttag is in the process of zooming in before zooming out and/or is paused (0, 1, and 2)
//*       Outsize: the final ending size of the texttag (will not affect ending size if changed, this is utility)
//*       OutDur: how long the second zoom lasts, if called with ZoomTextInOut
//*       PauseDur: how long its size will be paused, if called with ZoomTextInOut
//*       ZCF: the current function evaluated each iteration)
//*       U: a generic unit variable that you can use (for instance in the callback)
//*       X: a generic real variable that you can use (for instance in the callback)
//*       Y: a generic real variable that you can use (for instance in the callback)
//*       I: a generic integer variable that you can use (for instance in the callback)
//*
//*   ZoomedTextData
//*       In any function used for the callback (and functions that it calls), this is the relevant ZoomData
//*       After any sort of a wait, this is 0 because the ZoomData is automatically destroyed
//********************************************************************************


//==============================================================================
    globals
        public constant real TIMER_INTERVAL = 0.02
        Table TimerData
    endglobals

    function DefaultCall takes nothing returns boolean
        if ZoomedTextData.N &lt;= 0 and ZoomedTextData.State == 0 then
            return true
        endif
        return false
    endfunction

    //==========================================================================
    globals
        timer T = null
        integer N = 0
        public keyword ZoomData
        private keyword InFinish
        ZoomData ZoomedTextData
        public ZoomData array ZoomDatas
    endglobals

    function interface ZoomCallbackFunction takes nothing returns boolean

    public struct ZoomData
        texttag Text = null
        string S = &quot;&quot;
        real SizeMod = 0.00
        real Size = 0.00
        integer State = 0
        real OutSize = 0.00
        real OutDur = 0.00
        real PauseDur = 0.00
        ZoomCallbackFunction ZCF
        integer N = 0

        widget W = null
        real X = 0.00
        real Y = 0.00
        integer I = 0
    endstruct

    private function H2I takes handle H returns integer
        return H
        return 0
    endfunction

    private function ZoomRepeater takes nothing returns nothing
        local integer J = -1
        local ZoomData ZD
        local boolean B
        local integer State

        loop
            set J = J+1
            exitwhen J &gt;= N

            set ZD = ZoomDatas[J]

            set ZD.N = ZD.N - 1
            set ZD.Size = ZD.Size + ZD.SizeMod
            set ZoomedTextData = ZD
            set B = ZD.ZCF.evaluate()
            call SetTextTagText(ZD.Text, ZD.S, ZD.Size)

            if ZD.N &lt;= 0 then
                set State = ZD.State
                if State == 0 and B then
                    call DestroyTextTag(ZD.Text)
                elseif State == 1 then
                    if ZD.PauseDur &gt; 0.00 then
                        set ZD.State = 2
                        set ZD.N = R2I(ZD.PauseDur/TIMER_INTERVAL)
                        set ZD.SizeMod = 0.00
                    else
                        set ZD.State = 0
                        set ZD.N = R2I(ZD.OutDur/TIMER_INTERVAL)
                        set ZD.SizeMod = (ZD.OutSize-ZD.Size)/ZD.N
                    endif
                elseif State == 2 then
                    set ZD.State = 0
                    set ZD.N = R2I(ZD.OutDur/TIMER_INTERVAL)
                    set ZD.SizeMod = (ZD.OutSize-ZD.Size)/ZD.N
                endif

                if State == 0 then
                    set N = N-1
                    if N &gt; 0 then
                        set ZoomDatas[J] = ZoomDatas[N]
                        set J = J-1
                    else
                        call PauseTimer(T)
                        call ReleaseTimer(T)
                    endif

                    call ZD.destroy()
                endif
            endif
        endloop
    endfunction

    function ZoomText takes texttag whichText, string s, real startSize, real endSize, real duration, ZoomCallbackFunction callbackCode returns ZoomData
        local ZoomData ZD = ZoomData.create()

        call SetTextTagText(whichText, s, startSize)
        if callbackCode == null then
            set callbackCode = DefaultCall
        endif

        set ZD.Text = whichText
        set ZD.S = s
        set ZD.N = R2I(duration/TIMER_INTERVAL)
        set ZD.Size = startSize
        set ZD.SizeMod = (endSize-startSize)/ZD.N
        set ZD.ZCF = callbackCode

        set ZoomDatas[N] = ZD
        set N = N+1

        if N == 1 then
            set T = NewTimer()
            call TimerStart(T, TIMER_INTERVAL, true, function ZoomRepeater)
        endif

        return ZD
    endfunction

    function ZoomTextInOut takes texttag whichText, string s, real startSize, real zoomSize, real endSize, real zoomInDuration, real stayDuration, real zoomOutDuration, ZoomCallbackFunction callbackCode returns ZoomData
        local ZoomData ZD = ZoomData.create()

        set ZoomDatas[N] = ZD
        call SetTextTagText(whichText, s, startSize)

        if callbackCode == 0 then
            set callbackCode = DefaultCall
        endif

        set ZD.Text = whichText
        set ZD.S = s
        set ZD.N = R2I(zoomInDuration/TIMER_INTERVAL)
        set ZD.Size = startSize
        set ZD.SizeMod = (zoomSize-startSize)/ZD.N
        set ZD.ZCF = callbackCode

        set ZD.State = 1
        set ZD.OutSize = endSize
        set ZD.OutDur = zoomOutDuration
        set ZD.PauseDur = stayDuration

        set N = N+1
        if N == 1 then
            set T = NewTimer()
            call TimerStart(T, TIMER_INTERVAL, true, function ZoomRepeater)
        endif

        return ZD
    endfunction

    private function Init takes nothing returns nothing
        set TimerData = Table.create()
    endfunction
endlibrary


JASS:
library Table initializer init
//***************************************************************
//* Table object
//* ------------
//*
//*   set t=Table.create() - instanceates a new table object
//*   call t.destroy()     - destroys it
//*   t[1234567]           - Get value for key 1234567
//*                          (zero if not assigned previously)
//*   set t[12341]=32      - Assigning it.
//*   call t.flush(12341)  - Flushes the stored value, so it
//*                          doesn&#039;t use any more memory
//*   t.exists(32)         - Was key 32 assigned? Notice
//*                          that flush() unassigns values.
//*   call t.reset()       - Flushes the whole contents of the
//*                          Table.
//*
//*   call t.destroy()     - Does reset() and also recycles the id.
//*
//*   If you use HandleTable instead of Table, it is the same
//* but it uses handles as keys, the same with StringTable.
//*
//***************************************************************

//=============================================================
    globals
        private constant integer MAX_INSTANCES=8100 //400000

    //=========================================================
        private gamecache gc
    endglobals

    private struct GTable[MAX_INSTANCES]
        method reset takes nothing returns nothing
            call FlushStoredMission(gc,I2S(this))
        endmethod

        private method onDestroy takes nothing returns nothing
            call FlushStoredMission(gc,I2S(this))
        endmethod
    endstruct

    //Hey: Don&#039;t instanciate other people&#039;s textmacros that you are not supposed to, thanks.
    //! textmacro Table__make takes name, type, key
    struct $name$ extends GTable

        method operator [] takes $type$ key returns integer
            return GetStoredInteger(gc,I2S(this),$key$)
        endmethod

        method operator []= takes $type$ key, integer value returns nothing
            call StoreInteger(gc,I2S(this),$key$, value)
        endmethod

        method flush takes $type$ key returns nothing
            call FlushStoredInteger(gc,I2S(this),$key$)
        endmethod

        method exists takes $type$ key returns boolean
            return HaveStoredInteger(gc,I2S(this),$key$)
        endmethod

    endstruct
    //! endtextmacro



    private function H2I takes handle h returns integer
        return h
        return 0
    endfunction
    
    //! runtextmacro Table__make(&quot;Table&quot;,&quot;integer&quot;,&quot;I2S(key)&quot; )
    //! runtextmacro Table__make(&quot;StringTable&quot;,&quot;string&quot;,&quot;key&quot; )
    //! runtextmacro Table__make(&quot;HandleTable&quot;,&quot;handle&quot;,&quot;I2S(H2I(key))&quot; )

    //=============================================================
    // initialize it all.
    //
    private function init takes nothing returns nothing
        call FlushGameCache(InitGameCache(&quot;libtable.gc&quot;))
        set gc=InitGameCache(&quot;libtable.gc&quot;)
    endfunction
endlibrary


JASS:
library_once TimerUtils
//*********************************************************************
//* TimerUtils (Blue flavor)
//* ----------
//*
//*  To implement it , create a custom text trigger called TimerUtils
//* and paste the contents of this script there.
//*
//*  To copy from a map to another, copy the trigger holding this
//* library to your map.
//*
//* (requires vJass)   More scripts: htt://www.wc3campaigns.net
//*
//* For your timer needs:
//*  * Attaching
//*  * Recycling (with double-free protection)
//*
//* set t=NewTimer()      : Get a timer (alternative to CreateTimer)
//* ReleaseTimer(t)       : Relese a timer (alt to DestroyTimer)
//* SetTimerData(t,2)     : Attach value 2 to timer
//* GetTimerData(t)       : Get the timer&#039;s value.
//*                         You can assume a timer&#039;s value is 0
//*                         after NewTimer.
//*
//* Blue Flavor: Slower than the red flavor, it got a 408000 handle id
//*             limit, which means that if more than 408000 handle ids
//*             are used in your map, TimerUtils might fail, this
//*             value is quite big and it is much bigger than the 
//*             timer limit in Red flavor.
//*
//********************************************************************

//================================================================
    globals
        private constant integer MAX_HANDLE_ID_COUNT = 408000
        // values lower than 8191: very fast, but very unsafe.
        // values bigger than 8191: not that fast, the bigger the number is the slower the function gets
        // Most maps don&#039;t really need a value bigger than 50000 here, but if you are unsure, leave it
        // as the rather inflated value of 408000
    endglobals

    //=================================================================================================
    private function H2I takes handle h returns integer
        return h
        return 0
    endfunction

    //==================================================================================================
    globals
        private integer array data[MAX_HANDLE_ID_COUNT]
        private constant integer MIN_HANDLE_ID=0x100000
    endglobals

    //It is dependent on jasshelper&#039;s recent inlining optimization in order to perform correctly.
    function SetTimerData takes timer t, integer value returns nothing
        debug if(H2I(t)-MIN_HANDLE_ID&gt;=MAX_HANDLE_ID_COUNT) then
        debug     call BJDebugMsg(&quot;SetTimerData: Handle id too big, increase the max handle id count or use gamecache instead&quot;)
        debug endif
        set data[H2I(t)-MIN_HANDLE_ID]=value
    endfunction

    function GetTimerData takes timer t returns integer
        debug if(H2I(t)-MIN_HANDLE_ID&gt;=MAX_HANDLE_ID_COUNT) then
        debug     call BJDebugMsg(&quot;GetTimerData: Handle id too big, increase the max handle id count or use gamecache instead&quot;)
        debug endif
        return data[H2I(t)-MIN_HANDLE_ID]
    endfunction

    //==========================================================================================
    globals
        private timer array tT
        private integer tN = 0
        private constant integer HELD=0x28829022
        //use a totally random number here, the more improbable someone uses it, the better.
    endglobals

    //==========================================================================================
    function NewTimer takes nothing returns timer
        if (tN==0) then
            set tT[0]=CreateTimer()
        else
            set tN=tN-1
        endif
        call SetTimerData(tT[tN],0)
     return tT[tN]
    endfunction

    //==========================================================================================
    function ReleaseTimer takes timer t returns nothing
        if(t==null) then
            debug call BJDebugMsg(&quot;Warning: attempt to release a null timer&quot;)
            return
        endif
        if (tN==8191) then
            debug call BJDebugMsg(&quot;Warning: Timer stack is full, destroying timer!!&quot;)

            //stack is full, the map already has much more troubles than the chance of bug
            call DestroyTimer(t)
        else
            call PauseTimer(t)
            if(GetTimerData(t)==HELD) then
                debug call BJDebugMsg(&quot;Warning: ReleaseTimer: Double free!&quot;)
                return
            endif
            call SetTimerData(t,HELD)
            set tT[tN]=t
            set tN=tN+1
        endif    
    endfunction

endlibrary
 

Akolyt0r

New Member
Reaction score
33
no these are ok ...
i just checked ...and i have jasshelper version 9.E.0 (newer)
that should be the problem.

download the newest JNGP version > here <
 

Schyy

New Member
Reaction score
5
wohaaaa hahahahaaaa ... i cant belive it :D ...

works fine now :D

thank ya very much now i can go on with that script ... because i spend the hole nigth in terraining and now its going to be bored :D

+REP !
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top