0ef16edb23
* Add antisabotage mod Prevents players of the same team from mining under or (somewhat) near others. Even works whilst crouching. * Fix slight issue of infinite items and radius fix Fixed issues dealing with unused variables, item removal and radius of the effect * Add newline so github doesn't die * Various improvements to function and distance Improvements/changes to improve performance and readability suggested by Lone_Wolf. * Create mod description Add readme.txt with description * Update with suggestions from Lone_Wolf Various performance optimizations and other issues suggested by Lone_Wolf * Remove unnecessary dependency * Snowball effect applied to a quick fix * Reword readme * Add license.txt MIT * Rename readme.txt to readme.md Co-authored-by: LoneWolfHT <lonewolf04361@gmail.com>
22 lines
717 B
Lua
22 lines
717 B
Lua
-- Code by Apelta. Mutelated by Lone_Wolf
|
|
|
|
minetest.register_on_dignode(function(pos, oldnode, digger)
|
|
if not digger:is_player() then return end
|
|
|
|
local dname = digger:get_player_name()
|
|
for _, player in pairs(minetest.get_connected_players()) do
|
|
local name = player:get_player_name()
|
|
|
|
if name ~= dname and ctf.players[name].team == ctf.players[dname].team then
|
|
local player_pos = player:get_pos()
|
|
|
|
if math.floor(player_pos.y) == pos.y and vector.distance(player_pos, pos) <= 1.5 then
|
|
minetest.set_node(pos, oldnode)
|
|
digger:get_inventory():remove_item("main", ItemStack(oldnode))
|
|
minetest.chat_send_player(dname, "You can't mine blocks under your teammates!")
|
|
return
|
|
end
|
|
end
|
|
end
|
|
end)
|