Fix antisabotage bugs and make to work with paxel(#731)

* 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>
This commit is contained in:
Apelta 2021-01-05 22:14:55 -06:00 committed by GitHub
parent 88c326f13d
commit 10881d4211
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 8 deletions

View file

@ -151,9 +151,15 @@ local function remove_pillar(pos, pname)
local name = minetest.get_node(pos).name
if name:find("default") and isdiggable(name) then
local player = minetest.get_player_by_name(pname)
if minetest.get_modpath("antisabotage") then
-- Fix paxel being capable of mining blocks under teammates
if antisabotage.is_sabotage(pos, minetest.get_node(pos), player) then return end
end
minetest.dig_node(pos)
local player = minetest.get_player_by_name(pname)
if player and diggers[pname] and type(diggers[pname]) ~= "table" then
if vector.distance(player:get_pos(), pos) <= DIG_DIST_LIMIT then
pos.y = pos.y + 1

View file

@ -1,3 +1,4 @@
name = ctf_classes
depends = ctf, ctf_flag, ctf_colors, ctf_map_core, ctf_stats, ctf_bandages, physics, shooter, hpregen, give_initial_stuff, dropondie, crafting, sniper_rifles, grenades, furnace, ctf_respawn_immunity, ctf_marker, ctf_match
description = Adds classes, including knight, shooter, and medic
depends = ctf, ctf_flag, ctf_colors, ctf_map_core, ctf_stats, ctf_bandages, physics, shooter, hpregen, give_initial_stuff, dropondie, crafting, sniper_rifles, grenades, furnace, ctf_respawn_immunity, ctf_marker, ctf_match
optional_depends = antisabotage

View file

@ -1,9 +1,9 @@
-- Code by Apelta. Mutelated by Lone_Wolf
minetest.register_on_dignode(function(pos, oldnode, digger)
if not digger:is_player() then return end
-- 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()
@ -12,10 +12,21 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
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))
-- 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
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)