I want to pass a array of regions to my function, but obviously that's not possible without pointers. Is there any alternative? Possibly passing by value?
What about calling the function multiple times in a For N cycle, having the N region in the array as parameter?
If the function needs to do other stuff after that, just split it.
@moronsonofboron: Go
I was under the impression that there were no pointers.
@WhiskeeGX: Go
I could do that, but it's really not a clean way to do it at all...
I had another idea where I could use a global variable as buffer for the function(Have the calling trigger fill the array then have my action use the array). But that's just as ugly.
I agree with Whiskee - breaking it into a small functional component like that makes a lot of sense for most cases. Is there something in your use where breaking the actions apart doesn't work as cleanly?
If that doesn't cut it, you could use the local data table (only valid for current thread) to pass it around - similar to how Pick <Player/Unit> and Get Picked <Player/Unit> work, but in the reverse. Maybe pass a prefix to the receiving end to keep it clean.
Yeah, the problem is I want to do a bunch of things, wait for about a tenth of a second and do a few more things. If I put the wait inside my "handle region" function then it'll wait way too much and not at the right time.
well, I'm pretty sure that's possible :)
The handleRegion function would just do "something" in those regions, it's the main trigger you should put Waits into.
Can you be more specific about what's happening and the correct timing?
Each array length is a different type. If you know that your array is not going to be more than x elements, you can pass a region[max] to your function, and set the last one to null (or give the count to the function).
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I want to pass a array of regions to my function, but obviously that's not possible without pointers. Is there any alternative? Possibly passing by value?
Can't you pass a pointer-to-array accompanied by an integer that counts the number of regions in the array?
What about calling the function multiple times in a For N cycle, having the N region in the array as parameter?
If the function needs to do other stuff after that, just split it.
@moronsonofboron: Go I was under the impression that there were no pointers.
@WhiskeeGX: Go I could do that, but it's really not a clean way to do it at all...
I had another idea where I could use a global variable as buffer for the function(Have the calling trigger fill the array then have my action use the array). But that's just as ugly.
Why not? Splitting in one-purpose functions instead of having fat pieces of code is actually a clean design choice...
What I meant was something like:
you'd basically do the same thing in the function itself if you could pass a pointer as parameter :)
@JamesObscura: Go
I agree with Whiskee - breaking it into a small functional component like that makes a lot of sense for most cases. Is there something in your use where breaking the actions apart doesn't work as cleanly?
If that doesn't cut it, you could use the local data table (only valid for current thread) to pass it around - similar to how Pick <Player/Unit> and Get Picked <Player/Unit> work, but in the reverse. Maybe pass a prefix to the receiving end to keep it clean.
For Ex:
and then just grab the count and iterate over the result on the receiving end
@Nevir27: Go
Yeah, the problem is I want to do a bunch of things, wait for about a tenth of a second and do a few more things. If I put the wait inside my "handle region" function then it'll wait way too much and not at the right time.
well, I'm pretty sure that's possible :)
The handleRegion function would just do "something" in those regions, it's the main trigger you should put Waits into.
Can you be more specific about what's happening and the correct timing?
Each array length is a different type. If you know that your array is not going to be more than x elements, you can pass a region[max] to your function, and set the last one to null (or give the count to the function).