| 12-10-2006, 08:26 PM | #1 |
Ok. I've got the script for Local Handle Vars in my custom script. The)TideHunter( gave me some triggers a while ago that used that, and he said to put in the custom script something like this: JASS:function U2I takes unit u returns integer return u return 0 endfunction So... Do I need to make one of those for every handle I intend on using this for? Eg: T2I takes timer returns integer etc. etc. My other question... How do I use this? From what little I know about this, It's supposed to allow you to use local variables from one function into another usinh gamecache, but I have no idea how. Could anyone help? |
| 12-10-2006, 08:33 PM | #2 |
You can create a script that looks like: JASS:function H2I takes handle h returns integer return h return 0 endfunction All objects (units,timers,dialog windows,etc.) are handles. So you will only need H2I. You can use it this way: JASS:function Aha takes nothing returns nothing local timer t=GetExpiredTimer() local string timerasstring=I2S(H2I(t)) local unit u=GetStoredInteger(udg_cache,timerasstring,"the_unit") call KillUnit(u) // or use apply timed life, works better. set u=null call FlushStoredMission(udg_cache,timerasstring) call DestroyTimer(t) set t=null endfunction function KillUnitTimed takes unit u, real time returns nothing // udg_cache is an initialized GameCache // I2S means integer to string local timer t=CreateTimer() local string timerasstring=I2S(H2I(t)) local integer unitasinteger=H2I(u) call StoreInteger(udg_cache,timerasstring,"the_unit",unitasinteger) call TimerStart(t,time,false,function Aha) set t=null endfunction |
| 12-10-2006, 08:38 PM | #3 |
That's in there but I wasn't sure if it covered all of them. Thanks. And after looking, I think I've sort of got it. There are a bunch of functions called like "GetHandleUnit" so I think thats how you retrieve those stored units. Hmm. I have a trigger that uses it pretty well, I'll look into it. |
| 12-10-2006, 08:40 PM | #4 |
You can use just 1 function to convert a handle to an integer, but you need a function for each handle type to convert them back. |
| 12-11-2006, 06:27 PM | #5 |
To explain why, you need to understand the extending concept. To put it simply, all units are handles, but not all handles are units. |
