forked from VoxeLibre/VoxeLibre
small API fix
This commit is contained in:
parent
a18a2127c5
commit
d1ca012ea0
|
@ -1,28 +1,29 @@
|
||||||
local has_doc = minetest.get_modpath(minetest.get_current_modname())
|
local has_doc = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
local function survival_give(inv, itemstack)
|
local function survival_give(inv, original_item, itemstack)
|
||||||
if inv:room_for_item("main", itemstack) then
|
if inv:room_for_item("main", itemstack) then
|
||||||
inv:add_item("main", itemstack)
|
inv:add_item("main", itemstack)
|
||||||
|
return original_item:take_item()
|
||||||
else
|
else
|
||||||
minetest.add_item(user:get_pos(), itemstack)
|
minetest.add_item(user:get_pos(), itemstack)
|
||||||
|
return original_item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function creative_give(inv, itemstack)
|
local function creative_give(inv, original_item, itemstack)
|
||||||
if inv:room_for_item("main", itemstack) then
|
if not inv:contains_item("main", itemstack) then
|
||||||
inv:add_item("main", itemstack)
|
inv:add_item("main", itemstack)
|
||||||
else
|
return original_item
|
||||||
minetest.add_item(user:get_pos(), itemstack)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function give_item(user, itemstack)
|
local function give_item(user, original_item, itemstack)
|
||||||
local inv = user:get_inventory()
|
local inv = user:get_inventory()
|
||||||
if inv then
|
if inv then
|
||||||
if minetest.is_creative_enabled(user:get_player_name()) then
|
if minetest.is_creative_enabled(user:get_player_name()) then
|
||||||
creative_give(inv, itemstack)
|
creative_give(inv, original_item, itemstack)
|
||||||
else
|
else
|
||||||
survival_give(inv, itemstack)
|
survival_give(inv, original_item, itemstack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
@ -107,7 +108,7 @@ function mcl_cauldrons.take_cauldron(pos, itemstack, user, sounds)
|
||||||
if user and not minetest.is_creative_enabled(user:get_player_name()) then
|
if user and not minetest.is_creative_enabled(user:get_player_name()) then
|
||||||
minetest.set_node(pos, {name="mcl_cauldrons:cauldron"})
|
minetest.set_node(pos, {name="mcl_cauldrons:cauldron"})
|
||||||
if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end
|
if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end
|
||||||
return give_item(user, ItemStack(mcl_cauldrons.registered_cauldrons[nn.name].bucket))
|
return give_item(user, original, ItemStack(mcl_cauldrons.registered_cauldrons[nn.name].bucket))
|
||||||
else
|
else
|
||||||
minetest.set_node(pos, {name="mcl_cauldrons:cauldron"})
|
minetest.set_node(pos, {name="mcl_cauldrons:cauldron"})
|
||||||
if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end
|
if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end
|
||||||
|
|
Loading…
Reference in New Issue