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
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +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