| 05-14-2004, 02:01 PM | #1 |
Need a tiny bit of help...I'll try to make sense. In JASS I need to make a unique trigger name. Basically I need to create a trigger over and over again but with a number on the end to differentate between them. I have a counter (1..n) The way to create a trigger is : set gg_trg_<trigger_name> = CreateTrigger() So how do I use the variable 'counter' in the '<trigger_name>' to produce : trigger1 trigger2 trigger3 for example Can you setup an array of triggers maybe? Any help on this would be appreciated... ps The reason I want this is for fading units with a simple call call FadeUnit(<unit_id>, start, stop, time_period) This in itself is not particularly hard, just need a unique trigger for each unit. There is also a million and one uses for this sort of thing. |
| 05-14-2004, 02:46 PM | #2 |
Yes, you can have an array of triggers. The question is why you still need access to that triggers after they are created. I suggest you create the trigger on the fly in FadeUnit and then in the action function when you are finished you can destroy GetTriggeringTrigger. |
| 05-14-2004, 03:29 PM | #3 | |
Quote:
The point is not having access afterwards...the point is not to create two triggers of the same name. I might have 10/15/n units all doing this at the same time. I thought of a more elegant way to do this, but I can think of other uses for creating multiple triggers with a need for referencing so it would still be useful. The problem with just leaving it in an array is a finite amount of triggers. I wanted a better solution is all. |
| 05-14-2004, 07:30 PM | #4 |
your mistaking objects with reference identifiers. Your thinking that local trigger t=CreateTrigger() somehow means that T is trigger. And that doing local trigger t=CreateTrigger() again, means you've overwritten the old one. Thats not the case at all. The named reference identifier is merely that, a named pointer for convience so you have access to it later. Also arrays have 8192 unique indices, if you are using 8192+ units then obviously something is pretty screwy wouldn't you think? |
| 05-14-2004, 09:14 PM | #5 | |
Quote:
Cheers man, that clears up a lot actually. |
| 05-15-2004, 12:31 AM | #6 |
in case you didn't know you could also reference a handle using multiple variables, and since they are referenceing the same handle modify the handle with one modifies the other. E.g. local unit u=CreateUnit('hfoo',1,1,1) local unit copy=u call SetUnitX(copy,2) call BJDebugMsg(R2S(GetUnitX(u))) will display 2. However: Primitives do NOT work like this. Primitives use there four byte identifiers to store their values. local integer i=6 local integer j=i set j=j+1 call BJDebugMsg(I2S(i)) will print out "6" because i has not changed at all. Strings are also immutable objects, meaning that they act like primitives where as going local string s="S" local string st=s+"T" call BJDebugMsg(s) will leave the output as S, however, they are still pointed to objects. Meaning that your reference identifier is pointing to a value. Strings are very odd though, jass as an optimization will scan the already in use strings to make sure not to create new unneccessary strings meaning you can't just use strings indisciminately as any object you like as most instance identifers can be used for. |
| 05-15-2004, 02:08 PM | #7 | |
Quote:
The reason is not the upper limit but the limit you impose on yourself at compile time when the array is declared...is more what I meant. Cheers again guys, I got myself into a hole thinking that you needed to reference the trigger afterwards - just think it was exam stress... ================================================= Just read that in the jass manual, cheers wanna master this language quickly. That all makes sense and is pretty standard, except for the strings. Any recomendations for reading material... Already pulled off/referenced to : 'jass for beginners' from the tutorials section 'jass vault' http://kattana.users.whitehat.dk/browsefuncs.php 'wc3 mod forum' - more jass stuff 'jass manual' http://jass.sourceforge.net/doc/ This lot seems to be the best I can find. edit : Wow the jass vault really i quite a good place, actually reading it will save me a lot of time - a lot of things I wanna do have already been made - no need to keep reinventing the wheel. |
