custom texttag, does this leak?

afisakov

You can change this now in User CP.
Reaction score
37
I tried my best to write this efficiently, but wanted to know
1) does it leak somewhere
2) is there a way to make it more efficient

Code:
function cconvert takes real percentage returns integer
local integer result = R2I(percentage * 2.55)
if (result < 0) then
   set result = 0
elseif (result > 255) then
   set result = 255
endif
return result
endfunction

function CreateTextunit_sec_speed takes string s, unit u, real dur,real speed,real zOffset,real size,real red,real green,real blue,real transparency returns texttag
set bj_lastCreatedTextTag=CreateTextTag()
call SetTextTagText(bj_lastCreatedTextTag,s,size*0.0023)
call SetTextTagPos(bj_lastCreatedTextTag,GetUnitX(u),GetUnitY(u),zOffset)
call SetTextTagColor(bj_lastCreatedTextTag,cconvert(red),cconvert(green),cconvert(blue),cconvert(100.0-transparency))
call SetTextTagPermanent(bj_lastCreatedTextTag,false)
call SetTextTagVelocity(bj_lastCreatedTextTag,0,speed/1803.)
call SetTextTagLifespan(bj_lastCreatedTextTag,dur)
call SetTextTagFadepoint(bj_lastCreatedTextTag,dur-.5)
return bj_lastCreatedTextTag
endfunction

function ...
if p!=Player(0) then
   set g=goldmod(g,myha[pi])
   call CreateTextunit_sec_speed("|cffFFFF00+"+I2S(g)+"|r",GetTriggerUnit(),2.5,75,0,10,0,80,80,0)
   if GetLocalPlayer()==p then
   call SetTextTagVisibility(bj_lastCreatedTextTag,true)
   else
   call SetTextTagVisibility(bj_lastCreatedTextTag,false)
   endif
   call SetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD) + g )
endif
... endfunction
 

MyPad

Member
Reaction score
0
JASS:
function cconvert takes real percentage returns integer
    local integer result = R2I(percentage * 2.55)
    if (result &lt; 0) then
       set result = 0
    elseif (result &gt; 255) then
       set result = 255
    endif
    return result
endfunction

function CreateTextunit_sec_speed takes string s, unit u, real dur,real speed,real zOffset,real size,real red,real green,real blue,real transparency returns texttag
    set bj_lastCreatedTextTag=CreateTextTag()
    call SetTextTagText(bj_lastCreatedTextTag,s,size*0.0023)
    call SetTextTagPos(bj_lastCreatedTextTag,GetUnitX(u),GetUnitY(u),zOffset)
    call SetTextTagColor(bj_lastCreatedTextTag,cconvert(red),cconvert(green),cconvert(blue),cconvert(100.0-transparency))
    call SetTextTagPermanent(bj_lastCreatedTextTag,false)
    call SetTextTagVelocity(bj_lastCreatedTextTag,0,speed/1803.)
    call SetTextTagLifespan(bj_lastCreatedTextTag,dur)
    call SetTextTagFadepoint(bj_lastCreatedTextTag,dur-.5)
    return bj_lastCreatedTextTag
endfunction

function ...
   if p!=Player(0) then
       set g=goldmod(g,myha[pi])
       call CreateTextunit_sec_speed(&quot;|cffFFFF00+&quot;+I2S(g)+&quot;|r&quot;,GetTriggerUnit(),2.5,75,0,10,0,80,80,0)
       if GetLocalPlayer()==p then
           call SetTextTagVisibility(bj_lastCreatedTextTag,true)
       else
           call SetTextTagVisibility(bj_lastCreatedTextTag,false)
       endif
       call SetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD) + g )
endif
... endfunction


This could be made more efficient by creating local text tags instead of global text tags and using the native
 

jonas

Ultra Cool Member
Reaction score
46
It's equally efficient. If your map lags it won't be because of this.

JASS:
function cconvert takes real percentage returns integer
    local integer result = R2I(percentage * 2.55)
    if (result &lt; 0) then
       set result = 0
    elseif (result &gt; 255) then
       set result = 255
    endif
    return result
endfunction

function CreateTextunit_sec_speed takes string s, unit u, real dur,real speed,real zOffset,real size,real red,real green,real blue,real transparency returns texttag
    set bj_lastCreatedTextTag=CreateTextTag()
    call SetTextTagText(bj_lastCreatedTextTag,s,size*0.0023)
    call SetTextTagPos(bj_lastCreatedTextTag,GetUnitX(u),GetUnitY(u),zOffset)
    call SetTextTagColor(bj_lastCreatedTextTag,cconvert(red),cconvert(green),cconvert(blue),cconvert(100.0-transparency))
    call SetTextTagPermanent(bj_lastCreatedTextTag,false)
    call SetTextTagVelocity(bj_lastCreatedTextTag,0,speed/1803.)
    call SetTextTagLifespan(bj_lastCreatedTextTag,dur)
    call SetTextTagFadepoint(bj_lastCreatedTextTag,dur-.5)
    return bj_lastCreatedTextTag
endfunction

function ...
   if p!=Player(0) then
       set g=goldmod(g,myha[pi])
       call CreateTextunit_sec_speed(&quot;|cffFFFF00+&quot;+I2S(g)+&quot;|r&quot;,GetTriggerUnit(),2.5,75,0,10,0,80,80,0)
       if GetLocalPlayer()==p then
           call SetTextTagVisibility(bj_lastCreatedTextTag,true)
       else
           call SetTextTagVisibility(bj_lastCreatedTextTag,false)
       endif
       call SetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD) + g )
endif
... endfunction




This could be made more efficient by creating local text tags instead of global text tags and using the native
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • jonas jonas:
    Good to see you Varine!
  • The Helper The Helper:
    Happy Sunday!
    +1
  • V-SNES V-SNES:
    Happy Sunday!
    +1
  • ToshibaNuon ToshibaNuon:
    Happy sunday!
    +2
  • The Helper The Helper:
    And its Friday!
  • The Helper The Helper:
    Happy Saturday!
    +1
  • V-SNES V-SNES:
    Happy Saturday!
  • The Helper The Helper:
    Happy Monday!
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    Happy Friday!
    +1
  • tom_mai78101 tom_mai78101:
    Starting this upcoming Thursday, I will be in Japan for 10 days.
  • tom_mai78101 tom_mai78101:
    Thursday - Friday will be my Japan arrival flight. 9 days later, on a Sunday, will be my return departure flight.
    +2
  • The Helper The Helper:
    Hope you have safe travels my friend!
    +1
  • vypur85 vypur85:
    Wow spring time in Japan is awesome. Enjoy!
  • The Helper The Helper:
    Hopefully it will be more pleasure than work
  • vypur85 vypur85:
    Recently tried out ChatGPT about WE triggering. Wow it's capable of giving a somewhat legitimate response.
  • The Helper The Helper:
    I am sure it has read all the info on the forums here
  • The Helper The Helper:
    i think triggering is just scripting and chatgpt is real good at code
  • vypur85 vypur85:
    Yeah I suppose so. It's interesting how it can explain in so much detail.
  • vypur85 vypur85:
    But yet it won't work.
  • The Helper The Helper:
    it does a bad ass job doing excel vba code it has leveled me up at my job when I deal with excel that is for sure
  • vypur85 vypur85:
    Nice! I love Excel coding as well. Has always been using Google to help me. Maybe I'll use ChatGPT next time when I need it.
  • The Helper The Helper:
    yeah whatever it puts out even if it is not perfect I can fix it and the latest version of chatgpt can create websites from pictures it will not be long until it can do that with almost all the tools
    +1

    The Helper Discord

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top