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 API "dtime" not clarified #14758

Merged
merged 3 commits into from
Jun 22, 2024
Merged

Fix API "dtime" not clarified #14758

merged 3 commits into from
Jun 22, 2024

Conversation

Mahoyomu
Copy link
Contributor

Fix #14222

This PR documents that "dtime" in minetest.register_globalstep is the time measured in seconds in the Lua API.

This PR is Ready for Review.

How to test

Read the Lua API.

doc/lua_api.md Outdated Show resolved Hide resolved
doc/client_lua_api.md Outdated Show resolved Hide resolved
@sfan5 sfan5 added @ Documentation Improvements or additions to documentation Bugfix 🐛 PRs that fix a bug labels Jun 17, 2024
@appgurueu appgurueu added Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines Action / change needed Code still needs changes (PR) / more information requested (Issues) labels Jun 17, 2024
@Mahoyomu Mahoyomu closed this Jun 18, 2024
@Mahoyomu Mahoyomu reopened this Jun 18, 2024
@Mahoyomu
Copy link
Contributor Author

I added a change to this description like you said and I think it should be fine now

@Emojigit
Copy link
Contributor

I added a change to this description like you said and I think it should be fine now

LGTM. (Not a official review though)

doc/client_lua_api.md Outdated Show resolved Hide resolved
@Mahoyomu
Copy link
Contributor Author

How is it now

@@ -315,6 +315,7 @@ Call these functions only at load time!

* `minetest.register_globalstep(function(dtime))`
* Called every client environment step, usually interval of 0.1s
Copy link
Contributor

Choose a reason for hiding this comment

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

This is more like 1/FPS or 1/60 IIRC rather than 0.1s, no?

Copy link
Member

Choose a reason for hiding this comment

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

It's 0.09 on standalone servers and 1/fps (but at least 1/60) on the client.
This is not something we should document.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about something like "Called every client environment step (every frame, at least 60 times per second)"?

I feel this is worth documenting because accurate calculations may very well rely on the client / server step interval. It's certainly something modders should think about. Serverside, the dedicated_server_step_setting should probably be mentioned.

Copy link
Member

Choose a reason for hiding this comment

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

If your calculations rely on the number of calls then they're broken.
Neither can we guarantee that it's called 60 times per second, what I meant was "not more than 60 times a second".

Information is good but I don't want to make any promises to modders about this.

Copy link
Member

Choose a reason for hiding this comment

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

This is a trivial PR, can we just merge it?

Copy link
Contributor

@appgurueu appgurueu Jun 21, 2024

Choose a reason for hiding this comment

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

Now we can (0bebdec). Client steps being every 0.1s is just misleadingly wrong: It would lead client modders to wrongly believe that this isn't called often enough.

I don't care much about the "usually 0.1s" for server steps statement, this is roughly right considering our default settings at least. Though it might be better to mention the setting - something like "target interval is determined by dedicated_server_step setting on dedicated servers" (and usually much higher in singleplayer).

This is valuable information for modders to have because it tells them how smoothly / janky they can expect everything to run on average, if the server is not overloaded. (Though of course their code should still handle varying dtimes including lag spikes properly.)

@sfan5 sfan5 removed the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Jun 21, 2024
@sfan5 sfan5 merged commit 9ab4478 into minetest:master Jun 22, 2024
@Mahoyomu Mahoyomu deleted the doc-fix branch June 24, 2024 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix 🐛 PRs that fix a bug @ Documentation Improvements or additions to documentation One approval ✅ ◻️ Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify API "dtime"
5 participants