Snippet CreateTextTagDefault

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
It is come to my attention, that a lot of people are stuck creating a default looking texttag (floating text for GUI users).

So, here it is, a function, which creates a default (like the bounty text, it moves up and gradually fades) floating text (duh)!


I hate working with percentages, so I replaced them with a "colour code" parameter, which makes this easier to use.

Comply with GUI users, one can access the created texttag via "Last created text tag".

JASS:
function CreateTextTagDefault takes string msg, string colourCode, real x, real y returns texttag
    local real vel = 64. * 0.071 / 128
    local real angle = 90. * bj_DEGTORAD
    
    set bj_lastCreatedTextTag = CreateTextTag()
    call SetTextTagText(bj_lastCreatedTextTag, colourCode + msg, 11 * .023 / 10)
    call SetTextTagPos(bj_lastCreatedTextTag, x, y, 0)
    call SetTextTagColor(bj_lastCreatedTextTag, 0, 0, 0, 255)
    call SetTextTagPermanent(bj_lastCreatedTextTag, false)
    call SetTextTagVelocity(bj_lastCreatedTextTag, vel * Cos(angle), vel * Sin(angle))
    call SetTextTagLifespan(bj_lastCreatedTextTag, 3.)
    call SetTextTagFadepoint(bj_lastCreatedTextTag, 2.)
    call SetTextTagVisibility(bj_lastCreatedTextTag, true)
    
    return bj_lastCreatedTextTag 
endfunction


A location (point) version for GUI users.

JASS:
function CreateTextTagDefaultLoc takes string msg, string colourCode, location where returns texttag
    return CreateTextTagDefault(msg, colourCode, GetLocationX(where), GetLocationY(where))
endfunction


Have fun!

:)
 

The_Kingpin

Member (Who are you and why should I care?)
Reaction score
41
Yaay! I can't wait to [del]steal[/del] use this in my map!

Can't the color code argument be omitted? You can just type it inside the message.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
What must I call, to use this? in GUI

Code:
Custom script:   call CreateTextTagDefault("hello", "|cffffcc00", 0, 0)

This creates a default looking texttag in the centre of the playable map area, saying hello.

First parameter is the message you want to display,
the second one is the colour code,
the last two are the coordinates of the position you want it to appear.
 

The_Kingpin

Member (Who are you and why should I care?)
Reaction score
41
Custom Script: call CreateTextTagDefault("+1","|cffffcc00",10,15)

EDIT: Damn.
 

Hatebreeder

So many apples
Reaction score
381
Code:
Custom script:   call CreateTextTagDefault("hello", "|cffffcc00", 0, 0)

So for the ...0,0) I must use X and Y coordinated to, lets say, define a Location of a Unit?
Or can so something like this:
CreateTextTagDefault("udg_Damage",|cffffcc00,udg_TargetUnit)
 

Trollvottel

never aging title
Reaction score
262
no, you would have to do it so:
JASS:
Custom script:   call CreateTextTagDefault("hello", "|cffffcc00", GetUnitX(udg_TargetUnit, GetUnitY(udg_TargetUnit)


or if you use a location GetLocationX and Y
 

Hatebreeder

So many apples
Reaction score
381
no, you would have to do it so:
JASS:

Custom script:   call CreateTextTagDefault("hello", "|cffffcc00", GetUnitX(udg_TargetUnit, GetUnitY(udg_TargetUnit)


or if you use a location GetLocationX and Y

Sexy :p
Ok, I see now how it works...
Great thnx to you, andrewgosu, for this System. And trollvottel for the explaination...

I am having Problems with converting an integer into a String... the function is: 'I2S' right? So,
Code:
call CreateTextTagDefault(I2S(udg_Damage), "|cffffcc00", GetUnitX(udg_TargetUnit), GetUnitY(udg_TargetUnit)
But this gives me an Syntax Error...
 

Trollvottel

never aging title
Reaction score
262
hehe its not the I2S thing


call CreateTextTagDefault(I2S(udg_Damage), "|cffffcc00", GetUnitX(udg_TargetUnit), GetUnitY(udg_TargetUnit))

then it should work
 

ReVolver

Mega Super Ultra Cool Member
Reaction score
609
We should include the site on the jass section, it's very useful.
 

Hatebreeder

So many apples
Reaction score
381
Just annother Quick Question.
I see, that there are some BJ Functions in the Main Snipplett Trigger.
Why are they there?
I thought, you should try to replace all BJ Codes with Natives... Or isn't this possible on this?
I'm a JASS noob, but I'm gonna start learning it some time in the Winter Vacation =)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top