An issue with tables and crafting
For my mod, I decided to replace the long section of code for each recipe, with a table and a modified "minetest.register_craft" piece of code. Only, it doesn't work. It loads, but just that - no recipes will work. Here is the code:
[spoiler=code (click to view)][/spoiler]
I tried adding/removing "node" and "craft" before "'craftin'" in the recipe registry, to no avail. Due to the persistence of this problem, I have come here to ask if anyone could point me in the right direction. If you have a suggestion of how to get this to work, please let me know in a reply.
Thank you.
[spoiler=code (click to view)]
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 crafting = {
{ "morestuff2:block_granite", "morestuff2:bricks_granite" },
{ "morestuff2:block_marble", "morestuff2:bricks_marble", },
{ "morestuff2:block_basalt", "morestuff2:bricks_basalt", },
{ "morestuff2:block_gneiss", "morestuff2:bricks_gneiss", },
{ "morestuff2:block_limestone", "morestuff2:bricks_limestone", },
{ "morestuff2:block_schist", "morestuff2:bricks_schist", },
{ "morestuff2:block_quartzite", "morestuff2:bricks_quartzite", },
}
for _, row in ipairs(crafting) do
local craftin = row[1]
local craftout = row[2]
minetest.register_craft( {
output = 'node craftout 8',
recipe = {
{ 'craftin', 'craftin', 'craftin' },
{ 'craftin', 'craft morestuff2:saw', 'craftin' },
{ 'craftin', 'craftin', 'craftin' },
},
replacements = { {'morestuff2:saw', 'morestuff2:saw'}, },
})
end
I tried adding/removing "node" and "craft" before "'craftin'" in the recipe registry, to no avail. Due to the persistence of this problem, I have come here to ask if anyone could point me in the right direction. If you have a suggestion of how to get this to work, please let me know in a reply.
Thank you.