Add infinite placement in level editor
parent
a93da1f623
commit
1a41881a4f
|
@ -134,7 +134,29 @@ minetest.register_chatcommand("editor_load", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Unlimited node placement in editor mode
|
||||||
|
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
||||||
|
if placer and placer:is_player() then
|
||||||
|
return lzr_gamestate.get_state() == lzr_gamestate.EDITOR
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Don't pick node up if the item is already in the inventory
|
||||||
|
local old_handle_node_drops = minetest.handle_node_drops
|
||||||
|
function minetest.handle_node_drops(pos, drops, digger)
|
||||||
|
if not digger or not digger:is_player() or
|
||||||
|
lzr_gamestate.get_state() ~= lzr_gamestate.EDITOR then
|
||||||
|
return old_handle_node_drops(pos, drops, digger)
|
||||||
|
end
|
||||||
|
local inv = digger:get_inventory()
|
||||||
|
if inv then
|
||||||
|
for _, item in ipairs(drops) do
|
||||||
|
if not inv:contains_item("main", item, true) then
|
||||||
|
inv:add_item("main", item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
lzr_gamestate.register_on_enter_state(function(state)
|
lzr_gamestate.register_on_enter_state(function(state)
|
||||||
if state == lzr_gamestate.EDITOR then
|
if state == lzr_gamestate.EDITOR then
|
||||||
|
|
|
@ -35,5 +35,10 @@ end)
|
||||||
|
|
||||||
-- Can't drop items
|
-- Can't drop items
|
||||||
function minetest.item_drop(itemstack, dropper, pos)
|
function minetest.item_drop(itemstack, dropper, pos)
|
||||||
|
if lzr_gamestate.get_state() == lzr_gamestate.EDITOR then
|
||||||
|
-- Destroy item in editor mode
|
||||||
|
return ""
|
||||||
|
else
|
||||||
return itemstack
|
return itemstack
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue