I noticed that in the return type, I could click a box saying that I was returning an array. However, I get the lovely error message (when using the custom script to return the array; gui won't even let you do it),
"Bulk copy not supported"
This makes me extremely disheartened, as I just spent 20 minutes writing a wonderful function to get up to 10 random points within a region with X amount of spacing between them...and now I can't use it.
Anyone know of a workaround to return my precious array (besides using a global variable and making a lock on that variable?)
Since pointers were removed there is no elegant way to do this. The usual approach to returning dynamic objects is to create a global array (or in this case a 2 dimentional array) and associate an index with your object.
For instance you could have the function RandPoint(int whichArray) and it would assign the 10 random points to an array RandPoints[<your points>][<which array>]. Make the second dimension large enough and reuse indices.
If you REALLY want it to be on the fly, you could do something ugly like create a unit and store the points in the unit's custom values.
oh I just brute forced it lol. And I was afraid that this was the case. I am using a global arrays for the same reason in a couple other areas, to basically use the indices as pointers. I really don't like it, and dunno what I'm going to do. In the meantime, I'm not worrying about distances, and just getting random points. who cares if 5 nukes overlap...just don't sit in the middle of this venn diagram
anyways, here's the hacked together function (I probably shouldn't've used the word "Wonderful", but at the time I was feeling pretty proud)
Edit: what language do i specify for it to view it as galaxy code? "galaxy"?
lol I guess you missed this part of my first post...
[
However, I get the lovely error message (when using the custom script to return the array; gui won't even let you do it),
Since pointers were removed there is no elegant way to do this. The usual approach to returning dynamic objects is to create a global array (or in this case a 2 dimentional array) and associate an index with your object.
For instance you could have the function RandPoint(int whichArray) and it would assign the 10 random points to an array RandPoints[<your points>][<which array>]. Make the second dimension large enough and reuse indices.
May I ask why you put the <which array> in the second dimension here? My first intuition would be to use RandPoints[ArrayPointer][PointIndex] to store each point...
array is not possible, but u can trick that if u do a virtual memory system.
Just make a long array 128x17 integer
If u want to allocate some block set last interger [16] to 1 if that block is not allocated before.
It is high level galaxy scripting.
I use it in my KryptoCode lib. ( u can see the source in my profil)
alternative:
Using player group or unit group to do that dirty stuff.
I mean player group or unit group are dynamic array, right?
it is just not easy to access them, because they are kind of sorted.
I noticed that in the return type, I could click a box saying that I was returning an array. However, I get the lovely error message (when using the custom script to return the array; gui won't even let you do it),
"Bulk copy not supported"
This makes me extremely disheartened, as I just spent 20 minutes writing a wonderful function to get up to 10 random points within a region with X amount of spacing between them...and now I can't use it.
Anyone know of a workaround to return my precious array (besides using a global variable and making a lock on that variable?)
@Kenterik: Go
Since pointers were removed there is no elegant way to do this. The usual approach to returning dynamic objects is to create a global array (or in this case a 2 dimentional array) and associate an index with your object.
For instance you could have the function RandPoint(int whichArray) and it would assign the 10 random points to an array RandPoints[<your points>][<which array>]. Make the second dimension large enough and reuse indices.
If you REALLY want it to be on the fly, you could do something ugly like create a unit and store the points in the unit's custom values.
(Curious to know how your algorithm works)
@SexLethal: Go
oh I just brute forced it lol. And I was afraid that this was the case. I am using a global arrays for the same reason in a couple other areas, to basically use the indices as pointers. I really don't like it, and dunno what I'm going to do. In the meantime, I'm not worrying about distances, and just getting random points. who cares if 5 nukes overlap...just don't sit in the middle of this venn diagram
anyways, here's the hacked together function (I probably shouldn't've used the word "Wonderful", but at the time I was feeling pretty proud)
Edit: what language do i specify for it to view it as galaxy code? "galaxy"?
@Kenterik: Go
don't think your trigger is considered galaxy tho. So probably just use
<<code>>
@Kenterik: Go
You sure this works? This should give an error when compiling/saving telling you that Galaxy doesn't allow bulk copying.
Passing arrays isn't possible. You can only use global arrays or do it some other way.
@s3rius: Go
lol I guess you missed this part of my first post... [ However, I get the lovely error message (when using the custom script to return the array; gui won't even let you do it),
"Bulk copy not supported" ]
May I ask why you put the <which array> in the second dimension here? My first intuition would be to use RandPoints[ArrayPointer][PointIndex] to store each point...
array is not possible, but u can trick that if u do a virtual memory system. Just make a long array 128x17 integer
If u want to allocate some block set last interger [16] to 1 if that block is not allocated before.
It is high level galaxy scripting. I use it in my KryptoCode lib. ( u can see the source in my profil)
alternative: Using player group or unit group to do that dirty stuff. I mean player group or unit group are dynamic array, right? it is just not easy to access them, because they are kind of sorted.