Conversation
Api added with the help of Copilot AI.
"rad_resistance" group added to lead block node definitions. Playtesting required.
Lead block removed from node_resistances table.
DustyBagel
left a comment
There was a problem hiding this comment.
Seems fine. This should probably be reviewed by someone who understands how this works better though.
Greater than or equal to 0 because negative makes no sense.
The technic.register_rad_resistance function added
Unnecessary function removed.
Spaces bothered me.
The node_radiation_resistance function is only used locally.
Documented rad_resistance group.
I guess we only need the rad_resistance group?
Space caused an error for some reason?
Documented technic.register_group_resistance function
Added rad_resistance group to resistant nodes.
Technic specific node resistances moved to node definitions.
| technic.register_group_resistance("concrete", 16) | ||
| technic.register_group_resistance("tree", 3.4) | ||
| technic.register_group_resistance("uranium_block", 500) | ||
| technic.register_group_resistance("wood", 1.7) |
There was a problem hiding this comment.
Unfortunately this only works on nodes that are already registered when technic is loaded.
A few ideas to fix that:
- re-add the previous
cache_radiation_resistanceto lazily calculate the node value when needed - calculate all values either in
core.register_on_mods_loadedor in acore.after(0, function() ??? end)callback (first server step)
There was a problem hiding this comment.
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" with node_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.
core.register_on_mods_loaded (core == minetest) is run after all mods are loaded. You can still use core.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.
Why is whitespace such an issue? There's nothing there.
I thought I removed the white space already...
I think this will work?
Radiation functions moved to Radiation section.
Shouldn't the resistance cache be initialized before the node_radiation_resistance function?
Changed "rad_resistance" to "rad_resistant"
Changed "rad_resistance" group to "rad_resistant".
Changed rad_resistance group to rad_resistant. Why would anyone ever say "thumb of rule"?
Sync with Main Repository
Initialized the resistance cache inside the node_radiation_resistance function.
Radiation resistance API made with the help of Microsoft Copilot to fix #605.