Alternative approach to unknown nodes. #1
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In https://git.minetest.land/MineClone2/mcl_devtest/src/branch/master/unknower/init.lua a random node is registered that has a 64999 in 65000 chance to become an unknown node upon the next game restart.
Instead, why not set a single designated unknown node name, and after registration set its definitions table to
nil
like so:With this approach:
How are you planning to place that node?
The purpose of this mod is to make it easier to place unknown nodes in the map. If you immediately unregister it it will not be available for placing.
Now I have thought about if it's possible to do this live i.e. set the node name, place then unregister it but that wouldn't exactly recreate the situation it's supposed to test (if it even works).
Another way might be to write unknown node data to world db by means of voxelmanipulators - haven't tried that yet at all.
But again the situation this is supposed to test is preexisting unknown nodes. (i.e. cause a mod was removed or world was ported from other mcl variants) Placing them live into a loaded world might have other consequences idk.
the uncertainty can maybe be removed by seeding random with the old value lol.
quicktesting it suggests instantly deregistering a just placed node leads to crash.
I had not actually tested anything before making the above suggestion.
Interesting that it crashes. How and where does it crash?
in builtin .. not in mcl didnt investigate where exactly. p sure this is expected behavior.
Actually it might be that new node defintions are illegal at runtime? idk
yeah. it's register_node. deleting a node from the node defs has no immediate effect (placed node remains)
registration functions can only be called at load time:
11f3f72f1c/doc/lua_api.txt (L4744)
Indeed. Perhaps my initial suggestion to directly alter the registration table was a bit too crude. But there is also
minetest.unregister_item(name)
:Does it still crash when you use that in place of directly setting
nil
in the table? It could be assigned to a chat command, like with the other functions.Yes. It didnt crash when i set the registration to nil (didnt have an immediate effect on the placed node either though).
It crashed when i tried to register the node (or the new node) again.
I mean I'll try the unregister thing but it wouldn't really help much i suppose if you can't register a new node right after (as i said the goal is to be able to place unknown nodes here).
I think my original solution is probably the best, definitely the simplest. Getting the unknown nodes "live" would be neat but i'm not sure that's even possible tbh.