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