mirror of
https://github.com/rollerozxa/voxelmanip-wiki
synced 2024-05-05 08:01:02 -07:00
Mod Dependency Management: edit
This commit is contained in:
parent
1a72f4775b
commit
547d183e8d
26
pages/Mod_Dependency_Management.md
Normal file
26
pages/Mod_Dependency_Management.md
Normal file
@ -0,0 +1,26 @@
|
||||
A mod has the ability to depend on other mods, either required dependencies or optional dependencies. These are specified as comma separated lists in the mod's `mod.conf` file, `depends` and `optional_depends` respectively.
|
||||
|
||||
A mod's dependencies get loaded before the mod, such that API functions get defined and are available for use. If no mods have dependencies, mod loading order goes in reverse alphabetical order ^(undocumented)^.
|
||||
|
||||
## Required dependencies
|
||||
Required dependencies need to be resolved for a mod to be allowed. You can always rely on these depending mods to exist. In recent versions of Minetest, the game will refuse to load if a player attempts to load a mod with unresolved required dependencies. If your mod gets installed from the main menu content browser, it will attempt to also download required dependencies.
|
||||
|
||||
## Optional dependencies
|
||||
Optional dependencies can be used to provide additional functionality if a mod exists. If you want to use API functions of the mod, you will need to check if the mod exists using `minetest.get_modpath` (it will return nil if the mod isn't loaded).
|
||||
|
||||
```lua
|
||||
if minetest.get_modpath('optionally_dependant_mod') then
|
||||
-- Code for when optionally_dependant_mod exists
|
||||
end
|
||||
```
|
||||
|
||||
## Game Support
|
||||
In order to support several games, you would want to optionally depend on each game's specific mods. For example:
|
||||
|
||||
```lua
|
||||
if minetest.get_modpath("default") then
|
||||
-- Code path for Minetest Game
|
||||
elseif minetest.get_modpath("mcl_core") then
|
||||
-- Code path for MineClone 2
|
||||
end
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user