feat: nukeprotect modularity

This commit is contained in:
oof2win2
2022-11-12 22:39:58 +01:00
parent d0d59d35d8
commit 875e1b2bf6
2 changed files with 35 additions and 38 deletions

View File

@@ -1,12 +1,30 @@
return { return {
[tostring(defines.inventory.character_ammo)] = { inventories = {
["atomic-bomb"] = true {
}, -- @setting ammo The items to not allow in the player's ammo inventory inventory = defines.inventory.character_ammo,
[tostring(defines.inventory.character_armor)] = {}, -- @setting armor The items to not allow in the player's armor inventory event = defines.events.on_player_ammo_inventory_changed,
[tostring(defines.inventory.character_guns)] = {}, -- @setting gun The items to not allow in the player's gun inventory items = {
[tostring(defines.inventory.character_main)] = { ["atomic-bomb"] = true
["atomic-bomb"] = true },
}, -- @setting main The items to not allow in the player's main inventory },
{
inventory = defines.inventory.character_armor,
event = defines.events.on_player_armor_inventory_changed,
items = {},
},
{
inventory = defines.inventory.character_guns,
event = defines.events.on_player_gun_inventory_changed,
items = {},
},
{
inventory = defines.inventory.character_main,
event = defines.events.on_player_main_inventory_changed,
items = {
["atomic-bomb"] = true
},
},
},
ignore_permisison = "bypass-nukeprotect", -- @setting ignore_permisison The permission that nukeprotect will ignore ignore_permisison = "bypass-nukeprotect", -- @setting ignore_permisison The permission that nukeprotect will ignore
ignore_admins = true, -- @setting ignore_admins Ignore admins, true by default. Allows usage outside of the roles module ignore_admins = true, -- @setting ignore_admins Ignore admins, true by default. Allows usage outside of the roles module
} }

View File

@@ -24,34 +24,13 @@ local function check_items(player, type)
end end
end end
if table_size(config[tostring(defines.inventory.character_ammo)]) > 0 then for _, inventory in ipairs(config.inventories) do
Event.add(defines.events.on_player_ammo_inventory_changed, function(event) if #inventory.items > 0 then
local player = game.get_player(event.player_index) Event.add(inventory.event, function(event)
local player = game.get_player(event.player_index)
check_items(player, defines.inventory.character_ammo) if player and player.valid then
end) check_items(player, inventory.inventory)
end end
end)
if table_size(config[tostring(defines.inventory.character_armor)]) > 0 then end
Event.add(defines.events.on_player_armor_inventory_changed, function(event)
local player = game.get_player(event.player_index)
check_items(player, defines.inventory.character_armor)
end)
end
if table_size(config[tostring(defines.inventory.character_guns)]) > 0 then
Event.add(defines.events.on_player_gun_inventory_changed, function(event)
local player = game.get_player(event.player_index)
check_items(player, defines.inventory.character_guns)
end)
end
if table_size(config[tostring(defines.inventory.character_main)]) > 0 then
Event.add(defines.events.on_player_main_inventory_changed, function(event)
local player = game.get_player(event.player_index)
check_items(player, defines.inventory.character_main)
end)
end end