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:
parent
88c326f13d
commit
10881d4211
3 changed files with 26 additions and 8 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue