Fix converting piles, add shuffle to stockpile
This commit is contained in:
parent
68196657ee
commit
ad9dbdcba6
15
init.lua
15
init.lua
@ -253,17 +253,21 @@ end
|
||||
local function convert_pile(pos,nodename)
|
||||
local oldmeta=minetest.get_meta(pos)
|
||||
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.place_node(pos,{name=nodename})
|
||||
local newmeta=minetest.get_meta(pos)
|
||||
local newinv=newmeta:get_inventory()
|
||||
local s=oldinv:get_size("main")
|
||||
for i=1,s,1 do
|
||||
local stack=oldinv:get_stack("main",i)
|
||||
if stack:get_count() > 0 then
|
||||
local stack=ItemStack(cards[i])
|
||||
newinv:set_stack("main",i,stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function draw_card(pos,formname,fields,sender)
|
||||
@ -379,7 +383,7 @@ minetest.register_node("deck:stockpile", {
|
||||
meta:set_string("formspec","size[13,6]"..
|
||||
"button[0,0;2,1;draw;Draw]"..
|
||||
"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;]"
|
||||
)
|
||||
end,
|
||||
@ -505,5 +509,8 @@ minetest.register_craft_predict(function(itemstack,player,old_craft_grid,craft_i
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
--minetest.log(player:get_inventory_formspec())
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user