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

[Snippet] TextTag

Level 5
Joined
Oct 13, 2010
Messages
84
sure allocate() method is magical but still remain a prob here!
the code doesn't works properly if all cons are true:
- The number of texttag breaks the limit
- Use the standard texttag like crit, miss, bounty and GUI texttag...
 
Last edited:
Err..

JASS:
        static method createLocal takes boolean createForPlayer returns thistype
            local thistype this = allocate(createForPlayer)
            
            set lifespan_p = 604800
            call SetTextTagVisibility(tag_p, true)
            call SetTextTagPermanent(tag_p, false)
            call TimerStart(textTagTimer_p, 604800, false, function thistype.destroyTag)
            call enqueue()
            
            return this
        endmethod

->

JASS:
        static method createLocal takes boolean createForPlayer returns thistype
            local thistype this = allocate(createForPlayer)
            
            set lifespan_p = 604800
            call SetTextTagVisibility(tag_p, createForPlayer)
            call SetTextTagPermanent(tag_p, false)
            call TimerStart(textTagTimer_p, 604800, false, function thistype.destroyTag)
            call enqueue()
            
            return this
        endmethod

?
 
JASS:
        method operator dy= takes real dy returns nothing
            set yvel_p = dy
             set angle_p = Atan2(yvel_p, xvel_p)
            set speed_p = SquareRoot(xvel_p*xvel_p + yvel_p*yvel_p)
            call SetTextTagVelocity(tag_p, xvel_p*.071/128, yvel_p*.071/128)
        endmethod

There's one extra space in front of the third line.
RUBBISH.

edit
This is a pretty good snippet, and I guess it does deserve an approval, but I'll wait just a bit for 2 reasons:

1- I don't understand if the previous post implies that there's a problem with the system, or there could be a problem.
2- I might need an opinion or two.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
The previous post implies that I thought you pointed out a problem and was then later mistaken, realizing that there was no problem. The small snippet you posted made me second guess myself, but when I looked at the code, I realized that it was correctly done and that your interpretation of how the system operates is incorrect =).


This system is also currently being used in a map. the mapper did find one bug with it, but since I fixed that bug long, long, long ago, the mapper has had 0 issues.
 
Level 5
Joined
Oct 13, 2010
Messages
84
Here is what you missed :
JASS:
        method setColor takes integer red, integer green,integer blue,integer alpha returns nothing
            set color_p.red = red
            set color_p.green = green
            set color_p.blue = blue
            set color_p.alpha = alpha
            call SetTextTagColor(tag_p, red, green, blue, alpha)
        endmethod
        method repaint takes nothing returns nothing
            call SetTextTagColor(tag_p, color_p.red, color_p.green, color_p.blue, color_p.alpha)
        endmethod

Btw, can you make it more modulous ? Or at least a simple version please!
My texttag code and many texttag code only need the way you manage local texttag.
I must to import too many code that i do NOT use :-??
 
Level 5
Joined
Oct 13, 2010
Messages
84
- here is your color field and where it's done ?
JASS:
        method operator color= takes integer hex returns nothing
            local Color color = Color.createFromHex(hex)
            
            set this.color_p.red = color.red
            set this.color_p.green = color.green
            set this.color_p.blue = color.blue
            set this.color_p.alpha = color.alpha
            
            call color.destroy()
        endmethod
- Got order wrong? No, i just do it like the native funtion
- When you paint the texttag with hex code color, you will need to execute convert algorithm. But the argb code not (cause of the native function >.<)
- My code changes color and transparent seperately !!! (you are too strict with users by forcing them to use hex code @@)

Btw, can you make it more modulous ? Or at least a simple version please!
The way you manage local texttags is impressive
However, must to import too many codes that are NOT used
And even in my case, it makes my code's slower @@
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Uh... what are you on about?

You can pass in args separately... you have access to the Color field..

JASS:
set tag.color.red = bleh
set tag.color.blue = bleh

Now.. the one thing that I did forget to do was actually set the text tag color, haha.. so I'll have to do that : (.

edit
I'll update this when I have time to change the texttag colors. For now, I have added a temporary solution called recolor.

edit
now recolors text tags properly : ).
 
Last edited:
Level 2
Joined
May 4, 2009
Messages
11
- I tested with 100 permanent instance texttags in debug mode and some non-permanent others then Overload message coming. How can i make 100 - 200 permanent texttags without that message, does it possible ?


- Texttags velocity don't work even though i tried several ways still don't.
Im making my new "TypeWar" map, so i need your help soon :(. Thanks!
Velocity make me so crazy!
Here's code
JASS:
//
            local tt TextTag
            local integer rand_i

            //...

            set rand_i = GetRandomInt(200, 255)
            set tt = TextTag.create()
            set tt.color.red = rand_i
            set tt.color.green = rand_i
            set tt.color.blue = rand_i
            set tt.color.alpha = 100
            call tt.setText("MyText", 10)
            call tt.setAnchor(Position[u], GetRandomReal(-50.,50.), GetRandomReal(-50.,50.), GetRandomReal(0.,100.))
            set tt.suspended = true
            set tt.permanent = false
            call tt.setVelocity(speed, angle)
            set tt.fadepoint = 1.
            set tt.lifespan = GetRandomReal(0.5, 2.5)
            set tt.visible = true
 
Level 2
Joined
May 4, 2009
Messages
11
Thank you guys :D
Yup, so i think it should display for local, i mean if 1 player have 10 - 20 texttags, and 8 players in total is ~160 textags, all of them are visible for allplayer then get lag. The same but texttags display is local, and each player only show 20 then doesn't get lag, right ?
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Velocity should work, it's just using this, heh

JASS:
        method setVelocity takes real speed, real angle returns nothing
            set angle_p = angle
            set speed_p = speed
            set xvel_p = speed*Cos(angle)
            set yvel_p = speed*Sin(angle)
            call SetTextTagVelocity(tag_p, xvel_p, yvel_p)
        endmethod

Notice that angle should be in radians, not degrees

edit
I see why your velocity doesn't work.. you set an anchor, lol

anchor = stay positioned on the Position
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
Texttag uses Table, CTL, StringColors, Position.

Position again uses ItemPosition, which requires AutoFly and GetItemOwner and has 4 potential and usefull expansions.

GetItemOwner uses UnitIndexer, Table and RegisterPlayerUnitEvent.

I think noone will use this resource, if he/she is not using 8 of 9 required libraries anyhow.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
UnitIndexer, Table, RegisterPlayerUnitEvent, and AutoFly are all core libraries that should be in practically all maps ;).

Position is a core library for whenever you are dealing with anchors, like this does.

CTL is core for periodic timers of .03125, which most maps have.

The only extra you may never use is StringColors, but even then, if you have any sort of UI with advanced coloring effects, you'll likely use it.

There are a set of libraries on THW that resources commonly use


CTL
UnitIndexer
Table
RegisterPlayerUnitEvent


Then for resources of type (anchor/projectiles/etc), these are commonly used

AutoFly
Position


The only non-essential (the thing you are likely to put into your map solely because of this library) is StringColors. This library supports cool coloring effects as it is one of the few text ui libraries, hence it uses StringColors. You are likely only to have 0-2 of these types of resources in your map.



My pro tip: if you are going to be using THW resources, use only THW resources. Each site has their own set of standard resources that stuff uses. If you're on wc3c, stuff will use stuff from wc3c. If you're on TH, it'll be stuff from j4l. If it's on here, it's stuff from here (mostly me since I wrote most of the core libs, but a few other people wrote a couple too, like mag with his sound library).

THW has the latest and greatest and also has way more libraries than any of the other sites, so if you are going to have to pick one, I recommend picking THW =). Sure, it doesn't currently have a bonus lib since Lua broke, but if someone fixes Lua, that can change =).
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
Two weeks ago I published a spell on THW using CTL, Dummy, DummyCaster and WorldBounds, thus I'm well aware of your work here and I appreciate it.

I've never used Autofly, since I always used Dummy for any protectiles which adds/removes 'Amrf' anyway. But you're right it is super short and good to have anyway.

I'm not familiar with Position though. I'll take a look into it later and if I feel using it is a pro I'm going to use Texttag aswell.

StringColors definitely supports some cool and unique stuff.
 
Top