Skip to content
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

Fix types of get_mapgen_setting_noiseparams #12025

Merged
merged 1 commit into from
Feb 4, 2022

Conversation

appgurueu
Copy link
Contributor

@appgurueu appgurueu commented Jan 31, 2022

Bugfix. Closes #11962, ready for review. Mainmenu noiseparam setting editing still works. @srifqi

Regarding possible breakage:

  • The documentation mentions numbers and not strings, so the old behavior was clearly a bug nobody should have relied on;
  • When passing params to setters both numbers and strings were, are and continue to be supported (by means of tonumber);
  • If somebody tonumbered the strings, that is a no-op for numbers and works as expected there;
  • If somebody performed arithmetic or called math funcs on the strings, relying on the implicit conversion Lua does, that will obviously work with numbers too;
  • And even most (all?) string operations will, due to the same implicit string-number conversion, just stringify the number;

The only thing this would break would be actual typechecks for a buggy type or trying to index the number (something like noiseparams.something:sub(...), but I suppose that hardly matters. Should it be found in the wild, it's definitely utter swinecode and on the mod authors, who should be urged to upgrade.

Also note that prior to 5.0, said getter would return numbers.

@sfan5 sfan5 added Bugfix 🐛 PRs that fix a bug @ Script API labels Jan 31, 2022
Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -517,24 +517,20 @@ end

Copy link
Contributor

@gaelysam gaelysam Feb 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm coming too late but %g string serialization needs to be applied in the previous function get_current_np_group too

Causes rounding issues in the dialogs
image

(I don't know how to make a comment outside the scope of the changes)

LoneWolfHT pushed a commit to LoneWolfHT/minetest that referenced this pull request Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Noiseparams returned to Lua contain some numbers as strings.
4 participants