[Solved]My mod does not work

BBmine
Member
 
Posts: 1425
Joined: Sun Jul 12, 2015 22:51
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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.
God's not dead!
I actually did mine walls before I started playing this game....
Mods, Servers, and My Youtube Channel
Let us remember Just Test on April 16.
"Together, we will make America great again!" --President Trump
Please vote for the next video I should do here
I'm the most rottenist potato in the fridge.
Copyright (c) 2017 Baggins Inc. (tm) All rights reserved.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
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", {}))
 

BBmine
Member
 
Posts: 1425
Joined: Sun Jul 12, 2015 22:51
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.
God's not dead!
I actually did mine walls before I started playing this game....
Mods, Servers, and My Youtube Channel
Let us remember Just Test on April 16.
"Together, we will make America great again!" --President Trump
Please vote for the next video I should do here
I'm the most rottenist potato in the fridge.
Copyright (c) 2017 Baggins Inc. (tm) All rights reserved.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron