|
|
|
|
Reply From: |
jgodfrey |
While you don’t show much code, this works as expected for me:
func _ready():
var abc = [1, 2, 3, 4, ["a", "b"]]
print(typeof(abc))
print(typeof(abc[2]))
print(typeof(abc[4]))
- 1st print returns
19
for the entire array (TYPE_ARRAY
)
- 2nd print returns
2
for the array value 3
(TYPE_INT
)
- 3rd print returns
19
for the subarray value (TYPE_ARRAY
)
Does that point you in the right direction?
If not, please post more code (including the array contents and the code that processes it).
Thanks alot I just replaced TYPE_ARRAY with 19 and that worked
swordofbling | 2020-11-25 17:32
That sounds really suspicious. TYPE_ARRAY
is just an enum representation of the value 19
. So, they should be absolutely interchangeable. And, with that in mind, I’d highly recommend that you use TYPE_ARRAY
instead of the value 19
.
So called magic numbers are never good to have floating around in code. If you look at that code 6 months from now, you’ll probably ask yourself what 19
means. However, if you instead see TYPE_ARRAY
there, it’ll probably make sense immediately.
Really, I think you must have done more than changed the TYPE_ARRAY
reference to 19
. Whatever those other changes were must have been the real fix. Otherwise, it doesn’t make sense to me.
Regardless, I’m glad you have it working now.
jgodfrey | 2020-11-25 18:04
That’s odd because whenever I did print(typeof(tile_positions[timeNo]) == TYPE_ARRAY) it always returned true even on the integers sections of the array that’s why it didn’t work but when I switched it to 19 in the code it started to work so I’m thinking it got confused somehow in what it was trying to check.
swordofbling | 2020-11-26 09:44