| 02-06-2007, 10:56 PM | #1 |
I need a really good tutorial for learning to use handles, and game caches, etc.. Anyone know of a good one? |
| 02-07-2007, 09:50 AM | #2 |
Using handles is easy. Handles are just a type of object. Units, locations, etc. (every object type except integer, real, string and code) are sub-types of handles. Basically, a handle variable is a variable of handle type, for example: JASS:local handle h = <handle object> The handle variable is a 4 byte pointer. It points to a specific 'slot' in an index of handles (the same index is used for all handles, though some of the newer handles are 10 times higher, eg: lightning, I think). This applies to all types that are handles (units, etc.). Using H2I, we can get the pointer in integer form from a handle (the same 4 byte configuration but treated as if it is an integer). This is an integer unique to that handle (untill that handle no longer exists and the handle slot is recycled). This can be converted to a string, and used as a unique key in game cache storage, effectively allowing you to 'attach' things to a handle slot. Eg: JASS:local unit u = GetTriggerUnit() local string s = I2S(H2I(u)) call StoreString(udg_gc, s, "String", "Hello World!") <in another function later on> local unit u = GetTriggerUnit() local string s = I2S(H2I(u)) call BJDebugMsg(GetStoredString(udg_gc, s, "String") And "Hello World!" would be printed out. There are now alternatives which are faster, such as dynamic arrays, structs, etc. |
| 02-07-2007, 11:55 AM | #3 |
because of the lack of return bug to store references, they are not only faster but better |
| 02-07-2007, 03:04 PM | #4 |
i would seriously recommend skipping the whole handle vars phase that most new JASSers go through, just download grimoire or wehelper and start using structs. |
| 02-07-2007, 03:15 PM | #5 |
With the lack of documentation/tutorials for new users I would advice against that |
| 02-07-2007, 08:33 PM | #6 |
I see, thanks ^_^ Ive learnt c++ and jass, and html, and css, and php, and all those sorts of things, so I understand, sort of what a struct is, (the same in c++ is it?) |
| 02-07-2007, 09:42 PM | #7 | |
Quote:
agreed, even after reading all the documentation I still have no idea how it all works, and probably never will :( all I can use is the bytecode thing, error finder, and window mode/no alt tab pause |
