Closed bell07 closed 7 years ago
depends.txt is ensured the 3d_armor is already loaded and armor.elements exist
That is correct, I have no idea why that's there. I am sure it can be safely removed, though I admit that it's not a particularly elegant solution. Shields got kinda just stuck back on following an outrage when I once tried to get rid them. There should really be a proper api for adding new armor elements.
In the shields mod at the end of init there is a resgistration in table armor.elements, implemented with delay. (https://github.com/stujones11/minetest-3d_armor/blob/master/shields/init.lua#L123) I do not see the reason for the delay, tested without and all is working as expected for me. Trough depends.txt is ensured the 3d_armor is already loaded and armor.elements exists at the shields init-time. So my proposal is to remove minetest.after(0..) and register instantly.
Trough delay other mods cannot see the membership of the shields in "usable armor" group at the init stage. I had a timing issue in smart_inventory because the inventory does cache all items groups and other classifications, using minetest.after(0..) to be sure all items are loaded. And sometimes (today each time) the shields been not available for usage :-/