Added ExpGamingPlayer.InventroySearch

This commit is contained in:
Cooldude2606
2018-09-14 20:19:04 +01:00
parent d554255d0b
commit 2c7490e1bf
3 changed files with 76 additions and 20 deletions

View File

@@ -1,13 +1,14 @@
--[[ --- Desction <get from json>
Explosive Gaming -- @module ThisModule@X.Y.Z
-- @author <get from json>
-- @license <get from json>
-- @alais ThisModule
This file can be used with permission but this and the credit below must remain in the file. -- Module Require
Contact a member of management on our discord to seek permission to use our code. local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
Any changes that you may make to the code are yours but that does not make the script yours. local Game = require('FactorioStdLib.Game@^0.8.0')
Discord: https://discord.gg/r6dC2uK
]]
--Please Only Edit Below This Line-----------------------------------------------------------
-- Local Varibles
-- removed from none admin ranks, no further action -- removed from none admin ranks, no further action
local low_items = { local low_items = {
'loader', 'loader',
@@ -16,7 +17,8 @@ local low_items = {
'small-plane', 'small-plane',
'player-port', 'player-port',
'coin', 'coin',
'programmable-speaker' 'programmable-speaker',
'logistic-chest-active-provider'
} }
-- removed for admin and non-admin ranks, gives warnings to non-admins -- removed for admin and non-admin ranks, gives warnings to non-admins
@@ -32,6 +34,7 @@ local high_items = {
'infinity-chest' 'infinity-chest'
} }
-- inventories which are searched
local inventorys = { local inventorys = {
defines.inventory.player_main, defines.inventory.player_main,
defines.inventory.player_quickbar, defines.inventory.player_quickbar,
@@ -40,6 +43,15 @@ local inventorys = {
local _root_tree = {low_items=low_items,med_items=med_items,high_items=high_items} local _root_tree = {low_items=low_items,med_items=med_items,high_items=high_items}
-- Module Define
local module_verbose = false
local ThisModule = {
on_init=function()
if loaded_modules['ExpGamingCore.Ranking@^4.0.0'] then Ranking = require('ExpGamingCore.Ranking@^4.0.0') end
end
}
-- Function Define
local function take_action(player,item_name,category) local function take_action(player,item_name,category)
if category == 'low_items' then player_return({'inventory-search.low',item_name},defines.textcolor.med,player) if category == 'low_items' then player_return({'inventory-search.low',item_name},defines.textcolor.med,player)
elseif category == 'med_items' then player_return({'inventory-search.med',item_name},defines.textcolor.high,player) Admin.give_warning(player,'<server>','Found A Banned Item',5) elseif category == 'med_items' then player_return({'inventory-search.med',item_name},defines.textcolor.high,player) Admin.give_warning(player,'<server>','Found A Banned Item',5)
@@ -47,9 +59,9 @@ local function take_action(player,item_name,category)
else return end else return end
end end
function search_player(player) function ThisModule.search_player(player)
for category,items in pairs(_root_tree) do for category,items in pairs(_root_tree) do
if category ~= 'low_items' or not Ranking.get_rank(player):allowed('admin-items') then if not Ranking or category ~= 'low_items' and not Ranking.get_rank(player):allowed('admin-items') then
for _,_inventory in pairs(inventorys) do for _,_inventory in pairs(inventorys) do
local inventory = player.get_inventory(_inventory) local inventory = player.get_inventory(_inventory)
if inventory then if inventory then
@@ -63,17 +75,18 @@ function search_player(player)
end end
end end
Event.register({defines.events.on_player_main_inventory_changed,defines.events.on_player_quickbar_inventory_changed},function(event) -- Event Handlers Define
local player = Game.get_player(event) script.on_event(defines.events.on_tick,function(event)
if player and player.name == 'freek18' then search_player(player) end
end)
Event.register(defines.events.on_tick,function(event)
if (game.tick%900) == 0 then if (game.tick%900) == 0 then
local players = game.connected_players local players = game.connected_players
if #players == 0 then return end if #players == 0 then return end
local player = players[math.random(#players)] local player = players[math.random(#players)]
if Ranking.get_rank(player):allowed('all-items') then return end if Ranking and Ranking.get_rank(player):allowed('all-items') then return end
search_player(player) ThisModule.search_player(player)
end end
end) end)
-- Module Return
return setmetatable(ThisModule,{
__call=function(self,...) self.search_player(...) end
})

View File

@@ -0,0 +1,21 @@
{
"name": "inventorySearch",
"version": "4.0.0",
"type": "Submodule",
"description": "Adds an inventory search that is proformed on a random player every 15 seconds.",
"location": "<blank>",
"keywords": [
"Search",
"ExpGaming",
"Player",
"Inventory"
],
"dependencies": {
"ExpGamingLib": "^4.0.0",
"ExpGamingAdmin.TempBan": "^4.0.0",
"ExpGamingAdmin.Warnings": "^4.0.0",
"ExpGamingCore.Ranking": "?^4.0.0",
"FactorioStdLib.Game": "^0.8.0"
},
"collection": "ExpGamingPlayer_4.0.0"
}

View File

@@ -72,11 +72,33 @@
"FactorioStdLib.Game": "^0.8.0", "FactorioStdLib.Game": "^0.8.0",
"ExpGamingCore.Gui": "^4.0.0", "ExpGamingCore.Gui": "^4.0.0",
"ExpGamingCore.Ranking": "?^4.0.0", "ExpGamingCore.Ranking": "?^4.0.0",
"ExpGamingAdmin.AdminLib": "?^4.0.0",
"ExpGamingAdmin.buttonFlow": "?^4.0.0", "ExpGamingAdmin.buttonFlow": "?^4.0.0",
"ExpGamingAdmin.reports": "?^4.0.0", "ExpGamingAdmin.reports": "?^4.0.0",
"ExpGamingPlayer.playerInfo": "?^4.0.0" "ExpGamingPlayer.playerInfo": "?^4.0.0"
}, },
"collection": "ExpGamingPlayer_4.0.0" "collection": "ExpGamingPlayer_4.0.0"
},
"inventorySearch": {
"name": "inventorySearch",
"version": "4.0.0",
"type": "Submodule",
"description": "Adds an inventory search that is proformed on a random player every 15 seconds.",
"location": "<blank>",
"keywords": [
"Search",
"ExpGaming",
"Player",
"Inventory"
],
"dependencies": {
"ExpGamingLib": "^4.0.0",
"ExpGamingAdmin.TempBan": "^4.0.0",
"ExpGamingAdmin.Warnings": "^4.0.0",
"ExpGamingCore.Ranking": "?^4.0.0",
"FactorioStdLib.Game": "^0.8.0"
},
"collection": "ExpGamingPlayer_4.0.0"
} }
}, },
"dependencies": {} "dependencies": {}