So, after updating from 4.?.? to 5.0.1, I'm having a problem with naming conventions with my mod.
I would like to depend on some item from another mod, but also provide a replacement in case that mod is not installed (e.g. only have an optional dependency on that mod).
What I'm currently doing is:
If [someothermod] is installed then use someothermod:someitem
else define othermod:someitem
Obviously, defining objects with a prefix unequal to the [modname] results in a naming convention error.
Thus the question is:
How can I provide a replacement item without violating naming conventions?
[question] items and naming conventions
Re: [question] items and naming conventions
If I'm understanding your question, you want to use "alias".
- v-rob
- Developer
- Posts: 971
- Joined: Thu Mar 24, 2016 03:19
- GitHub: v-rob
- IRC: v-rob
- Location: Right behind you.
Re: [question] items and naming conventions
Add an extra colon before the other mod's name, like so:
This works even if the other mod isn't installed or doesn't exist.
Code: Select all
minetest.register_node(":someothermod:someitem", {
...
})
Re: [question] items and naming conventions
What I would like to do is use a crafting material from another mod and supply a replacement if that mod is not installed, so players can still create the recipe.
But, if [someothermod] is not installed, ':someothermod:someitem' does not exist and thus there's no way to craft?
But, if [someothermod] is not installed, ':someothermod:someitem' does not exist and thus there's no way to craft?
Re: [question] items and naming conventions
I guess you meant something like this, "if bones doesn't exist" default wood and its craft recipe disappear, as an example.Exilyth wrote:But, if [someothermod] is not installed, ':someothermod:someitem' does not exist and thus there's no way to craft?
at least some help i hope :)
Code: Select all
clear_craft=function(mod,r)
if not minetest.get_modpath(mod) then
minetest.clear_craft({output=r})
minetest.unregister_item(r)
end
end
minetest.register_on_mods_loaded(function()
-- add lines here
clear_craft("bones","default:wood")
end)
- Attachments
-
- cc.zip
- (261 Bytes) Downloaded 76 times
- v-rob
- Developer
- Posts: 971
- Joined: Thu Mar 24, 2016 03:19
- GitHub: v-rob
- IRC: v-rob
- Location: Right behind you.
Re: [question] items and naming conventions
No, using the colon first allows you to define an item for any mod inside your own mod, whether it exists or not. If 'someothermod' doesn't exist, ':someothermod:someitem' inside your own mod will create an item in this non-existant mod's namespace.Exilyth wrote:What I would like to do is use a crafting material from another mod and supply a replacement if that mod is not installed, so players can still create the recipe.
But, if [someothermod] is not installed, ':someothermod:someitem' does not exist and thus there's no way to craft?
Don't do this in your code:
Code: Select all
if mod_is_enabled then
craft using othermod:item
else
mymod:item
craft using mymod:item
end
Code: Select all
if not mod_is_enabled then
:othermod:item
end
craft using othermod:item
Who is online
Users browsing this forum: No registered users and 20 guests