Allow crafting card deck from 2 pieces of paper

This commit is contained in:
Mikko Tuumanen 2020-06-02 21:26:03 +03:00 committed by Mikko Tuumanen
parent 4ced74b2b6
commit d07b53cdfc

View File

@ -362,29 +362,46 @@ minetest.register_craft({
})
minetest.register_craft({
output = "deck:chestpile",
recipe = {{ "default:paper" }}
recipe = {{ "default:paper" },{ "default:paper" }}
})
local function craft_pile(itemstack,player,old_craft_grid,craft_inv,really)
--describe("craft",old_craft_grid)
-- local s=craft_inv:get_size("craft")
local place, cardname
local onlycards=true
local onlypaper=true
for key,value in pairs(old_craft_grid) do
--local stack=craft_inv:get_stack("craft",i)
local stack=old_craft_grid[key]
if stack:is_empty() then
minetest.log("empty "..key)
--minetest.log("empty "..key)
else
place=key
cardname=stack:get_name()
if string.sub(cardname,1,10) ~= "deck:card_" then
return nil
onlycards=false
end
if cardname ~= "default:paper" then
onlypaper=false
end
minetest.log("craft:"..key.."="..stack:get_name())
end
end
if cardname == nil then
return ItemStack()
if (onlycards==false and onlypaper==false) then
return nil
end
if onlypaper then
local resultname=itemstack:get_name()
if resultname == "deck:chestpile" then
local stackmeta=itemstack:get_meta()
local i
for i=1,52,1 do
stackmeta:set_string(i,cardnames[i])
end
return itemstack
end
return nil
end
local pilename
if place < 5 then