An issue with tables and crafting

User avatar
SegFault22
Member
 
Posts: 870
Joined: Mon May 21, 2012 03:17

An issue with tables and crafting

by SegFault22 » Thu Nov 14, 2013 05:02

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)]
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
[/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.
Last edited by SegFault22 on Thu Nov 14, 2013 05:03, edited 1 time in total.
Resources are abundant; only money is scarce. People should not have to work hard and remain poor just to pay for the needs of survival.
Society can thrive without money - but only if productive members of society are rewarded for being productive.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Thu Nov 14, 2013 08:55

You have added the craftin and craftout variables as strings.
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 = craftout..'8',
    recipe = {
        { craftin, craftin, craftin },
        { craftin, 'morestuff2:saw', craftin },
        { craftin, craftin, craftin },
      },
      replacements = { {'morestuff2:saw', 'morestuff2:saw'}, },
    })

end
Last edited by rubenwardy on Thu Nov 14, 2013 08:55, edited 1 time in total.
 

User avatar
SegFault22
Member
 
Posts: 870
Joined: Mon May 21, 2012 03:17

by SegFault22 » Thu Nov 14, 2013 22:18

rubenwardy wrote:You have added the craftin and craftout variables as strings.
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 = craftout..'8',
    recipe = {
        { craftin, craftin, craftin },
        { craftin, 'morestuff2:saw', craftin },
        { craftin, craftin, craftin },
      },
      replacements = { {'morestuff2:saw', 'morestuff2:saw'}, },
    })

end

I see. Thank you very much, you've just saved my mod several seconds of loading time.
Resources are abundant; only money is scarce. People should not have to work hard and remain poor just to pay for the needs of survival.
Society can thrive without money - but only if productive members of society are rewarded for being productive.
 


Return to WIP Mods

Who is online

Users browsing this forum: Bing [Bot] and 11 guests

cron