(untested) invrefill: support pulling from echest

wsc-master-rebase
cron 2021-01-16 01:31:08 +00:00 committed by Schmappie Eldress
parent 77274845fd
commit c4a075add1
1 changed files with 13 additions and 8 deletions

View File

@ -32,17 +32,21 @@ end
local function shulk_switch(name)
local plinv = minetest.get_inventory("current_player")
local pos = find_named(plinv.main, name, hasitems)
--or find_named(plinv.enderchest, name, hasitems))
if pos then
minetest.localplayer:set_wield_index(pos)
return true
end
end
local function shulk_place(pos, name)
if shulk_switch(name) then
minetest.place_node(pos)
local epos = find_named(plinv.enderchest, name, hasitems)
if epos then
local q = quint.invaction_new()
quint.invaction_dump(q,
{location = "current_player", inventory = "enderchest"},
{location = "current_player", inventory = "main"},
{min = epos, max = epos})
quint.invaction_apply(q)
return true
end
end
@ -60,8 +64,9 @@ local function do_refill(pos)
quint.invaction_apply(q)
end
local function queue_refill(pos, name)
if shulk_place(pos, name) then
function refill.refill_at(pos, name)
if shulk_swap(pos, name) then
minetest.after(0.5, minetest.place_node, pos)
minetest.after(1, do_refill, pos)
minetest.after(2, minetest.dig_node, pos)
end
@ -69,7 +74,7 @@ end
function refill.refill_here(name)
local pos = vector.round(minetest.localplayer:get_pos())
queue_refill(pos, name)
refill.refill_at(pos, name)
end
minetest.register_chatcommand("refill", {