• 🏆 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!

Floating text problem...

Status
Not open for further replies.
Level 17
Joined
Nov 13, 2006
Messages
1,814
after a time floating text doesn't appear :/
i have no ideea why screwed up the whole system, because at begining floating text work well

How it must work?
i created 26 destructible, in hashtable stored to (Inv_Slot, 100-199,0) and (Inv_Slot, 200-205,0), i want write to every slot a number with floating text.
i have function what each time when player click to a trackable (what is at destructible position) i want refresh the numbers at every destructible (3rd jass)

JASS:
function FT_Charges takes player p, string txt, real fsize, real x, real y, integer slot returns nothing
    local integer alpha = 255
    local integer pl = GetPlayerId(p) + 1
    local texttag tt = CreateTextTag( )
    if GetLocalPlayer() == p then
        call SetTextTagText( tt, txt, fsize * 0.023 )
        call SetTextTagPos( tt, x, y, 100.00 )
        call SetTextTagColor( tt, 255, 255, 255, alpha )
        call SetTextTagPermanent( tt, false )
    endif
    call SaveTextTagHandle(udg_Inv_Slots, pl+1000, slot, tt)
    set tt = null
endfunction

JASS:
function SetChargeSlotText takes integer pl, integer slot returns nothing
    local real x = LoadReal(udg_Inv_Slots, 0, 1)
    local real x1 = LoadReal(udg_Inv_Slots, slot, 1)
    local real y1 = LoadReal(udg_Inv_Slots, slot, 2)
    local real shiftX = (x1-x)/16
    local integer ilv = 0
    local integer charge = 0
    if slot < 200 then
       set ilv = LoadInteger(udg_Stat_Table, 10000*pl+slot,99)
       if ilv <=72 or ilv >= 1100 then
         set charge = R2I(LoadReal(udg_Stat_Table, 10000*pl+slot,5))
       endif
    elseif slot < 300 then
       set ilv = GetItemLevel(UnitItemInSlot(udg_Hero[pl], slot - 200))
       if ilv <=72 or ilv >= 1100 then
          set charge = GetItemCharges(UnitItemInSlot(udg_Hero[pl], slot - 200))
       endif
    endif
    if LoadTextTagHandle(udg_Inv_Slots, pl+1000, slot) != null and ilv==0 then
        call DestroyTextTag (LoadTextTagHandle(udg_Inv_Slots, pl+1000, slot))
    endif

    if charge > 0 then
       call FT_Charges(Player(pl - 1), I2S(charge), 0.7, x1+45-shiftX, y1-15, slot)
    endif
endfunction

JASS:
.....................
set n1 = 100
loop 
  exitwhen n1 == 206
  call SetChargeSlotText (pl, n1)
  if n1==119 then
    set n1 = 199
  endif
  set n1 = n1 + 1
endloop

notice: on screenshot 1st items was in that 3x2 slot then i moved to bigger inventory then after a time dont appeared the text anymore also was problem with refresh the texts.(each time when i moved something then the must be refreshed the text everywhere)

i tryed with displaying text for all player and everything was fine, slot/charges/coords was with right value in FT_Charges function
 

Attachments

  • CustomWindow2.w3x
    683.3 KB · Views: 58
  • 4.tga.jpg
    4.tga.jpg
    207.8 KB · Views: 134
Level 17
Joined
Nov 13, 2006
Messages
1,814
As ruler said, Floating Text count is limited to 100 instance per game.
BUT, if you made it local, you can have a total of 1200 instance per game - 100 Floating Text per player.

Is that game for Single-player or multiplayer ?

multiplayer but i create text for local players, also this is solved

JASS:
    if LoadTextTagHandle(udg_Inv_Slots, pl+1000, slot) != null and ilv==0 then
        call DestroyTextTag (LoadTextTagHandle(udg_Inv_Slots, pl+1000, slot))
    endif

=========>>>>

JASS:
    if LoadTextTagHandle(udg_Inv_Slots, pl+1000, slot) != null  then
        call DestroyTextTag (LoadTextTagHandle(udg_Inv_Slots, pl+1000, slot))
    endif

and i rewrote the calls so now

JASS:
function SetChargesText takes integer pl returns nothing
    local real x
    local real x1
    local real y1
    local real shiftX
    local integer ilv
    local integer charge
    local integer i = 100
    local texttag tt
    loop
        exitwhen i == 206
        set x = LoadReal(udg_Inv_Slots, 0, 1)
        set x1 = LoadReal(udg_Inv_Slots, i, 1) + 45
        set y1 = LoadReal(udg_Inv_Slots, i, 2) - 15
        set shiftX = (x1 - x) / 16
        set ilv = 0
        set charge = 0
        if i < 200 then
            set ilv = LoadInteger(udg_Stat_Table, 10000 * pl + i, 99)
            if ilv <=72 or ilv >= 1100 then
                set charge = R2I(LoadReal(udg_Stat_Table, 10000 * pl + i, 5))
            endif
        elseif i < 300 then
            set ilv = GetItemLevel(UnitItemInSlot(udg_Hero[pl], i - 200))
            if ilv <=72 or ilv >= 1100 then
                set charge = GetItemCharges(UnitItemInSlot(udg_Hero[pl], i - 200))
            endif
        endif
        if LoadTextTagHandle(udg_Inv_Slots, pl + 1000, i) != null then
            call DestroyTextTag (LoadTextTagHandle(udg_Inv_Slots, pl + 1000, i))
            call SaveTextTagHandle(udg_Inv_Slots, pl + 1000, i, null)
        endif

        if charge > 0 then
            if GetLocalPlayer() == Player(pl - 1) then
                set tt = CreateTextTag( )
                call SetTextTagText( tt, I2S(charge), 0.7 * 0.023 )
                call SetTextTagPos( tt, x1 - shiftX, y1, 100.00 )
                call SetTextTagColor( tt, 255, 255, 255, 255 )
                call SetTextTagPermanent( tt, false )
            endif
            call SaveTextTagHandle(udg_Inv_Slots, pl + 1000, i, tt)
        endif
        if i==119 then
            set i = 199
        endif
        set i = i + 1
        set tt = null
    endloop
endfunction
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
but i create text for local players

No you don't, you create the texttag on each computer and then define the text for the local player.
Just create the texttag only for the local player, it's safe and this way you will reach the hardcoded limit of 100 texttags much later, on a bonus side it's also more efficient.
And yes i know you didn't reach the limit there, but it's just a good practice.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
No you don't, you create the texttag on each computer and then define the text for the local player.
Just create the texttag only for the local player, it's safe and this way you will reach the hardcoded limit of 100 texttags much later, on a bonus side it's also more efficient.
And yes i know you didn't reach the limit there, but it's just a good practice.

y i changed it later, (hehe i allways change my codes and allways miss something :D)

[EDIT] my question is, sometimes when i use a local variable what isnt setted (so like local integer a, without = x) it cause a break in function, dont cause problem if i save the texttag to hash if i dont even created to non localplayer?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Just use the null default value.

But i don't see why you would store it if it doesn't exist in the first place, i mean store a null texttag or nothing, the result will be the same with an hashtable when you will try to get it, it will return null.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Just use the null default value.

But i don't see why you would store it if it doesn't exist in the first place, i mean store a null texttag or nothing, the result will be the same with an hashtable when you will try to get it, it will return null.

because i want destroy it later, and i guess i cant save to hashtable something/load and destroy the loaded textag only for localplayer without desync, thats why i save globally but create texttage locally, or dont make desync ??
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
You can set a variable, or an hashtable key in a local block, so i don't see your problem.
Nothing in your submitted code should cause a desync by itself.
But for safety just make sure you won't crash the thread because of a not initialized variable value.
Anyway a variable should always have a default value.
 
Status
Not open for further replies.
Top