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

Add API to weather mod #3112

Merged
merged 1 commit into from
May 12, 2024
Merged

Add API to weather mod #3112

merged 1 commit into from
May 12, 2024

Conversation

sfan5
Copy link
Member

@sfan5 sfan5 commented Apr 10, 2024

resolves #2913, replaces #3020

Key points

  • no is_enabled/set_enabled because that's problematic with multiple mods
  • API always works, even on singlenode worlds or with enable_weather = false
    • in the latter case it does not do anything and won't interfere (by default)
  • only one way to modify behavior: by overriding

How to test

local old_get = weather.get
weather.get = function(player)
	local data = old_get(player)
	data.clouds = data.clouds or {}
	data.clouds.thickness = 0.1
	return data
end

everything is as before except that clouds are paper-thin

Copy link
Contributor

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

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

Tested, works. Code looks fine besides my one minor comment. I like the simplicity of this. The docs are in line with the rest of game_api.txt, but formatted a bit weirdly if you view them as Markdown (for example the spacing used for delimiting will just be collapsed into a single space; the weather.get = function(player) "inline code" should probably be a subheading). Why not strive for proper Markdown formatting here?

@sfan5
Copy link
Member Author

sfan5 commented Apr 22, 2024

Why not strive for proper Markdown formatting here?

I'll try to reformat it.

Co-authored-by: Till Affeldt <t.affeldt@tu-braunschweig.de>
@sfan5 sfan5 merged commit d1ba7c3 into minetest:master May 12, 2024
2 checks passed
@sfan5 sfan5 deleted the wapi branch May 12, 2024 12:41
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.

Weather mod needs API to disable it
2 participants