@12Me21:
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_on_craft(function(itemstack, _, old_craft_grid, craft_inv)
if itemstack:get_name() == "default:chest_locked" then
craft_inv:set_list("craft", old_craft_grid)
itemstack:set_name("")
end
end)
false_chicken wrote:Hybrid Dog wrote:false_chicken wrote:One more question. Can one disable an item from a base game/mod via lua? Like cleanly removing the Locked Chest from minetest_game or disabling the crafting recipe without editing the base game itself.
you could write
default?in depends.txt and
local craft = minetest.register_craft
function minetest.register_craft(a)
if a.output == "default:chest_locked" then
return
end
return craft(a)
endin init.lua
I am a bit confused now. Sorry! I tried it out but I was still able to craft the Locked Chest. The formatted code looks like this:
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
local craft = minetest.register_craft
function minetest.register_craft(a)
if a.output == "default:chest_locked" then
return
end
return craft(a)
end
I am unsure as to what this is actually supposed to do. I never call the function explicitly so I am not sure when it is actually supposed to run. From what I can see it never does.
1. This code should override the function which registers a craft recipe to abort if the output is "default:chest_locked" before the default mod is loaded.
2. l'm sorry, l did a mistake, it would be default! and not default?
3. And l tried it but it still didn't work, maybe letting mods become loaded before default is impossible…
But l found another solution:
minetest.register_on_craft(function(itemstack, _, old_craft_grid, craft_inv)
if itemstack:get_name() == "default:chest_locked" then
craft_inv:set_list("craft", old_craft_grid)
itemstack:set_name("")
end
end)The locked chest appears but if you click on it, nothing happens. G:
lf you want, l can disable showing it.