|
@@ -1,3 +1,9 @@
|
|
|
+creative = {}
|
|
|
+
|
|
|
+function creative.is_enabled_for(name)
|
|
|
+ return minetest.setting_getbool("creative_mode")
|
|
|
+end
|
|
|
+
|
|
|
dofile(minetest.get_modpath("creative") .. "/inventory.lua")
|
|
|
|
|
|
if minetest.setting_getbool("creative_mode") then
|
|
@@ -28,22 +34,25 @@ if minetest.setting_getbool("creative_mode") then
|
|
|
damage_groups = {fleshy = 10},
|
|
|
}
|
|
|
})
|
|
|
+end
|
|
|
|
|
|
- minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
|
|
- return true
|
|
|
- end)
|
|
|
+-- Unlimited node placement
|
|
|
+minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
|
|
+ return creative.is_enabled_for(placer:get_player_name())
|
|
|
+end)
|
|
|
|
|
|
- function minetest.handle_node_drops(pos, drops, digger)
|
|
|
- if not digger or not digger:is_player() then
|
|
|
- return
|
|
|
- end
|
|
|
- local inv = digger:get_inventory()
|
|
|
- if inv then
|
|
|
- for _, item in ipairs(drops) do
|
|
|
- item = ItemStack(item):get_name()
|
|
|
- if not inv:contains_item("main", item) then
|
|
|
- inv:add_item("main", item)
|
|
|
- end
|
|
|
+-- Don't pick up if the item is already in the inventory
|
|
|
+function minetest.handle_node_drops(pos, drops, digger)
|
|
|
+ if not digger or not digger:is_player() or
|
|
|
+ not creative.is_enabled_for(digger:get_player_name()) then
|
|
|
+ return
|
|
|
+ end
|
|
|
+ local inv = digger:get_inventory()
|
|
|
+ if inv then
|
|
|
+ for _, item in ipairs(drops) do
|
|
|
+ item = ItemStack(item):get_name()
|
|
|
+ if not inv:contains_item("main", item) then
|
|
|
+ inv:add_item("main", item)
|
|
|
end
|
|
|
end
|
|
|
end
|