
Array blues.
EntityReborn opened this issue ยท 5 comments
In the case of array_get, it returns the whole array, instead of the requested item. See http://paste.thezomg.com/1785/13313967/ for a code example.
Try this... http://paste.thezomg.com/1786/13314019/
Type /test a b c
You will get:
Items: {{a, b, c}}
Items 0: {a, b, c}
First: {a, b, c}
Items: {a, b, c}
Items 0: a
First: a
Explanation... because parse_args() returns an array, by using array() around parse_args() you effectively turn @Items into an array of arrays. You can see this because of the double parenthesis around {{a, b, c}}. {a, b, c} is the first (and only) item in the @Items array. Think of it like this: {{a, b, c}, {d, e, f}, {g, h, i}}. This is actually a great way to store coordinate arrays... For example I have a script where you can /enablesigns (Basically make it so a sign can do something if there is a command on it)... To do that, I push the location of the sign onto an array, but the location itself is an array (In the format {x, y, z, World})... So I get an array that looks like {{x1, y1, z1, World}, {x2, y2, z2, World}, ... }
Looks like array_implode does the same as well. (Returns the array, not a string)
So, I'm a bit confused now, this is not a bug, correct? After looking at @Rebes script, it appears to be working as intended.