New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Massive var-array fix (CAUTION: affects all vars) #856
Conversation
@sorlok Excellent work, as usual. I can confirm your changes conform to ECMA standards and so do GM: Studio's with the following test. myarr[1] = 50;
myarr[56] = 29;
myarr2[56] = 29;
myarr2[1] = 50;
show_message(string(array_length_1d(myarr))); // should be 57
show_message(string(array_length_1d(myarr2))); // should be 57 However I must note two discrepancies. If it is not too much to ask, can you resolve these two issues before I merge?
Otherwise your pull request is excellent and again I am ecstatic about having you as a contributor here sorlok. I can also confirm that several games continue to work as expected with your changes, including Project Mario where Project K is utilized to load collision data with arrays from d3d model files. I have also taken the liberty of documenting the new functions on the Wiki for you. |
Excellent feedback; I'll fix the warnings and add the is_array function. |
I've added is_array(), and fixed the reorder warnings. A note about is_array(); due to the way that we handle arrays, the following won't work right:
I can't think of any clever ways of fixing this right now, but normal array usage probably won't encounter these errors. |
@sorlok I expanded your test to the following, I got false, true, true in ENIGMA and true, true, false in Studio. a[0] = 10; //is_array() prints "false", since arrays with one element are considered to be scalar.
show_message(string(is_array(a)));
a[1] = 10; //Now is_array() prints "true"
show_message(string(is_array(a)));
a = 10; //is_array() still prints "true".
show_message(string(is_array(a))); I can confirm the compile errors have been resolved. If there is anything else you would like to add please do so, otherwise I am prepared to merge this pull request, the is_array() function at least partially works. Josh says ECMA compliance will side with YoYo on this one, but that's fine for now. |
After testing on several games, I am approving this commit because it meets our expectations and improves the functionality of the engine. Great work @sorlok! |
Massive var-array fix (CAUTION: affects all vars)
Excellent! If we ever decide to do a massive rewrite of variables (probably with the new parser), let me know and I'll see about fixing is_array(). |
@sorlok Alright! I don't exactly understand much about it, but yeah bets are on the new parser. |
When I have 2D array, I can't get correct size. Like so:
All combinations in array_length_2d(inputs) always either return 4 or 0. |
Interesting; I'll have a look. It's possible something got mixed up in the length code. |
Just to be more specific - I need it to return 2 at some point. I think it would at array_length_2d(inputs,0) or array_length_2d(inputs, 1). |
Just figured it out; you actually want to use the function "array_height_2d(inputs)". The function "array_length_2d()" is used for the length of the second column. Confirmed this behavior in GM:S. So we're doing the right thing already. |
This branch contains a lot of changes to arrays-inside-variables. It brings arrays closer to GM feature parity.
Please be careful with this branch; I am fairly confident in it, but it does affect the "var" class extensively.