[Solved]My mod does not work

User avatar
BBmine
Member
 
Posts: 3475
Joined: Sun Jul 12, 2015 22:51
Location: USA
GitHub: BBmine
IRC: BBmine
In-game: Baggins

[Solved]My mod does not work

by BBmine » Thu Apr 07, 2016 18:50

I banged out a mod for my Noob Academy server which enables leather and leather crafting. Here is the code:
Code: Select all
minetest.register_craftitem("mobs:leather", {
   description = "Leather",
   inventory_image = "mobs_leather.png",
})
minetest.register_craft({
   output = "mobs:leather",
   recipe = {
      {"farming:string", "farming:string", "farming:string"},
      {"farming:string", "default:mese_crystal", "farming:string"},
      {"farming:string", "farming:string", "farming:string"},
   },
})

Here is the error it gives me:
Code: Select all
2016-04-07 13:49:24: ERROR[main]: ========== ERROR FROM LUA ===========
2016-04-07 13:49:24: ERROR[main]: Failed to load and run script from
2016-04-07 13:49:24: ERROR[main]: /home/user/.minetest/mods/leather_craft/init.lua:
2016-04-07 13:49:24: ERROR[main]: /usr/share/minetest/builtin/game/register.lua:60: Name mobs:leather does not follow naming conventions: "modname:" or ":" prefix required
2016-04-07 13:49:24: ERROR[main]: stack traceback:
2016-04-07 13:49:24: ERROR[main]:    [C]: in function 'error'
2016-04-07 13:49:24: ERROR[main]:    /usr/share/minetest/builtin/game/register.lua:60: in function 'check_modname_prefix'
2016-04-07 13:49:24: ERROR[main]:    /usr/share/minetest/builtin/game/register.lua:98: in function 'register_item'
2016-04-07 13:49:24: ERROR[main]:    /usr/share/minetest/builtin/game/register.lua:177: in function 'register_craftitem'
2016-04-07 13:49:24: ERROR[main]:    /home/user/.minetest/mods/leather_craft/init.lua:1: in main chunk
2016-04-07 13:49:24: ERROR[main]: ======= END OF ERROR FROM LUA ========
2016-04-07 13:49:24: ERROR[main]: Server: Failed to load and run /home/user/.minetest/mods/leather_craft/init.lua
2016-04-07 13:49:24: ERROR[main]: ModError: ModError: Failed to load and run /home/user/.minetest/mods/leather_craft/init.lua
2016-04-07 13:49:24: ERROR[main]: Error from Lua:
2016-04-07 13:49:24: ERROR[main]: /usr/share/minetest/builtin/game/register.lua:60: Name mobs:leather does not follow naming conventions: "modname:" or ":" prefix required
2016-04-07 13:49:24: ERROR[main]: stack traceback:
2016-04-07 13:49:24: ERROR[main]:    [C]: in function 'error'
2016-04-07 13:49:24: ERROR[main]:    /usr/share/minetest/builtin/game/register.lua:60: in function 'check_modname_prefix'
2016-04-07 13:49:24: ERROR[main]:    /usr/share/minetest/builtin/game/register.lua:98: in function 'register_item'
2016-04-07 13:49:24: ERROR[main]:    /usr/share/minetest/builtin/game/register.lua:177: in function 'register_craftitem'
2016-04-07 13:49:24: ERROR[main]:    /home/user/.minetest/mods/leather_craft/init.lua:1: in main chunk
2016-04-07 13:49:24: ERROR[main]: Check debug.txt for details.
Last edited by BBmine on Thu Apr 07, 2016 22:04, edited 1 time in total.
 

User avatar
rubenwardy
Moderator
 
Posts: 5862
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: My mod does not work

by rubenwardy » Thu Apr 07, 2016 18:57

When you define an item, its name needs to be in the form modname:item where modname is the name of the current mod. You are not in the mobs mod, so you cannot define an item called mobs:leather in that way.

Solution: Renaming the item name to be of the form modname:item.

Alternatively: If you are overriding an item, or you need to make the name mobs:leather, then use :mobs:leather in register_craftitem. Prepending a colon like that disabled the valid name check. (minetest.register_craftitem("mobs:leather", {}))
 

User avatar
BBmine
Member
 
Posts: 3475
Joined: Sun Jul 12, 2015 22:51
Location: USA
GitHub: BBmine
IRC: BBmine
In-game: Baggins

Re: My mod does not work

by BBmine » Thu Apr 07, 2016 22:03

rubenwardy wrote:When you define an item, its name needs to be in the form modname:item where modname is the name of the current mod. You are not in the mobs mod, so you cannot define an item called mobs:leather in that way.

Solution: Renaming the item name to be of the form modname:item.

Alternatively: If you are overriding an item, or you need to make the name mobs:leather, then use :mobs:leather in register_craftitem. Prepending a colon like that disabled the valid name check. (minetest.register_craftitem("mobs:leather", {}))

Thanks! It works now.
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 1 guest