Allow crafting card deck from 2 pieces of paper
This commit is contained in:
parent
4ced74b2b6
commit
d07b53cdfc
27
init.lua
27
init.lua
@ -362,29 +362,46 @@ minetest.register_craft({
|
|||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "deck:chestpile",
|
output = "deck:chestpile",
|
||||||
recipe = {{ "default:paper" }}
|
recipe = {{ "default:paper" },{ "default:paper" }}
|
||||||
})
|
})
|
||||||
|
|
||||||
local function craft_pile(itemstack,player,old_craft_grid,craft_inv,really)
|
local function craft_pile(itemstack,player,old_craft_grid,craft_inv,really)
|
||||||
--describe("craft",old_craft_grid)
|
--describe("craft",old_craft_grid)
|
||||||
-- local s=craft_inv:get_size("craft")
|
-- local s=craft_inv:get_size("craft")
|
||||||
local place, cardname
|
local place, cardname
|
||||||
|
local onlycards=true
|
||||||
|
local onlypaper=true
|
||||||
for key,value in pairs(old_craft_grid) do
|
for key,value in pairs(old_craft_grid) do
|
||||||
--local stack=craft_inv:get_stack("craft",i)
|
--local stack=craft_inv:get_stack("craft",i)
|
||||||
local stack=old_craft_grid[key]
|
local stack=old_craft_grid[key]
|
||||||
if stack:is_empty() then
|
if stack:is_empty() then
|
||||||
minetest.log("empty "..key)
|
--minetest.log("empty "..key)
|
||||||
else
|
else
|
||||||
place=key
|
place=key
|
||||||
cardname=stack:get_name()
|
cardname=stack:get_name()
|
||||||
if string.sub(cardname,1,10) ~= "deck:card_" then
|
if string.sub(cardname,1,10) ~= "deck:card_" then
|
||||||
return nil
|
onlycards=false
|
||||||
|
end
|
||||||
|
if cardname ~= "default:paper" then
|
||||||
|
onlypaper=false
|
||||||
end
|
end
|
||||||
minetest.log("craft:"..key.."="..stack:get_name())
|
minetest.log("craft:"..key.."="..stack:get_name())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if cardname == nil then
|
if (onlycards==false and onlypaper==false) then
|
||||||
return ItemStack()
|
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
|
end
|
||||||
local pilename
|
local pilename
|
||||||
if place < 5 then
|
if place < 5 then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user