Fix converting piles, add shuffle to stockpile
This commit is contained in:
parent
68196657ee
commit
ad9dbdcba6
17
init.lua
17
init.lua
@ -253,16 +253,20 @@ end
|
|||||||
local function convert_pile(pos,nodename)
|
local function convert_pile(pos,nodename)
|
||||||
local oldmeta=minetest.get_meta(pos)
|
local oldmeta=minetest.get_meta(pos)
|
||||||
local oldinv=oldmeta:get_inventory()
|
local oldinv=oldmeta:get_inventory()
|
||||||
|
local s=oldinv:get_size("main")
|
||||||
|
local cards={}
|
||||||
|
for i=1,s,1 do
|
||||||
|
local stack=oldinv:get_stack("main",i)
|
||||||
|
cards[i]=stack:get_name()
|
||||||
|
end
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
minetest.place_node(pos,{name=nodename})
|
minetest.place_node(pos,{name=nodename})
|
||||||
local newmeta=minetest.get_meta(pos)
|
local newmeta=minetest.get_meta(pos)
|
||||||
local newinv=newmeta:get_inventory()
|
local newinv=newmeta:get_inventory()
|
||||||
local s=oldinv:get_size("main")
|
local s=oldinv:get_size("main")
|
||||||
for i=1,s,1 do
|
for i=1,s,1 do
|
||||||
local stack=oldinv:get_stack("main",i)
|
local stack=ItemStack(cards[i])
|
||||||
if stack:get_count() > 0 then
|
newinv:set_stack("main",i,stack)
|
||||||
newinv:set_stack("main",i,stack)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -379,7 +383,7 @@ minetest.register_node("deck:stockpile", {
|
|||||||
meta:set_string("formspec","size[13,6]"..
|
meta:set_string("formspec","size[13,6]"..
|
||||||
"button[0,0;2,1;draw;Draw]"..
|
"button[0,0;2,1;draw;Draw]"..
|
||||||
"button[2,0;2,1;drawall;Draw all]"..
|
"button[2,0;2,1;drawall;Draw all]"..
|
||||||
"button[4,4,2,1,shuffle,Shuffle cards]"..
|
"button[4,0;2,1;shuffle;Shuffle cards]"..
|
||||||
"list[current_player;main;0,1;13,5;]"
|
"list[current_player;main;0,1;13,5;]"
|
||||||
)
|
)
|
||||||
end,
|
end,
|
||||||
@ -505,5 +509,8 @@ minetest.register_craft_predict(function(itemstack,player,old_craft_grid,craft_i
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
--minetest.log(player:get_inventory_formspec())
|
||||||
player:get_inventory():set_size("main", 60)
|
player:get_inventory():set_size("main", 60)
|
||||||
|
player:set_inventory_formspec("size[13,11]list[current_player;main;0,3.5;13,5;]list[current_player;craft;3,0;3,3;]listring[]list[current_player;craftpreview;7,1;1,1;]")
|
||||||
|
--minetest.log(player:get_inventory_formspec())
|
||||||
end)
|
end)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user