Last active
January 1, 2020 16:49
-
-
Save SmallJoker/2fe2ce4277a3424c4bed359e55e258a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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