• 🏆 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] Floating Text

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
JASS:
    local texttag Text = CreateTextTag()
    set udg_SP_Key = GetHandleId(udg_SP_Unit)
    set udg_SP_CurrentValue = LoadReal(udg_SP_Hashtable, udg_SP_Key, 1)
    call SetTextTagPosUnit(Text, udg_SP_Unit, 0.00)
    call SetTextTagText(Text, "udg_PlayerColor[GetConvertedPlayerId(udg_SP_Player)] + (I2S(R2I(udg_SP_CurrentValue)) + |r", 0.00)
    call SetTextTagVelocity(Text, 32.00, 32.00)
    call SetTextTagPermanent(Text, false)
    call SetTextTagLifespan(Text, 2.50)
    call SetTextTagFadepoint(Text, 1.50)
    set Text = null

There is no error compiled, but why is the Floating Text does not shows anything at all ?
At first, I thought it would be messing with the string itself, but even if I change it "Hello World", the string is not shown, why ?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
call SetTextTagText(Text, "udg_PlayerColor[GetConvertedPlayerId(udg_SP_Player)] + (I2S(R2I(udg_SP_CurrentValue)) + |r", 0.00)

"0.00" That's the size?
 
It determines the size, even though it says height. The BJ function is as follows:
JASS:
function SetTextTagTextBJ takes texttag tt, string s, real size returns nothing
    local real textHeight = TextTagSize2Height(size)

    call SetTextTagText(tt, s, textHeight)
endfunction

The TextTagSize2Height is:
JASS:
function TextTagSize2Height takes real size returns real
    return size * 0.023 / 10
endfunction

So yeah, putting 0.00 is most likely the problem, as Spartipilo said. ;)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
My code is like this now;
JASS:
    local texttag Text = CreateTextTag()
    set udg_SP_Key = GetHandleId(udg_SP_Unit)
    set udg_SP_CurrentValue = LoadReal(udg_SP_Hashtable, udg_SP_Key, 1)
    call SetTextTagPosUnit(Text, udg_SP_Unit, 0.00)
    call SetTextTagText(Text, "Hello World", 10.00 * 0.023 / 10)
    call SetTextTagVelocity(Text, 32.00, 32.00)
    call SetTextTagPermanent(Text, false)
    call SetTextTagLifespan(Text, 2.50)
    call SetTextTagFadepoint(Text, 1.50)
    set Text = null

But still, it is not shown ?
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
SetTextTagVelocity is in radians not in degrees...

JASS:
call SetTextTagPosUnit(Text, udg_SP_Unit, 0.00)
call SetTextTagText(Text, "Hello World", 10.00 * 0.023 / 10)
call SetTextTagVelocity(Text, 32.00, 32.00)
--->
JASS:
call SetTextTagPosUnit(Text, udg_SP_Unit, 150.)
call SetTextTagText(Text, "Hello World", 0.023)
call SetTextTagVelocity(Text, 0.02, 0.02)

EDIT:
and size should be adjusted to like 0.025 mentioned above
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
SetTextTagVelocity is in radians not in degrees...

JASS:
call SetTextTagPosUnit(Text, udg_SP_Unit, 0.00)
call SetTextTagText(Text, "Hello World", 10.00 * 0.023 / 10)
call SetTextTagVelocity(Text, 32.00, 32.00)
--->
JASS:
call SetTextTagPosUnit(Text, udg_SP_Unit, 150.)
call SetTextTagText(Text, "Hello World", 0.023)
call SetTextTagVelocity(Text, 0.02, 0.02)

EDIT:
and size should be adjusted to like 0.025 mentioned above

This solves it, but how do I make it like this ?
  • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Which value is 64.00 and which value is 90.00 (in JASS) ?
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
you may use SetTextTagVelocityBJ instead of SetTextTagVelocity for that, it's not so bad or;
JASS:
local texttag Text = CreateTextTag()
local real vel = 32*0.071 / 128
local real xvel = vel * Cos(90 * bj_DEGTORAD)
local real yvel = vel * Sin(90 * bj_DEGTORAD)
set udg_SP_Key = GetHandleId(udg_SP_Unit)
set udg_SP_CurrentValue = LoadReal(udg_SP_Hashtable, udg_SP_Key, 1)
call SetTextTagPosUnit(Text, udg_SP_Unit, 150)
call SetTextTagText(Text, "Hello World", 0.023)
call SetTextTagVelocity(Text, xvel, xvel)
call SetTextTagPermanent(Text, false)
call SetTextTagLifespan(Text, 2.50)
call SetTextTagFadepoint(Text, 1.50)
set Text = null
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
0.071 / 128
0.023 / 10
Where do you get these values ?

And why does this compiles an error "Expected expression"
JASS:
call SetTextTagText(Text, udg_PlayerColor[GetConvertedPlayerId(udg_SP_Player)] + (I2S(R2I(udg_SP_CurrentValue)) + "|r", 0.023)

This is the original one and works fine;
JASS:
call CreateTextTagUnitBJ( ( udg_PlayerColor[GetConvertedPlayerId(udg_SP_Player)] + ( I2S(R2I(udg_SP_CurrentValue)) + "|r" ) ), udg_SP_Unit, 0, 10, 100.00, 100.00, 100.00, 0 )
 
Status
Not open for further replies.
Top