• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] ShowText Ability

Status
Not open for further replies.
Level 10
Joined
Feb 20, 2008
Messages
448
Show text tag bug

hi im currently learning jass, so im practing on small system
here i tryed to make a spell show system in jass
some how i feel its suck any tips ?

also the text dont get removed ...


JASS:
//TESH.scrollpos=7
//TESH.alwaysfold=0
function Trig_ShowTextSystem_Actions takes nothing returns nothing
    // here we set Local variable for the trigger itself
    // like you see jass if very usefull for small system
    // here the show text will be  efficient &  mui
    local texttag ttag = CreateTextTag()
    local real speed = 80.00
    local real speed2 = 2.00
    local real angle = 90
    local real vel = TextTagSpeed2Velocity(speed2)
    local real xvel = vel * Cos(angle * bj_DEGTORAD)
    local real yvel = vel * Sin(angle * bj_DEGTORAD)
    local real textlife = 2.00
    local real offset = 7.00
    local real size = 15
    //plz note : you cant decimal in integer
    local integer red = 0
    local integer green = 100
    local integer blue = 0
    local integer trans = 0
    local integer name =GetSpellAbilityId()
    local string ID = GetObjectName(name)
    local unit Tunit = GetTriggerUnit()

    // below we do action
    set ttag = CreateTextTagUnitBJ(  ID + "!!" , Tunit, angle, size, red, green, blue, trans )
    call SetTextTagVelocity( ttag, xvel, yvel)
    call SetTextTagFadepoint( ttag, textlife)
    call SetTextTagLifespan( ttag, textlife )
    call SetTextTagPermanent( ttag, false )
    set Tunit = null
    set ttag = null
endfunction

//===========================================================================
function InitTrig_ShowTextSystem takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( t, function Trig_ShowTextSystem_Actions )
    set t = null
endfunction
 
Last edited:
the texttag dont get removed because you don't set the variable ttag to the created texttag...

I think you can use this

JASS:
//
//
//
set ttag = CreateTextTagUnitBJ( ( GetAbilityName(ID) + "!!" ), Tunit, offset, size, red, green, blue, trans )
//
//


and for the leak I don't know about the texttag but the unit local needs to be nulled.
 
it seems okay now, though I'm not sure if you need to destroy the texttag when you already set the lifespan(well at least for me I dont destroy texttags I just use the lifespan). have you tried that code already?

And I don't really think you need to set those real variables coz you only use them once and directly and they are not functions(except for the vel, xvel and yvel) so I think it would be faster to just put the numbers there instead of using the variables.(correct me if I'm wrong)
 
Level 10
Joined
Feb 20, 2008
Messages
448
yes i did try the code and it work great

and i add variable to make it clean!! its for some of my friend , he doesnt know jass at all so i want him to be able to edit as he want ^^ and e-zly

thx for the help + rep :p

p.s. since u tell it do i have to destroy text ?
 
Last edited:
Level 10
Joined
Feb 20, 2008
Messages
448
Thx for the info :) i will fix it

edit : now im tryng to figure out how i can make it without the bj function its doesnt work for now i tryed this :/

JASS:
    set ttag = GetLastCreatedTextTag()
    call SetTextTagText(ttag,  GetAbilityName(ID)  + "!!" , textHeight)
    call SetTextTagVelocity( ttag, xvel, yvel)
    call SetTextTagFadepoint( ttag, textlife)
    call SetTextTagLifespan( ttag, textlife )
    call SetTextTagPermanent( ttag, false )
    call SetTextTagPos(ttag, PosX, PosY, offset)
    call SetTextTagColor(ttag, red, green, blue, trans )
 
Last edited:
Level 10
Joined
Feb 20, 2008
Messages
448
can you post the code you tried?

i think it was something like this
JASS:
//TESH.scrollpos=7
//TESH.alwaysfold=0
function Trig_ShowTextSystem_Actions takes nothing returns nothing
    // here we set Local variable for the trigger itself
    // like you see jass if very usefull for small system
    // here the show text will be  efficient &  mui
    local texttag ttag = CreateTextTag()
    local real speed = 80.00
    local real speed2 = 2.00
    local real angle = 90
    local real vel = TextTagSpeed2Velocity(speed2)
    local real xvel = vel * Cos(angle * bj_DEGTORAD)
    local real yvel = vel * Sin(angle * bj_DEGTORAD)
    local real textlife = 2.00
    local real offset = 7.00
    local real size = 15
    //plz note : you cant decimal in integer
    local integer red = 0
    local integer green = 100
    local integer blue = 0
    local integer trans = 0
    local integer name =GetSpellAbilityId()
    local string ID = GetObjectName(name)
    local unit Tunit = GetTriggerUnit()
    local real height = TextTagSize2Height(size)
    local string text = ( ID + "!!")

    // below we do action
    call SetTextTagText(ttag,text,height)
    call SetTextTagVelocity( ttag, xvel, yvel)
    call SetTextTagFadepoint( ttag, textlife)
    call SetTextTagLifespan( ttag, textlife )
    call SetTextTagPermanent( ttag, false )
    set Tunit = null
    set ttag = null
endfunction

//===========================================================================
function InitTrig_ShowTextSystem takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( t, function Trig_ShowTextSystem_Actions )
    set t = null
endfunction
 
Status
Not open for further replies.
Top