• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Moving Floating Text

Status
Not open for further replies.
Level 2
Joined
Apr 25, 2008
Messages
17
Im trying to make floating text that follows a unit for 1 second. I've been experimenting and testing around for a few hours now, and no luck searching google. This does makes floating text follow a unit for 1 second, the problems are:
1) following text is not very smooth, as in blinking. The lifespan of text cannot go lower than 0.03 otherwise there wont be anything.
2) seems that when the function floattext is called a second time do display a second following text, it crashes (memory access error)
3) Oh and it feels like this is very unefficient, a text tag is created every 0.01 seconds <-- cannot destroy text tag in floattextfollow function otherwise will render texttag useless "sigh"

so can anyone have a look guide me on them points? :D tyvm
JASS:
function floatTextFollow takes nothing returns nothing   
    local integer p = GetHandleInt(GetExpiredTimer(), "p")-1   
    local texttag t = CreateTextTag()
    local string s = GetHandleString(GetExpiredTimer(), "s")
    
    call SetTextTagText ( t, s , 0.02)     
	call SetTextTagColor( t ,255,220,220,255)
	if (IsPlayerInForce(GetLocalPlayer(), GetForceOfPlayer(Player(p)))) then
		call SetTextTagVisibility(t,true)
	else
		call SetTextTagVisibility(t,true)
	endif 
	call SetTextTagLifespan(t,0.03)
	call SetTextTagPermanent(t,false)  
    call SetTextTagPos( t, GetUnitX(udg_CPU), GetUnitY(udg_CPU,0)   
    //call SetTextTagFadepoint(t,1)  
	//call SetTextTagVelocity(t,0.01,.04)  
                 
endfunction

function floatText takes string s, integer p returns nothing  
    local timer t = CreateTimer()      
    
    call SetHandleInt(t, "p", p+1) 
    call SetHandleString(t, "s", s) 
   
    call TimerStart(t, 0.01, true, function floatTextFollow)
    
    call waitFunc(1)
     
    call DestroyTimer(t)
    //call FlushHandleLocals(t)
    set t = null                    
endfunction
BTW
waitFunc is a wait function, i cannot use TriggerSleepAction or PollWait outside of triggers otherwise would halt *for some reason*. waitFunc works successfully destroying the timer after 1 second
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I once made something like "breathing" and I used this to indicate how much time the player has.
Anyway, you set the time to the time you need and use a timer to move it.

JASS:
function Move takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local texttag bla = // get it with your system/global/struct
    call SetTextTagPos(bla, some x, some y, some height)
    set t = null
endfunction
function Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local texttag bla = CreateTextTag()
    call SetTextTagText(bla, "something", some height)
    // use a system to move the locel / use a global / use a struct (vJass)
    call TimerStart(t, 0.03, true, function Move)
    set t = null
endfunction
 
Level 2
Joined
Apr 25, 2008
Messages
17
bah .... it was that simple, i could have sword i tried that, haha thanks mate, removed the crashing error as well. Thats working fine, i tried to use a global array b4, but it didnt work that time, seems to work now. anyway tyvm that helped alot
 
Status
Not open for further replies.
Top