Replace last empty tank with a single full tank on recharge (#4)
This commit is contained in:
parent
33db7c7924
commit
b44be3b184
1 changed files with 10 additions and 4 deletions
12
init.lua
12
init.lua
|
|
@ -57,9 +57,14 @@ local function recharge_airtank(itemstack, user, pointed_thing, full_item)
|
||||||
itemstack:set_wear(0)
|
itemstack:set_wear(0)
|
||||||
else
|
else
|
||||||
local inv = user:get_inventory()
|
local inv = user:get_inventory()
|
||||||
local leftover = inv:add_item("main", full_item)
|
|
||||||
if leftover:get_count() == 0 then
|
if itemstack:get_count() == 1 then
|
||||||
itemstack:set_count(itemstack:get_count()-1)
|
itemstack = ItemStack(full_item) -- replace with new stack containing one full tank
|
||||||
|
else
|
||||||
|
local leftover = inv:add_item("main", full_item)
|
||||||
|
if leftover:get_count() == 0 then
|
||||||
|
itemstack:take_item(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.sound_play("airtanks_compressor", {pos = pointed_thing.under, gain = 0.5})
|
minetest.sound_play("airtanks_compressor", {pos = pointed_thing.under, gain = 0.5})
|
||||||
|
|
@ -248,3 +253,4 @@ local function player_event_handler(player, eventname)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_playerevent(player_event_handler)
|
minetest.register_playerevent(player_event_handler)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue