improve protaction against air_block
This commit is contained in:
parent
88cbd331b4
commit
f85ef21668
27
airblock.lua
27
airblock.lua
@ -3,6 +3,10 @@ local S = minetest.get_translator("tech_additions")
|
|||||||
local placeairblock = function ()
|
local placeairblock = function ()
|
||||||
return function(itemstack, user, pointed_thing)
|
return function(itemstack, user, pointed_thing)
|
||||||
local name = user:get_player_name()
|
local name = user:get_player_name()
|
||||||
|
if not minetest.is_creative_enabled(name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local pos = user:getpos()
|
local pos = user:getpos()
|
||||||
local dir = user:get_look_dir()
|
local dir = user:get_look_dir()
|
||||||
local distancefromplayer = 3
|
local distancefromplayer = 3
|
||||||
@ -11,18 +15,19 @@ local placeairblock = function ()
|
|||||||
y = pos.y + 1 + (dir.y * distancefromplayer),
|
y = pos.y + 1 + (dir.y * distancefromplayer),
|
||||||
z = pos.z + (dir.z * distancefromplayer),
|
z = pos.z + (dir.z * distancefromplayer),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if minetest.is_protected(new_pos, name) then
|
||||||
|
minetest.record_protection_violation(new_pos, name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local getPos = minetest.get_node(new_pos)
|
local getPos = minetest.get_node(new_pos)
|
||||||
if
|
if getPos.name == "air" or
|
||||||
not minetest.is_protected(new_pos, name) and
|
getPos.name == "default:water_source" or
|
||||||
minetest.is_creative_enabled(name)
|
getPos.name == "default:water_flowing" or
|
||||||
then
|
getPos.name == "default:river_water_source" or
|
||||||
if getPos.name == "air" or
|
getPos.name == "default:river_water_flowing" then
|
||||||
getPos.name == "default:water_source" or
|
minetest.set_node(new_pos, {name="tech_additions:air_block"})
|
||||||
getPos.name == "default:water_flowing" or
|
|
||||||
getPos.name == "default:river_water_source" or
|
|
||||||
getPos.name == "default:river_water_flowing" then
|
|
||||||
minetest.set_node(new_pos, {name="tech_additions:air_block"})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user