HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

A simple way to set/get "custom values" for a widget

04-14-2007, 05:55 PM#1
Troll-Brain
It's a simple function for units,destructables and items.

Collapse JASS:
function W2I takes widget W returns integer
return W
return 0
endfunction

function I2W takes integer I returns widget
return I
return null
endfunction

function SetWidgetValueX takes gamecache G, widget W, integer X, integer value returns nothing
call StoreInteger(G,I2S(X),I2S(W2I(W)),value)
endfunction

function GetWidgetValueX takes gamecache G, widget W, integer X returns integer
return GetStoredInteger(G,I2S(X),I2S(W2I(W)))
endfunction

sorry if it's not the rigth forum but i cant consider it like a system, isnt it ? xD
04-14-2007, 08:18 PM#2
iNfraNe
goddamn you're outdated :). And besides, these functions do like... nothing at all. It's like DestroyEffectBJ

And wrong too, since now you cant use FlushStoredMission on the handle (erm, widget, why widget? handle would do the job perfectly and it would work on all handles, woohoo)... all kinds of things wrong with this :)

Try looking at some older stuff of vexorian if you want a good gamecache storage system. Besides, noone uses gamecache anymore anyway.
04-14-2007, 08:21 PM#3
Captain Griffen
Ahh, the nublet even got the fields the wrong way around.

Anyway, we're now in the age of the pre-processor. Gamecache based attatchment systems are outdated - slow and unwieldy, not to mention bug prone.
04-14-2007, 08:22 PM#4
iNfraNe
There is no bug.

- The matricks

:P
04-14-2007, 09:35 PM#5
Ammorth
What is used besides GameCache? Structs? But don't structs still requires a game-cache call to attach the struct number to a handle? So technically it's still using game-cache (just 1 call instead of 10 or so).
04-14-2007, 10:16 PM#6
Captain Griffen
Quote:
Originally Posted by Ammorth
What is used besides GameCache? Structs? But don't structs still requires a game-cache call to attach the struct number to a handle? So technically it's still using game-cache (just 1 call instead of 10 or so).

You can use game cache. Or object data. Or a hash. Or TimerAttach or something for a timer.

I use unit/item user data and TimerAttach, and then game cache to attach structs to the rather less helpful objects (which is rare).
04-14-2007, 11:32 PM#7
SFilip
Or you can use the CSData method of simply storing it into an integer array. The index will be H2I(handle)-0x100000. Though it might be a good idea to check if this is larger than 8190 and if it is use a second array for instance.
04-15-2007, 02:58 AM#8
Earth-Fury
Quote:
Originally Posted by SFilip
Or you can use the CSData method of simply storing it into an integer array. The index will be H2I(handle)-0x100000. Though it might be a good idea to check if this is larger than 8190 and if it is use a second array for instance.
http://wc3campaigns.net/pastebint.ph...3ffd04408ae7e1
As the title said, credit to grim =)
04-15-2007, 03:49 AM#9
Ammorth
Wait... 0x100000 is an integer that if subtracted from an integer handle will get the handle number?

Ie: Unit A = 158739-0x100000 = 0
Unit B = 158741-0x100000 = 2
04-15-2007, 04:45 AM#10
grim001
Yes.

Quote:
Originally Posted by Earth-Fury
http://wc3campaigns.net/pastebint.ph...3ffd04408ae7e1
As the title said, credit to grim =)

This method is not limited to integers (although that is most useful for attaching structs to handles now)

you can attach anything to anything in the same method as handle vars. The only disadvantage is that if you needed multiple attachments of the same kind you'd need to declare multiples of the same type. The advantage is that this is much faster and 100% bug-free.
04-15-2007, 08:09 AM#11
MaD[Lion]
hmm, damn i just though of something :P But wont work XD

wonder if its possible to convert Trackables to Integer, and somehow destroy that memory location... maybe turn it to a location and destroy it? :P
04-15-2007, 08:55 AM#12
Troll-Brain
I don't know any programming language so ...
And this function is for people who use gui almost.
Why widget ? cause what i said i just want to recreate unlimited custom values for any widget.

If it's really useless, simply destroy this post
04-15-2007, 10:01 AM#13
Captain Griffen
Quote:
Originally Posted by MaD[Lion]
hmm, damn i just though of something :P But wont work XD

wonder if its possible to convert Trackables to Integer, and somehow destroy that memory location... maybe turn it to a location and destroy it? :P

I very much doubt it. It would try to clean it up like it was a location. Most likely wouldn't do anything, or would bug.
04-15-2007, 11:19 AM#14
iNfraNe
Quote:
Originally Posted by MaD[Lion]
hmm, damn i just though of something :P But wont work XD

wonder if its possible to convert Trackables to Integer, and somehow destroy that memory location... maybe turn it to a location and destroy it? :P
Lol, how offtopic can you get.

And no, you cant, it has been tested before. In like.. 2003
04-15-2007, 11:35 AM#15
Troll-Brain
i know the point of this topic : make laught pros