Page 1 of 1

How to overridr default item's recipe?

PostPosted: Wed Mar 23, 2016 00:17
by linushsao
i had read minetest wiki & rubenwardy's modding book,one line said" To override, you prefix the item string with a colon, :. Declaring an item as :default:dirt will override the default:dirt in the default mod."

i try to change default:chest's recipe,so i create my new mod and init.lua inside. following code for test:

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_craft({
   output = ':default:chest',
   recipe = {
      {'default:paper', 'default:paper'},
      {'default:paper', 'default:paper'},
      {'default:paper', 'default:paper'},
   }
})


i check by command " /mods " to make sure my mod has been loaded and seems no error msg,but i check recipe by craftguide mod, default:chest still not change.do i miss understand something?(do i have to edit minetest's default mod's crafting.lua and recomplie minetest?...@@a)

Re: How to overridr default item's recipe?

PostPosted: Wed Mar 23, 2016 06:57
by sofar
you want to use minetest.override instead, so that most of the properties and methods of the chest are maintained.

https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1815

Re: How to overridr default item's recipe?

PostPosted: Wed Mar 23, 2016 16:24
by rubenwardy
Sofar misread the question. There is currently no good way of overriding or deleting a recipe. Prefixing with a colon only works when registering an item, not when registering a craft recipe.

The best way is do copy the old recipe, then set the output to zero, ie

output="default:chest 0"

Then register a new recipe to make the item.

Re: How to overridr default item's recipe?

PostPosted: Fri Mar 25, 2016 03:11
by linushsao
sofar & rubenwardy,tks for ur reply.

i think maybe it's the solution to download minetest's(&minetest_games) source ,edit the game mods, and recompile minetestserver? i'll try.

Re: How to overridr default item's recipe?

PostPosted: Fri Mar 25, 2016 09:00
by oleastre
You only need to edit the minetest_game mods.
Nothing to change in the server source code; and so, you don't have to recompile minetestserver.

Just launch your world after you've done your changes.

And a simple advice: if you change minetest_game, prefer creating your own game (you just have to rename the folder and update game.conf). This will allow you to compare it to new versions of the original minetest_game
.