Mod Loading Hadling.
- Andrey01
- Member
- Posts: 2577
- Joined: Wed Oct 19, 2016 15:18
- GitHub: Andrey2470T
- In-game: Andrey01
- Location: Russia, Moscow
Mod Loading Hadling.
Is it possible anyhow to handle with a mod handling that what order mods should be loaded in? In my case, I want a certain mod to being loaded after all mods have been loaded.
-
- Member
- Posts: 1118
- Joined: Mon Dec 29, 2014 08:07
- Location: USA
Re: Mod Loading Hadling.
Andrey,
There is, in v5.0, a function (minetest.on_mods_loaded) that runs code after all mods have been loaded.
Not sure if this will solve your issue, but other than depending on the dependency tree, there is no sure fire way to determine or influence the order in which mods are loaded.
There is, in v5.0, a function (minetest.on_mods_loaded) that runs code after all mods have been loaded.
Not sure if this will solve your issue, but other than depending on the dependency tree, there is no sure fire way to determine or influence the order in which mods are loaded.
Re: Mod Loading Hadling.
If you add a lineAndrey01 wrote:Is it possible anyhow to handle with a mod handling that what order mods should be loaded in? In my case, I want a certain mod to being loaded after all mods have been loaded.
Code: Select all
depends = moda,modb,modc
- Andrey01
- Member
- Posts: 2577
- Joined: Wed Oct 19, 2016 15:18
- GitHub: Andrey2470T
- In-game: Andrey01
- Location: Russia, Moscow
Re: Mod Loading Hadling.
Well, that means the certain mod that I mentioned also will be loaded together with other, not separately. And there`s no a function like minetest.load_mod() that would implement loading of that mod inside minetest.register_on_mods_loaded(), as far as I know.ShadMOrdre wrote:Andrey,
There is, in v5.0, a function (minetest.on_mods_loaded) that runs code after all mods have been loaded.
Not sure if this will solve your issue, but other than depending on the dependency tree, there is no sure fire way to determine or influence the order in which mods are loaded.
This method doesn`t fit also. It`s unknown what and what amount of mods a user maintains.Yvanhoe wrote:If you add a lineAndrey01 wrote:Is it possible anyhow to handle with a mod handling that what order mods should be loaded in? In my case, I want a certain mod to being loaded after all mods have been loaded.in the mod.conf file at the root of your mod, your will only be loaded after moda, modb and modc were loaded.Code: Select all
depends = moda,modb,modc
Re: Mod Loading Hadling.
TL;DRAndrey01 wrote:there`s no a function like minetest.load_mod() that would implement loading of that mod inside minetest.register_on_mods_loaded(), as far as I know.
You need a new feature to be added to minetest to dynamically load mods.
This is non-trivial and would require a lot of work to properly sort the decency tree (and having more than one mod attempting to be loaded last would cause a race condition).
This means that it would be very buggy and cumbersome to code and maintain.
The real question here would be to know why you need your mod to be the final one loaded.
(ie are you trying to override an item definition, etc -- if that is the case then you can override the def in minetest.register_on_mods_loaded())
==================================================
Minetest does, not yet, provide any mechanism to do this.
Eg the following in mod_xyz/mod.conf:
Code: Select all
depends = moda, modb, modc
But does not, and cannot, ensure that mod_xyz is the last one loaded (after all other mods).
Really what you are asking is for an enhancement / feature to be added to minetest that allows the dynamic loading of a mod -- which incidentally would require another mod to be installed to define the body of the minetest.register_on_mods_loaded() method to dynamically load mod_xyz.
The trouble here is one of a race condition where if more then one mod attempts to be loaded last, then it is unclear which mod would actually be the last one loaded -- in fact it will probably be different on each world load (as it will depend on when register_on_mods_loaded actually gets called per mod).
This race condition makes adding that new feature, fundamentally unworkable.
Even if the mod loading system had a priority value added, where higher priorities get loaded at the bottom -- there would still be a race condition for mods that had the same priority (they could be sorted based on their dependency tree, but it still becomes a non-trivial matter).
==================================================
Re: Mod Loading Hadling.
There's also minetest.register_on_joinplayer, but that doesn't prevent another mod from doing the same thing, and minetest doing them in whatever order it does them. But there are things you can't do there. And its a little buggy. But from my minimal testing, it seems to handle this after minetest.on_mods_loaded. At least I'm able to do some overwrites without having a soft dependency.
But maybe that wasn't what you were asking, either... ;)
But maybe that wasn't what you were asking, either... ;)
Re: Mod Loading Hadling.
try to name the mod to zzzz, if minetest reads mods from a to z, and the more z it maybe becomes more chance to be the last one
- Andrey01
- Member
- Posts: 2577
- Joined: Wed Oct 19, 2016 15:18
- GitHub: Andrey2470T
- In-game: Andrey01
- Location: Russia, Moscow
Re: Mod Loading Hadling.
Why I`m asking for it is I need to override 'node_def' tables of all nodes of any mods that enabled, because they need additional properties. That`s why I need to load this mod after all.
Re: Mod Loading Hadling.
See this thread: viewtopic.php?f=6&t=3045Andrey01 wrote:Why I`m asking for it is I need to override 'node_def' tables of all nodes of any mods that enabled, because they need additional properties. That`s why I need to load this mod after all.
cornernote wrote:Heres a quick function (hack) based on your solution to make main code a little cleaner:
Code: Select all
minetest.registered = function(case,name) local params = {} local list if case == "item" then list = minetest.registered_items end if case == "node" then list = minetest.registered_nodes end if case == "craftitem" then list = minetest.registered_craftitems end if case == "tool" then list = minetest.registered_tools end if case == "entity" then list = minetest.registered_entities end if list then for k,v in pairs(list[name]) do params[k] = v end end return params end
What about this code ?
Code: Select all
minetest.register_on_mods_loaded(override_nodes)
local function override_nodes()
local list = minetest.registered_nodes
if list then
for name,node in pairs(list) do
node.after_place_node =
function(pos)
-- get the actual node that was placed
placed_node = minetest.get_node(pos)
-- do something with placed_node
if placed_node.some_property == nil
local some_value = {} -- alter as needed
placed_node.some_property = some_value
end
-- set the updated node
minetest.set_node(pos, placed_node)
end
end
end
end
Re: Mod Loading Hadling.
Edit:
this is maybe the solution:
this is maybe the solution:
Code: Select all
for i,v in pairs(minetest.registered_items) do
v.light_source = 10
minetest.override_item(i, v)
end
local a = minetest.register_node
minetest.register_node = function(name,def)
def.light_source = 10
end
Who is online
Users browsing this forum: No registered users and 10 guests