Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
minetest.register_privilege( "lava", "Can place lava at any depth.")
local LAVA_PLACE_DEPTH = -50
function override_on_place(item_name)
local def = minetest.registered_items[item_name]
local old_on_place = def.on_place
def.on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack -- No placement
end
if pointed_thing.above.y <= LAVA_PLACE_DEPTH
or minetest.check_player_privs(placer, "lava") then
-- OK
return old_on_place(itemstack, placer, pointed_thing)
end
-- Prevent placement
local player_name = placer:get_player_name()
minetest.chat_send_player(player_name,
"You are not allowed to place lava above " .. LAVA_PLACE_DEPTH .. "!")
minetest.log("action", player_name .. " tried to place default:lava_source above " .. LAVA_PLACE_DEPTH)
return itemstack
end
end
override_on_place("bucket:bucket_lava")
override_on_place("default:lava_source")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.