Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Radiation API #651
base: master
Are you sure you want to change the base?
Radiation API #651
Changes from 4 commits
3e9eb08
b9de49b
174ba17
268d7bc
930efcc
cedccb4
2309259
11f982a
0cf8159
a9e1351
9eb7d0e
8ad1f58
5b8e7fb
60b22e3
f9026bf
af6ab28
cf01860
feb853c
28a9068
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this only works on nodes that are already registered when
technic
is loaded.A few ideas to fix that:
cache_radiation_resistance
to lazily calculate the node value when neededcore.register_on_mods_loaded
or in acore.after(0, function() ??? end)
callback (first server step)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found such functions in the Minetest lua api, but I'm unsure how to use the
minetest.register_on_mods_loaded(function())
function. Do I just replace "function" withnode_radiation_resistance
, or is there more to it? I'm still quite new to all this.Edit: @DustyBagel has informed me that function is not backwards compatible with certain versions of Minetest. I don't think it's a big deal, but should we consider the
minetest.after
function instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core.register_on_mods_loaded
(core == minetest) is run after all mods are loaded. You can still usecore.override_item
if needed.Here's what I would do: loop through
core.registered_nodes
and cache the resistance values (where it is present). Afterwards,node_radiation_resistance()
could always retrieve the value (or 0) from the cache without any additional computations. That's computationally more expensive on startup, but has the lowest memory footprint in the long-run and more predictable code execution time.Changelog
0.4.16 → 5.0.0
mentions this callback. Minetest 5.0.0 is already the minimal requirement for technic, thus this is not of a concern.If functions are not mentioned in the changelog, you might as well have a look at the git blame of the
lua_api.md
line, which reveals when it was added.