forked from VoxeLibre/VoxeLibre
add helper function to give item in creative
This commit is contained in:
parent
7156afcd03
commit
a18a2127c5
|
@ -1,21 +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(user, itemstack)
|
local function survival_give(inv, 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)
|
||||||
else
|
else
|
||||||
minetest.add_item(user:get_pos(), itemstack)
|
minetest.add_item(user:get_pos(), itemstack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function give_item(user, itemstack)
|
|
||||||
local inv = user:get_inventory()
|
local function creative_give(inv, itemstack)
|
||||||
if inv then
|
|
||||||
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)
|
||||||
else
|
else
|
||||||
minetest.add_item(user:get_pos(), itemstack)
|
minetest.add_item(user:get_pos(), itemstack)
|
||||||
end
|
end
|
||||||
--end
|
end
|
||||||
|
|
||||||
|
local function give_item(user, itemstack)
|
||||||
|
local inv = user:get_inventory()
|
||||||
|
if inv then
|
||||||
|
if minetest.is_creative_enabled(user:get_player_name()) then
|
||||||
|
creative_give(inv, itemstack)
|
||||||
|
else
|
||||||
|
survival_give(inv, itemstack)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue