• 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] Problem with my CustomText function.

Status
Not open for further replies.
Level 2
Joined
Aug 31, 2008
Messages
22
Hi everyone.
I decided to move from GUI to JASS and created these little functions :
JASS:
function ColorRed takes string color returns real
 local real r
  if color=="red" then
 set r = 255
  else
 set r = 0
  endif
return r
endfunction
function ColorGreen takes string color returns real
 local real g
  if color=="green" then
 set g = 255
  else
 set g = 0
  endif
return g
endfunction
function ColorBlue takes string color returns real
 local real b
  if color=="blue" then
 set b = 255
  else
 set b = 0
  endif
return b
endfunction

function CustomText takes string text, location pos, real dura, string color returns nothing
    local texttag tag = CreateTextTag()
    local real red = 0
    local real green = 0
    local real blue = 0
    local string s
    
    set red = ColorRed( color )
    set green = ColorGreen( color )
    set blue = ColorBlue( color )
    set s = text + "!"
    
    call SetTextTagText(tag, s, 10)
    call SetTextTagPos(tag, GetLocationX(pos), GetLocationY(pos), 0)
    call SetTextTagVelocity(tag, 64.00, 90)
    call SetTextTagColorBJ(tag, red, green, blue, 0)
    call SetTextTagFadepoint(tag, dura - 0.25)
    call SetTextTagLifespan(tag, dura)              
    call SetTextTagPermanent(tag, false)
    set tag = null
endfunction

JassHelper tells me that everything is ok... but ... i dont know how to call my function ... i tried to write :

JASS:
    local string t = "newunit"
    local string col = "green"
    call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
    set udg_PosTest = GetUnitLoc(GetLastCreatedUnit())
    call CustomText( t, udg_PosTest, 2, col)
    call RemoveLocation( udg_PosTest )

(on a new trigger with the event : A player types "test")
But it doesnt work. The text "newunit!" doesnt appear.

Can someone help me please ?

Thanks.
 
Level 2
Joined
Aug 31, 2008
Messages
22
I added :

JASS:
call SetTextTagVisibility( tag, true )

and

JASS:
call SetTextTagColor( tag, R2I( red ), R2I( green ), R2I( blue ), 0 )
(the function demands an integer)

and it still doesnt work : /
 
Status
Not open for further replies.
Top