Help using Kattanas Handle variables.

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
I have to state, that I haven't used this system basically at all. So, my question would be following:

Code:
    local unit caster = GetTriggerUnit()
    local integer distanceX = 10
    local integer distanceY = 10
    call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)

How would I be going to attach the 2 integers to the local unit 'caster'?

I see the 'subject', 'name' and the 'value'. How should I replace them? Kattana's thread didn't really have good explanations.:p
 

SFilip

Gone but not forgotten
Reaction score
634
I wouldn't go for the natives the first time if I were you. Feel free to use SetHandleHandle() to simplify stuff.
But anyway in your code subject is the handle you want to attach something to. So in this case replace it with caster.
name is the string name you want to store the value under. Can be just about anything so you can use "distanceX" here (yes, with " ").
value is the integer you want stored, put distanceX here.
To attach distanceY just make another line, but make sure you use a different name there.

Reading is rather simple as well...
local integer a = GetHandleInt(caster, "distanceX")
or the native version
local integer a = GetStoredInteger(LocalVars(), I2S(H2I(caster)), "distanceX")
Of course this is assuming that you have the caster defined already...
 

Chocobo

White-Flower
Reaction score
409
H2I and I2H bug is quite enough to make a spell MUI.

Code:
    local unit caster = GetTriggerUnit()
    local integer distanceX = 10
    local integer distanceY = 10
    call StoreInteger(LocalVars(), I2S(H2I(caster)), "distanceX", distanceX)
    call StoreInteger(LocalVars(), I2S(H2I(caster)), "distanceY", distanceY)

Retrieving is :

Code:
    local unit caster = GetTriggerUnit()
    local integer distanceX = GetHandleInt(caster, "distanceX")
    local integer distanceY = GetHandleInt(caster, "distanceY")
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Thank you, both.

One last question. How can I simplify such long conditions?

Code:
function Trig_recieve_Conditions takes nothing returns boolean
    if ( not ( GetUnitUserData(GetTriggerUnit()) == 0 ) ) then
        return false
    endif
    if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'hbot' ) ) then
        return false
    endif
    return true
endfunction
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Code:
function Trig_recieve_Conditions takes nothing returns boolean
    return (GetUnitUserData(GetTriggerUnit()) == 0) and (GetOwningPlayer(GetTriggerUnit()) == Player(0)) and  (GetUnitTypeId(GetTriggerUnit()) == 'hbot')
endfunction
You might want to use a variable for the value of GetTriggerUnit()
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Thanks. Sorry for turning this into a ask-random-questions-about-JASS thread, but one of my functions just keeps showing me errors.

Code:
function damage takes nothing returns nothing
    //The damage displayed. E.g 45!
    local real text = (I2S(R2I(GetEventDamage()))+"!")
    //Font size of the floating text. E.g 10.
[COLOR="Red"]    local real fontsize = TextTagSize2Height(10.00)[/COLOR]
    //The colour % values of the floating text. Self explationary.
    local integer red = 100.00
    local integer green = 0.00
    local integer blue = 0.00
    local integer transparency = 0.00
    //velocity and the degree of the floating text. Eg. 64 towards 90 degrees.
    local real velocity = 64.00
    local real degree = 90.00
    //Fading age of the floating text.
    local real age = 4.00
    //lifespan of the floating text
    local real lifespan = 5.00
    
    local texttag e = CreateTextTag()
    local unit a = GetTriggerUnit()
    
    call SetTextTagText(e, text, fontsize)
    call SetTextTagPos(e,GetUnitX(a),GetUnitY(a),0)
    call SetTextTagColor(e,red,green,blue,transparency)       
    call SetTextTagPermanent(e, false)
    call SetTextTagVelocity(e,velocity,degree)
    call SetTextTagFadepoint(e,age)
    call SetTextTagLifespan(e,lifespan)
    
    set e = null
    set a = null
endfunction

The red line is the first error.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
The first few lines should be changed to this:
Code:
    //The damage displayed. E.g 45!
    local string text = (I2S(R2I(GetEventDamage()))+"!")
    //Font size of the floating text. E.g 10.
    local real fontsize = TextTagSize2Height(10.00)
    //The colour % values of the floating text. Self explationary.
    local integer red = 100
    local integer green = 0
    local integer blue = 0
    local integer transparency = 0
Variable text is a string and not real.
Removed decimal part of the integers (integers don't have decimals)
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
I am a total bampot, didn't even notice it. Edited the code.

But the floating text is never shown...
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Um, I probably should have noticed this earlier. The variable that you named 'transparency' is used as the alpha value for the text tag.
And 0% alpha = 100% transparency.
You want
Code:
local integer transparency = 100
and you probably should change the name of that variable to avoid more confusion :)
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Changed to 100, but still nothing. Wasn't 100% completely invisible, not the opposite?:p
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
First: Forgott about one thing, full color is 255 not 100. Same goes for your 'red'.

>Wasn't 100% completely invisible, not the opposite?
This is true for the BJ function that takes the 'transparency'. However the native one takes the alpha value as a integer between 0 and 255 where 0 is invisible.
The BJ function makes this on the transparency to get the alpha PercentTo255(100.0-transparency)
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
But if all the values are 100/255, the text should be still somewhat visible?...

Well, a new problem, with a higher priority has risen: (Damn)

How can I transfer a local unit between 2 triggers?

Code:
function Trig_Get_Unit_Within_Range_Return_Func002C takes nothing returns boolean
    return (GetUnitTypeId(GetTriggerUnit()) == 'h000') or (GetUnitTypeId(GetTriggerUnit()) == 'h001')
endfunction

function Trig_Get_Unit_Within_Range_Return_Conditions takes nothing returns boolean
    return (Trig_Get_Unit_Within_Range_Return_Func002C())
endfunction

function Trig_Get_Unit_Within_Range_Return_Actions takes nothing returns nothing
    local unit range = GetTriggerUnit()
    //...
endfunction

Code:
function Trig_Return_Oil_Conditions takes nothing returns boolean
    return GetUnitUserData(GetTriggerUnit()) == 1
endfunction

function Trig_Return_Oil_Actions takes nothing returns nothing
    local unit within = ...
    if ((GetUnitTypeId(GetTriggerUnit()) == GetUnitTypeId(within))) then
    else
    endif
endfunction

So, how?...:p
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
>how?
Globals. Or any other stuff that relies on globals (like handle vars).

>the text should be still somewhat visible?.
Yes, currently I do not know whats wrong. You can always try with stuff as setting the display to true even if I think that isn't needed.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Yes, I meant, using Kattanas Handle Variables. I know what globals are.:p

Anyway, ill test the floating text later, as it is not that important at present.
 

emjlr3

Change can be a good thing
Reaction score
395
well if that unit is going to be used instantly

just store it as a bj_ghoul[##], and use that, else ,store it to game cache, and access it later when needed

I personally use only 2 extra globals in maps I make, game cache and a multiboard, they are not really needed, everything can be done through the game cache
 
C

Capt Griffen

Guest
Game cache is very slow though. Globals are far, far faster. Even array look ups are ~5 times faster than GC.
 

emjlr3

Change can be a good thing
Reaction score
395
or right, if u don't feel like using globals
i personally don't feel like creating them, or using udg_ before anything I don't have to
yes globals are not evil, game cache is not evil either though

1*10^-10 compared to 1*10^-9 is hardly a big deal to me, nor should it be to anyone

slow if you are trying to do 50 million game cache things in a row compared to 50 million global things, but honestly, who cares if it takes 1 second longer to do that, in a real map, using real conditions, the difference is negligible, unless you are doing something retarded like 50 million things in a row
 
General chit-chat
Help Users

      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