10881d4211
* Fix crucial bugs with antisabotage Fix possible crashes, infinite items, and any related issues * Make sabotage into function to be used with paxel * Fix paxel to work with antisabotage * Fix whitespace for luacheck * Update mods/pvp/antisabotage/init.lua Remove unnecessary newline Co-authored-by: David Leal <halfpacho@gmail.com> * Update function * Update function name * Add check for antisabotage * Remove whitespace for luacheck * Add antisabotage as an optional dependency * Remove more whitespace Co-authored-by: David Leal <halfpacho@gmail.com> * Fix optional depends dev wiki lied to me :( Co-authored-by: David Leal <halfpacho@gmail.com> * Fix up a comment P.1 * Move a line in mod.conf * Fix up comments and spacing Co-authored-by: David Leal <halfpacho@gmail.com> Co-authored-by: LoneWolfHT <lonewolf04361@gmail.com>
33 lines
995 B
Lua
33 lines
995 B
Lua
-- Code by Apelta. Mutelated by Lone_Wolf. Mutelated again by Apelta.
|
|
antisabotage = {}
|
|
|
|
function antisabotage.is_sabotage(pos, oldnode, digger) -- used for paxel
|
|
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)
|
|
|
|
-- Remove all node drops
|
|
for _, item in pairs(minetest.get_node_drops(oldnode)) do
|
|
digger:get_inventory():remove_item("main", ItemStack(item))
|
|
end
|
|
|
|
minetest.chat_send_player(dname, "You can't mine blocks under your teammates!")
|
|
return true
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
minetest.register_on_dignode(function(pos, oldnode, digger)
|
|
if not digger:is_player() then return end
|
|
|
|
antisabotage.is_sabotage(pos, oldnode, digger)
|
|
end)
|