mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-29 20:16:38 +09:00
Refactor of commands
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
--- Adds a better method of player starting items based on production levels.
|
||||
-- @module AdvancedStartingItems@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Local Variables
|
||||
local items = {
|
||||
['iron-plate']=function(player,made) if tick_to_min(game.tick) < 5 then return 8 else return (made*10)/math.pow(tick_to_min(game.tick),2) end end,
|
||||
['copper-plate']=function(player,made) if tick_to_min(game.tick) < 5 then return 0 else return (made*8)/math.pow(tick_to_min(game.tick),2) end end,
|
||||
['electronic-circuit']=function(player,made) if tick_to_min(game.tick) < 5 then return 0 else return (made*6)/math.pow(tick_to_min(game.tick),2) end end,
|
||||
['iron-gear-wheel']=function(player,made) if tick_to_min(game.tick) < 5 then return 0 else return (made*6)/math.pow(tick_to_min(game.tick),2) end end,
|
||||
['steel-plate']=function(player,made) if tick_to_min(game.tick) < 5 then return 0 else return(made*4)/math.pow(tick_to_min(game.tick),2) end end,
|
||||
['pistol']=function(player,made) if player.force.item_production_statistics.get_input_count('submachine-gun') > 5 then return 0 else return 1 end end,
|
||||
['submachine-gun']=function(player,made) if made > 5 then return 1 else return 0 end end,
|
||||
['firearm-magazine']=function(player,made) if player.force.item_production_statistics.get_input_count('piercing-rounds-magazine') > 100 then return 0 else return 10 end end,
|
||||
['piercing-rounds-magazine']=function(player,made) if made > 100 then return 10 else return 0 end end,
|
||||
['light-armor']=function(player,made) if made > 5 and player.force.item_production_statistics.get_input_count('heavy-armor') <= 5 then return 1 else return 0 end end,
|
||||
['heavy-armor']=function(player,made) if made > 5 then return 1 else return 0 end end,
|
||||
['burner-mining-drill']=function(player,made) if tick_to_min(game.tick) < 5 then return 4 else return 0 end end,
|
||||
['stone-furnace']=function(player,made) if tick_to_min(game.tick) < 5 then return 4 else return 0 end end,
|
||||
['iron-axe']=function(player,made) if made > 5 and player.force.item_production_statistics.get_input_count('steel-axe') <= 5 then return 1 else return 0 end end,
|
||||
['steel-axe']=function(player,made) if made > 5 then return 1 else return 0 end end
|
||||
}
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {}
|
||||
|
||||
-- Event Handlers Define
|
||||
Event.add(defines.events.on_player_created, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
if event.player_index == 1 then
|
||||
player.force.friendly_fire = false
|
||||
game.map_settings.enemy_expansion.enabled = false
|
||||
player.force.chart(player.surface, {{player.position.x - 400, player.position.y - 400}, {player.position.x + 400, player.position.y + 400}})
|
||||
end
|
||||
for item,count in pairs(items) do
|
||||
if type(count) == 'function' then count = math.floor(count(player,player.force.item_production_statistics.get_input_count(item))) end
|
||||
if count > 0 then player.insert{name=item, count=count} end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
return ThisModule
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"name": "AdvancedStartingItems",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a better method of player starting items based on production levels.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Inventory",
|
||||
"Start",
|
||||
"Items",
|
||||
"Player",
|
||||
"Advanced",
|
||||
"Useful",
|
||||
"Balaced"
|
||||
],
|
||||
"author": "Cooldude2606",
|
||||
"contact": "Discord: Cooldude2606#5241",
|
||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||
"dependencies": {},
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
--- Creates flying text above player when they send a message.
|
||||
-- @module ChatPopup@4.0.0
|
||||
-- @author badgamernl
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ChatPopup
|
||||
|
||||
-- Module Require
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color = require('FactorioStdLib.Color')
|
||||
|
||||
local ChatPopup = {}
|
||||
|
||||
function ChatPopup.sendFlyingText(player, text)
|
||||
local _player = Game.get_player(player)
|
||||
if not _player then return end
|
||||
-- Split long text in chunks
|
||||
local chunkSize = 40
|
||||
local chunks = {}
|
||||
for i=1, #text, chunkSize do
|
||||
chunks[#chunks+1] = text:sub(i,i+chunkSize - 1)
|
||||
end
|
||||
-- Iterate over text chunks and create them as floating text centered above the player
|
||||
-- Disabled false centering because of not being able to disable scaling: (1 / 7.9 * #value)
|
||||
for i,value in ipairs(chunks) do
|
||||
_player.surface.create_entity{
|
||||
name="flying-text",
|
||||
color=_player.chat_color,
|
||||
text=value,
|
||||
position={_player.position.x, _player.position.y-(2 - (1 * i))}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_console_chat, function(event)
|
||||
if not event.player_index then return end
|
||||
local player = game.players[event.player_index]
|
||||
if not player then return end
|
||||
if not event.message then return end
|
||||
|
||||
-- Send message player send to player itself
|
||||
local message = player.name .. ': ' .. event.message
|
||||
ChatPopup.sendFlyingText(player, message)
|
||||
|
||||
-- parse message for players and if it includes player, send him a notification that he has been mentioned in the chat
|
||||
local player_message = event.message:lower():gsub("%s+", "")
|
||||
|
||||
for i,_player in ipairs(game.connected_players) do
|
||||
if _player.index ~= player.index then
|
||||
if player_message:match(_player.name:lower()) then
|
||||
ChatPopup.sendFlyingText(_player, 'You\'ve been mentioned by: ' ..player.name .. ' in chat!')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
return ChatPopup
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "ChatPopup",
|
||||
"version": "4.0.0",
|
||||
"description": "Creates flying text above player when they send a message.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Chat",
|
||||
"Popup",
|
||||
"Mention",
|
||||
"Floating",
|
||||
"Text"
|
||||
],
|
||||
"author": "badgamernl",
|
||||
"contact": "badgamernl@gmail.com",
|
||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"FactorioStdLib.Color": "^0.8.0"
|
||||
},
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
--- When a entity is damaged y a player it will show how much damage you've death, When a player gets attacked by a entity it will popup the player's health in color.
|
||||
-- @module DamagePopup@4.0.0
|
||||
-- @author badgamernl
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias DamagePopup
|
||||
|
||||
-- Module Require
|
||||
local Color = require('FactorioStdLib.Color')
|
||||
|
||||
local DamagePopup = {}
|
||||
|
||||
Event.add(defines.events.on_entity_damaged, function(event)
|
||||
local entity = event.entity
|
||||
local cause = event.cause
|
||||
local damage = event.original_damage_amount
|
||||
local health = entity.health
|
||||
-- local pre_attack_health = health + damage -- Didn't use it after all, maybe useful later
|
||||
|
||||
local color = defines.textcolor.crit
|
||||
|
||||
if entity.name == 'player' then
|
||||
if health > 100 then
|
||||
if health > 200 then
|
||||
color = defines.textcolor.low
|
||||
else
|
||||
color = defines.textcolor.med
|
||||
end
|
||||
end
|
||||
entity.surface.create_entity{
|
||||
name="flying-text",
|
||||
color=color,
|
||||
text=math.floor(health),
|
||||
position=entity.position
|
||||
}
|
||||
elseif cause and cause.name == 'player' then
|
||||
entity.surface.create_entity{
|
||||
name="flying-text",
|
||||
color=defines.textcolor.med,
|
||||
text='-'..math.floor(damage), -- cooldude2606 added floor for damage amount
|
||||
position=entity.position
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
return DamagePopup
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "DamagePopup",
|
||||
"version": "4.0.0",
|
||||
"description": "When a entibty is damaged y a player it will show how much damage you've dealth, When a player gets attacked by a entity it will popup the player's health in color.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Damage",
|
||||
"Popup",
|
||||
"Floating",
|
||||
"Text"
|
||||
],
|
||||
"author": "badgamernl",
|
||||
"contact": "badgamernl@gmail.com",
|
||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Color": "^0.8.0"
|
||||
},
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
--- Adds markers to the map when a player dies and removes it when the body is removed.
|
||||
-- @module DeathMarkers@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {}
|
||||
|
||||
-- Global Define
|
||||
local global = {
|
||||
corpses={}
|
||||
}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
|
||||
-- Event Handlers Define
|
||||
Event.add(defines.events.on_player_died, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
local tag = player.force.add_chart_tag(player.surface,{
|
||||
position=player.position,
|
||||
text='Death: '..player.name..' ('..tick_to_display_format(event.tick)..')'
|
||||
})
|
||||
if not global.corpses then global.corpses = {} end
|
||||
table.insert(global.corpses,tag)
|
||||
end)
|
||||
|
||||
Event.add(defines.events.on_tick, function(event)
|
||||
if (game.tick%3600) ~= 0 then return end
|
||||
if not global.corpses then global.corpses = {} end
|
||||
local key = 1
|
||||
while key <= #global.corpses do
|
||||
local tag = global.corpses[key]
|
||||
if not tag or not tag.valid then table.remove(global.corpses,key) else
|
||||
if not tag.target then
|
||||
local entity = tag.surface.find_entity('character-corpse',tag.position)
|
||||
if entity then tag.target = entity
|
||||
else tag.destroy() table.remove(global.corpses,key) key=key-1 end
|
||||
elseif not tag.target.valid then tag.destroy() table.remove(global.corpses,key) key=key-1 end
|
||||
end
|
||||
key=key+1
|
||||
end
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
return ThisModule
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "DeathMarkers",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds markers to the map when a player dies and removes it when the body is removed.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Death",
|
||||
"Marker",
|
||||
"Body",
|
||||
"Map"
|
||||
],
|
||||
"author": "Cooldude2606",
|
||||
"contact": "Discord: Cooldude2606#5241",
|
||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||
"dependencies": {},
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
--- Allows control over decon rights, if ExpGamingCore.Role is not installed it will allow admins to instant remove trees and thats it.
|
||||
-- @module DeconControl@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
local Role -- ExpGamingCore.Role@^4.0.0
|
||||
local Admin -- ExpGamingAdmin@^4.0.0
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||
if loaded_modules['ExpGamingAdmin'] then Admin = require('ExpGamingAdmin') end
|
||||
end
|
||||
}
|
||||
|
||||
-- Event Handlers Define
|
||||
Event.register(-1,function(event)
|
||||
Server.new_thread{
|
||||
name='tree-decon',
|
||||
data={trees={},cache={},clear=0}
|
||||
}:on_event('tick',function(self)
|
||||
local trees = self.data.trees
|
||||
if self.data.clear ~= 0 and self.data.clear < game.tick then self.data.cache = {} self.data.clear = 0 end
|
||||
if #trees == 0 then return end
|
||||
for i = 0,math.ceil(#trees/10) do
|
||||
local tree = table.remove(trees,1)
|
||||
if tree and tree.valid then tree.destroy() end
|
||||
end
|
||||
end):on_event(defines.events.on_marked_for_deconstruction,function(self,event)
|
||||
local cache = self.data.cache[event.player_index]
|
||||
if not cache then
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
if not Role then
|
||||
if player.admin then self.data.cache[event.player_index] = {'tree-decon',false}
|
||||
else self.data.cache[event.player_index] = {'decon',false} end
|
||||
else
|
||||
if Role.allowed(player,'tree-decon') then self.data.cache[event.player_index] = {'tree-decon',false}
|
||||
elseif not Role.allowed(player,'decon') then self.data.cache[event.player_index] = {'no-decon',false}
|
||||
else self.data.cache[event.player_index] = {'decon',false} end
|
||||
end
|
||||
cache = self.data.cache[event.player_index]
|
||||
end
|
||||
if not event.entity.last_user or event.entity.name == 'entity-ghost' then
|
||||
if cache[1] == 'tree-decon' then
|
||||
table.insert(self.data.trees,event.entity)
|
||||
self.data.clear = game.tick + 10
|
||||
end
|
||||
else
|
||||
if cache[1] == 'no-decon' then
|
||||
event.entity.cancel_deconstruction('player')
|
||||
if not cache[2] then
|
||||
cache[2] = true
|
||||
local player = Game.get_player(event)
|
||||
player_return({'DeconControl.player-print'},defines.textcolor.crit,player)
|
||||
Role.print(Role.meta.groups.Admin.lowest,{'DeconControl.rank-print',player.name},defines.textcolor.info)
|
||||
if Admin then Admin.give_warning(player,'<server>','Trying To Decon The Base') end
|
||||
end
|
||||
self.data.clear = game.tick + 10
|
||||
end
|
||||
end
|
||||
end):open()
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
return ThisModule
|
||||
@@ -1,3 +0,0 @@
|
||||
[DeconControl]
|
||||
player-print=Du darfst dies noch nicht entfernen. Du benötigst dazu den Rang Regular, den du nach 3 Stunden auf dem Server automatisch erhältst.
|
||||
rank-print=__1__ versuchte etwas zu entfernen.
|
||||
@@ -1,3 +0,0 @@
|
||||
[DeconControl]
|
||||
player-print=You do not have permission to do this right now. You require the Regular rank which can be obtained through 3 hours of in-game playtime on a server.
|
||||
rank-print=__1__ tried to deconstruct something.
|
||||
@@ -1,3 +0,0 @@
|
||||
[DeconControl]
|
||||
player-print=You are not allowed to do this yet, You require the Regular rank, you must play for at least 3 hours
|
||||
rank-print=__1__ tried to deconstruct something.
|
||||
@@ -1,3 +0,0 @@
|
||||
[DeconControl]
|
||||
player-print=Je moet minstens 3 uur gespeeld hebben om dit uit te voeren.
|
||||
rank-print=__1__ heeft geprobeerd iets te deconstrueren.
|
||||
@@ -1,3 +0,0 @@
|
||||
[DeconControl]
|
||||
player-print=Du har inte tillåtelse med det här just nu. Du behöver ha rang "Regular" vilket kan uppnås genom 3 timmar inne i spelet (den här kartan) hos Explosive Gaming.
|
||||
rank-print=__1__ försökte dekonstruera något.
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"name": "DeconControl",
|
||||
"version": "4.0.0",
|
||||
"description": "Allows control over decon rights, if ExpGamingCore.Role is not installed it will allow admins to instant remove trees and thats it.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Trees",
|
||||
"Decon",
|
||||
"Protection",
|
||||
"Admin",
|
||||
"Tool",
|
||||
"Report"
|
||||
],
|
||||
"author": "Cooldude2606",
|
||||
"contact": "Discord: Cooldude2606#5241",
|
||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Server": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"ExpGamingAdmin.Warnings": "?^4.0.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0",
|
||||
"ExpGamingAdmin": "?^4.0.0"
|
||||
},
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
--- Adds a custom ban function to the admin command set.
|
||||
-- @module ExpGamingAdmin.Ban@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local AdminGui = require('ExpGamingAdmin.Gui')
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color -- FactorioStdLib.Color@^0.8.0
|
||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
|
||||
end
|
||||
}
|
||||
|
||||
-- Function Define
|
||||
AdminGui.add_button('Ban','utility/danger_icon',{'ExpGamingAdmin.tooltip-ban'},function(player,byPlayer)
|
||||
Admin.open(byPlayer,player,'Ban')
|
||||
end)
|
||||
|
||||
function Admin.ban(player,by_player,reason)
|
||||
player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
reason = Admin.create_reason(reason,by_player_name)
|
||||
Admin.set_banned(player,true)
|
||||
if Sync then Sync.emit_embedded{
|
||||
title='Player Ban',
|
||||
color=Color.to_hex(defines.textcolor.crit),
|
||||
description='There was a player banned.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
} end
|
||||
if Admin.move_inventory then Admin.move_inventory(player) end
|
||||
Server.interface(game.ban_player,true,player,reason)
|
||||
end
|
||||
|
||||
Admin.add_action('Ban',Admin.ban)
|
||||
|
||||
-- Module Return
|
||||
return setmetatable(ThisModule,{__call=Admin.ban})
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin.Ban",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a custom ban function to the admin command set.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Ban",
|
||||
"Admin",
|
||||
"Set",
|
||||
"ExpGaming"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingAdmin.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Server": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"FactorioStdLib.Color": "?^0.8.0",
|
||||
"ExpGamingCore.Sync": "?^4.0.0",
|
||||
"ExpGamingAdmin.ClearInventory": "?^4.0.0",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingAdmin@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
--- Adds a function to clear a players inventory and move the items to spawn.
|
||||
-- @module ExpGamingAdmin.ClearInventory@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {}
|
||||
|
||||
-- Function Define
|
||||
local inventories = {
|
||||
defines.inventory.player_main,
|
||||
defines.inventory.player_quickbar,
|
||||
defines.inventory.player_trash,
|
||||
defines.inventory.player_guns,
|
||||
defines.inventory.player_ammo,
|
||||
defines.inventory.player_armor
|
||||
}
|
||||
|
||||
function Admin.move_item_to_spawn(item,surface,chests)
|
||||
chests = chests or surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {}
|
||||
local chest = nil
|
||||
while not chest or not chest.get_inventory(defines.inventory.chest).can_insert(item) do
|
||||
chest = table.remove(chests,1)
|
||||
if not chest then chest = surface.create_entity{
|
||||
name='iron-chest',
|
||||
position=surface.find_non_colliding_position('iron-chest',{0,0},32,1)
|
||||
} end
|
||||
end
|
||||
chest.get_inventory(defines.inventory.chest).insert(item)
|
||||
table.insert(chests,chest)
|
||||
return chests
|
||||
end
|
||||
|
||||
function Admin.move_inventory(player)
|
||||
player = Game.get_player(player)
|
||||
if not player then return end
|
||||
local chests = player.surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {}
|
||||
for _,_inventory in pairs(inventories) do
|
||||
local inventory = player.get_inventory(_inventory)
|
||||
if inventory then
|
||||
for item,count in pairs(inventory.get_contents()) do
|
||||
item = {name=item,count=count}
|
||||
chests = Admin.move_item_to_spawn(item,player.surface,chests)
|
||||
end
|
||||
inventory.clear()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Admin.add_action('Clear Inventory',Admin.move_inventory)
|
||||
-- Module Return
|
||||
return setmetatable(ThisModule,{__call=Admin.move_inventory})
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin.ClearInventory",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a function to clear a players inventoy and move the items to spawn.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Spawn",
|
||||
"Items",
|
||||
"Admin",
|
||||
"Move",
|
||||
"Clear",
|
||||
"Inventory"
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingAdmin@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingAdmin.Commands@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
|
||||
--- Used to clear all parts of a player, removing warnings, reports, jail and temp ban
|
||||
-- @command clear-all
|
||||
-- @param player the player to clear
|
||||
commands.add_command('clear-all', 'Clears a player of any temp-ban, reports or warnings', {
|
||||
['player']={true,'player'}
|
||||
}, function(event,args)
|
||||
Admin.clear_player(args.player,event.player_index)
|
||||
end)
|
||||
|
||||
return {
|
||||
on_init = function(self)
|
||||
if loaded_modules['ExpGamingAdmin.TempBan'] then verbose('ExpGamingAdmin.TempBan is installed; Loading tempban src') require(module_path..'/src/tempban',{self=Admin}) end
|
||||
if loaded_modules['ExpGamingAdmin.Jail'] then verbose('ExpGamingAdmin.Jail is installed; Loading tempban src') require(module_path..'/src/jail',{self=Admin}) end
|
||||
if loaded_modules['ExpGamingAdmin.Warnings'] then verbose('ExpGamingAdmin.Warnings is installed; Loading tempban src') require(module_path..'/src/warnings',{self=Admin}) end
|
||||
if loaded_modules['ExpGamingAdmin.Reports'] then verbose('ExpGamingAdmin.Reports is installed; Loading tempban src') require(module_path..'/src/reports',{self=Admin}) end
|
||||
if loaded_modules['ExpGamingAdmin.ClearInventory'] then verbose('ExpGamingAdmin.ClearInventory is installed; Loading tempban src') require(module_path..'/src/clear',{self=Admin}) end
|
||||
end
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin.Commands",
|
||||
"version": "4.0.0",
|
||||
"description": "Admins many of the admin featues which the script can use as in game commands.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"ExpGaming",
|
||||
"Admin",
|
||||
"Tools",
|
||||
"Commands",
|
||||
"Temp ban",
|
||||
"Jail",
|
||||
"Clear Inventory",
|
||||
"Report",
|
||||
"Warnings"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingAdmin.TempBan": "?^4.0.0",
|
||||
"ExpGamingAdmin.Jail": "?^4.0.0",
|
||||
"ExpGamingAdmin.Warnings": "?^4.0.0",
|
||||
"ExpGamingAdmin.Reports": "?^4.0.0",
|
||||
"ExpGamingAdmin.ClearInventory": "?^4.0.0",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingAdmin@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
local Admin = self
|
||||
|
||||
--- Clears a players inventory and moves it to chests in spawn
|
||||
-- @command clear-inv
|
||||
-- @param player the player to clear the inventory of
|
||||
commands.add_command('clear-inv', 'Clears a player\'s invetory', {
|
||||
['player'] = {true,'player-rank'}
|
||||
}, function(event,args)
|
||||
local player = args.player
|
||||
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
|
||||
Admin.move_inventory(player)
|
||||
end)
|
||||
@@ -1,30 +0,0 @@
|
||||
local Admin = self
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
|
||||
--- Used to jail a player which stops them from moving
|
||||
-- @command jail
|
||||
-- @param player the player to be jailed
|
||||
-- @param[opt] reason the reason the player was jailed
|
||||
commands.add_command('jail', 'Jails a player', {
|
||||
['player']={true,'player-rank'},
|
||||
['reason']={false,'string-inf'}
|
||||
}, function(event,args)
|
||||
local player = args.player
|
||||
local reason = args.reason
|
||||
if Role.has_flag(player,'not_reportable') then player_return{'ExpGamingAdmin.cant-report',args.player.name} return commands.error end
|
||||
if Admin.is_banned(player) then player_return{'ExpGamingAdmin.cant-report-ban',args.player.name} return commands.error end
|
||||
Admin.jail(player,event.player_index,reason)
|
||||
end)
|
||||
|
||||
--- Used to unjail a player
|
||||
-- @command unjail
|
||||
-- @param player the player to unjail
|
||||
commands.add_command('unjail', 'Returns a player\'s old rank', {
|
||||
['player']={true,'player'}
|
||||
}, function(event,args)
|
||||
local player = args.player
|
||||
if Admin.is_banned(player,true) ~= 'jail' then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
|
||||
Admin.set_banned(player,false)
|
||||
Server.interface(Role.revert,true,player,event.player_index,2)
|
||||
end)
|
||||
@@ -1,35 +0,0 @@
|
||||
local Admin = self
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
|
||||
--- Reports a player
|
||||
-- @command report
|
||||
-- @param player the player to report
|
||||
-- @param[opt] reason the reason why the player was reported
|
||||
commands.add_command('report', 'Reports a player', {
|
||||
['player']={true,'player-rank'},
|
||||
['reason']={false,'string-inf'}
|
||||
}, function(event,args)
|
||||
local _player = Game.get_player(event)
|
||||
local player = args.player
|
||||
local reason = args.reason
|
||||
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
|
||||
if Role.has_flag(player,'not_reportable') then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end
|
||||
for _,report in pairs(global.addons.reports.reports) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end end
|
||||
for _,report in pairs(global.addons.reports.verified) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end end
|
||||
Admin.report(player,event.player_index,reason)
|
||||
end)
|
||||
|
||||
--- Clears the reports of the player
|
||||
-- @command clear-reports
|
||||
-- @param player the player to clear the reports of
|
||||
commands.add_command('clear-reports', 'Clears a player\'s reports', {
|
||||
['player'] = {true,function(value)
|
||||
local player,err = commands.validate['player'](value)
|
||||
if err then return commands.error(err) end
|
||||
local rtn = not Admin.is_banned(player) and player
|
||||
if not rtn then return commands.error{'ExpGamingAdmin.cant-report-ban',value} end return rtn
|
||||
end}
|
||||
}, function(event,args)
|
||||
Admin.clear_reports(args.player,event.player_index)
|
||||
end)
|
||||
@@ -1,15 +0,0 @@
|
||||
local Admin = self
|
||||
|
||||
--- Used to temp ban a player and give a reason
|
||||
-- @command temp-ban
|
||||
-- @param player the player to temp ban
|
||||
-- @param[opt] reason the reason for the ban
|
||||
commands.add_command('temp-ban', 'Temporarily ban a player', {
|
||||
['player']={true,'player-rank'},
|
||||
['reason']={false,'string-inf'}
|
||||
}, function(event,args)
|
||||
local player = args.player
|
||||
local reason = args.reason
|
||||
if Admin.is_banned(player) and Admin.is_banned(player,true) ~= 'jail' then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
|
||||
Admin.temp_ban(player,event.player_index,reason)
|
||||
end)
|
||||
@@ -1,28 +0,0 @@
|
||||
local Admin = self
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
|
||||
--- Gives a warning to a player
|
||||
-- @command warn
|
||||
-- @param player the player to give a warning to
|
||||
-- @param[opt] reason the reason the player was given a warning
|
||||
commands.add_command('warn', 'Gives a player a warning', {
|
||||
['player']={true,'player-rank'},
|
||||
['reason']={false,'string-inf'}
|
||||
}, function(event,args)
|
||||
local player = args.player
|
||||
local reason = args.reason
|
||||
if Admin.is_banned(player) then player_return{'ExpGamingAdmin.cant-report-ban',args.player.name} return commands.error end
|
||||
if Role.has_flag(player,'not_reportable') then player_return{'ExpGamingAdmin.cant-report',args.player.name} return commands.error end
|
||||
Admin.give_warning(player,event.player_index,reason)
|
||||
end)
|
||||
|
||||
--- Clears the warning of a player
|
||||
-- @command clear-warnings
|
||||
-- @param player the player to clear the warning of
|
||||
commands.add_command('clear-warnings', 'Clears a player\'s warnings', {
|
||||
['player'] = {true,'player'}
|
||||
}, function(event,args)
|
||||
local player = args.player
|
||||
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
|
||||
Admin.clear_warnings(player,event.player_index)
|
||||
end)
|
||||
@@ -1,202 +0,0 @@
|
||||
--- Adds a gui that can be used to access all the admin commands.
|
||||
-- @module ExpGamingAdmin.Gui@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias AdminGui
|
||||
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local Gui = require('ExpGamingCore.Gui')
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local playerInfo -- ExpGamingPlayer.playerInfo@^4.0.0
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local AdminGui = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo')
|
||||
else playerInfo = function(player,frame)
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'ExpGamingAdmin.no-info-file'}
|
||||
}
|
||||
end end
|
||||
--code
|
||||
end,
|
||||
buttons={}
|
||||
}
|
||||
|
||||
function Admin.open(player,pre_select_player,pre_select_action)
|
||||
Gui.center.clear(player)
|
||||
Admin.center(player,pre_select_player,pre_select_action)
|
||||
end
|
||||
|
||||
-- Function Define
|
||||
function AdminGui.add_button(name,caption,tooltip,callback)
|
||||
AdminGui.buttons[name] = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-gui-'..name,
|
||||
caption=caption,
|
||||
tooltip=tooltip
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
local pre_select_player = parent.player and parent.player.caption or nil
|
||||
callback(pre_select_player,event.player_index)
|
||||
end)
|
||||
end
|
||||
|
||||
function AdminGui.draw(frame,filter_buttons)
|
||||
local frame = frame.add{
|
||||
type='flow',
|
||||
name='admin'
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption='',
|
||||
name='player'
|
||||
}.style.visible = false
|
||||
local function format(btn)
|
||||
btn.style.height = 30
|
||||
btn.style.width = 30
|
||||
end
|
||||
for name,button in pairs(AdminGui.buttons) do
|
||||
if not filter_buttons or filter_buttons[name] then format(button(frame)) end
|
||||
end
|
||||
return frame.player
|
||||
end
|
||||
|
||||
-- Gui Define
|
||||
local function get_players(_player,root_frame,state)
|
||||
local players = {'Select Player'}
|
||||
local _players = state and game.players or game.connected_players
|
||||
for _,player in pairs(_players) do
|
||||
if player.name ~= _player.name then
|
||||
if not Admin.is_banned or not Admin.is_banned(player) then
|
||||
table.insert(players,player.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
return players
|
||||
end
|
||||
|
||||
local online_check = Gui.inputs.add_checkbox('online-check-admin-commands',false,'Show Offline',false,function(player,element)
|
||||
element.parent['player-drop-down-admin-commands'].items = get_players(player,element.parent,true)
|
||||
element.parent['player-drop-down-admin-commands'].selected_index = 1
|
||||
end,function(player,element)
|
||||
element.parent['player-drop-down-admin-commands'].items = get_players(player,element.parent,false)
|
||||
element.parent['player-drop-down-admin-commands'].selected_index = 1
|
||||
end)
|
||||
|
||||
local player_drop_down = Gui.inputs.add_drop_down('player-drop-down-admin-commands',get_players,1,function(player,selected,items,element)
|
||||
element.parent.parent.player.caption = selected
|
||||
local player_info_flow = element.parent.parent.info_flow
|
||||
player_info_flow.clear()
|
||||
if selected == 'Select Player' then return
|
||||
else playerInfo(selected,player_info_flow,true) end
|
||||
local role = Role.get_highest(player)
|
||||
local _role = Role.get_highest(selected)
|
||||
if role.index >= _role.index then element.parent.warning.caption = {'ExpGamingAdmin.warning'}
|
||||
else element.parent.warning.caption = '' end
|
||||
end)
|
||||
|
||||
local reason_input = Gui.inputs.add_text('reason-input-admin-commands',false,'Enter Reason',function(player,text,element)
|
||||
if string.len(text) < 20 or text == 'Enter Reason' then
|
||||
element.parent.warning.caption = {'ExpGamingAdmin.short-reason'}
|
||||
else
|
||||
element.parent.warning.caption = ''
|
||||
end
|
||||
end)
|
||||
|
||||
local action_drop_down = Gui.inputs.add_drop_down('action-drop-down-rank-change',function() return {'Select Action',unpack(Admin.action_names)} end,1,function(player,selected,items,element)
|
||||
element.parent.parent.action.caption = selected
|
||||
if selected == 'Jail' or selected == 'Kick' or selected == 'Ban' or selected == 'Temp Ban' then
|
||||
element.parent['reason-input-admin-commands'].style.visible = true
|
||||
else
|
||||
element.parent['reason-input-admin-commands'].style.visible = false
|
||||
end
|
||||
end)
|
||||
|
||||
local take_action = Gui.inputs{
|
||||
type='button',
|
||||
name='admin-commands-take',
|
||||
caption={'ExpGamingAdmin.take-action'}
|
||||
}:on_event('click',function(event)
|
||||
local dropdowns = event.element.parent
|
||||
local role = Role.get_highest(event.player_index)
|
||||
local _action= dropdowns.parent.action.caption ~= 'Select Action' and dropdowns.parent.action.caption or nil
|
||||
local _player = Game.get_player(dropdowns.parent.player.caption)
|
||||
if not _player or not _action then dropdowns.warning.caption = {'ExpGamingAdmin.invalid'} return end
|
||||
local _role = Role.get_highest(_player)
|
||||
if role.index >= _role.index then dropdowns.warning.caption = {'ExpGamingAdmin.rank-high'} return end
|
||||
local _reason = dropdowns['reason-input-admin-commands'] and dropdowns['reason-input-admin-commands'].text
|
||||
if (_action == 'Jail' or _action == 'Kick' or _action == 'Ban' or _action == 'Temp Ban') and (_reason == 'Enter Reason' or string.len(_reason) < 10) then return end
|
||||
Admin.take_action(_action,_player,event.player_index,_reason)
|
||||
Gui.center.clear(event)
|
||||
end)
|
||||
|
||||
Admin.center = Gui.center{
|
||||
name='admin-commands',
|
||||
caption='utility/danger_icon',
|
||||
tooltip={'ExpGamingAdmin.tooltip'},
|
||||
draw=function(self,frame,pre_select_player,pre_select_action)
|
||||
frame.caption={'ExpGamingAdmin.name'}
|
||||
frame = frame.add{
|
||||
type='flow',
|
||||
direction='horizontal'
|
||||
}
|
||||
local dropdowns = frame.add{
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
local player_info_flow = frame.add{
|
||||
name='info_flow',
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
player_info_flow.style.height = 280
|
||||
player_info_flow.style.width = 200
|
||||
local label = dropdowns.add{
|
||||
type='label',
|
||||
caption={'ExpGamingAdmin.message'}
|
||||
}
|
||||
label.style.single_line = false
|
||||
label.style.width = 200
|
||||
online_check:draw(dropdowns)
|
||||
local _drop = player_drop_down:draw(dropdowns)
|
||||
if pre_select_player then Gui.set_dropdown_index(_drop,pre_select_player.name) end
|
||||
_drop = action_drop_down:draw(dropdowns)
|
||||
Gui.set_dropdown_index(_drop,pre_select_action)
|
||||
local _text = reason_input:draw(dropdowns)
|
||||
if pre_select_action == 'Jail' or pre_select_action == 'Kick' or pre_select_action == 'Ban' then
|
||||
_text.style.visible = true else _text.style.visible = false
|
||||
end
|
||||
if pre_select_player then playerInfo(pre_select_player,player_info_flow,true) end
|
||||
_text.style.width = 200
|
||||
label = dropdowns.add{
|
||||
name='warning',
|
||||
type='label',
|
||||
caption='',
|
||||
style='bold_red_label'
|
||||
}
|
||||
label.style.single_line = false
|
||||
label.style.width = 200
|
||||
take_action:draw(dropdowns)
|
||||
local caption = pre_select_player and pre_select_player.name or ''
|
||||
frame.add{
|
||||
name='player',
|
||||
type='label',
|
||||
caption=caption
|
||||
}.style.visible = false
|
||||
caption = pre_select_action or ''
|
||||
frame.add{
|
||||
name='action',
|
||||
type='label',
|
||||
caption=caption
|
||||
}.style.visible = false
|
||||
end
|
||||
}
|
||||
|
||||
-- Module Return
|
||||
-- calling will draw the admin buttons to that frame
|
||||
return setmetatable(AdminGui,{__call=function(self,...) return self.draw(...) end})
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin.Gui",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a gui that can be used to access all the admin commands.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Admin",
|
||||
"ExpGaming",
|
||||
"Commands",
|
||||
"Gui"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Role": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingPlayer": "?^4.0.0",
|
||||
"ExpGamingPlayer.playerInfo": "?^4.0.0",
|
||||
"mod-gui": "*",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingAdmin@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
--- Adds a jail function to the admin set, require ExpGamingRole to work.
|
||||
-- @module ExpGamingAdmin.Jail@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local AdminGui = require('ExpGamingAdmin.Gui')
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
local Color -- FactorioStdLib.Color@^0.8.0
|
||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
|
||||
end
|
||||
}
|
||||
|
||||
-- Function Define
|
||||
AdminGui.add_button('jail','utility/clock',{'ExpGamingAdmin.tooltip-jail'},function(player,byPlayer)
|
||||
Admin.open(byPlayer,player,'Jail')
|
||||
end)
|
||||
|
||||
function Admin.jail(player,by_player,reason)
|
||||
player, by_player = Admin.valid_players(player,by_player)
|
||||
if not player then return end
|
||||
reason = Admin.create_reason(reason,by_player.name)
|
||||
Admin.set_banned(player,'jail')
|
||||
if Sync then Sync.emit_embedded{
|
||||
title='Player Jail',
|
||||
color=Color.to_hex(defines.textcolor.med),
|
||||
description='There was a player jailed.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player.name,
|
||||
['Reason:']=reason
|
||||
} end
|
||||
Role.meta.last_jail = player.name
|
||||
player.driving = false
|
||||
Server.interface(Role.assign,true,player,'Jail',by_player.name)
|
||||
Server.interface(Role.unassign,true,player,Role.get(player),by_player.name)
|
||||
end
|
||||
|
||||
Admin.add_action('Jail',Admin.jail)
|
||||
|
||||
-- Module Return
|
||||
return setmetatable(ThisModule,{__call=Admin.jail})
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin.Jail",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a jail function to the admin set, require ExpGamingRole to work.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Jail",
|
||||
"Roles",
|
||||
"Admin",
|
||||
"ExpGaming"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingAdmin.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Server": "^4.0.0",
|
||||
"ExpGamingCore.Role": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"FactorioStdLib.Color": "?^0.8.0",
|
||||
"ExpGamingCore.Sync": "?^4.0.0",
|
||||
"ExpGamingAdmin.ClearInventory": "?^4.0.0",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingAdmin@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
--- Adds a kick function to the admin function set.
|
||||
-- @module ExpGamingAdmin.Kick@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local AdminGui = require('ExpGamingAdmin.Gui')
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color -- FactorioStdLib.Color@^0.8.0
|
||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
|
||||
end
|
||||
}
|
||||
-- Function Define
|
||||
AdminGui.add_button('Kick','utility/warning_icon',{'ExpGamingAdmin.tooltip-kick'},function(player,byPlayer)
|
||||
Admin.open(byPlayer,player,'Kick')
|
||||
end)
|
||||
|
||||
function Admin.kick(player,by_player,reason)
|
||||
player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
reason = Admin.create_reason(reason,by_player_name)
|
||||
if Sync then Sync.emit_embedded{
|
||||
title='Player Kick',
|
||||
color=Color.to_hex(defines.textcolor.high),
|
||||
description='There was a player kicked.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
} end
|
||||
if Admin.move_inventory then Admin.move_inventory(player) end
|
||||
Server.interface(game.kick_player,true,player,reason)
|
||||
end
|
||||
|
||||
Admin.add_action('Kick',Admin.kick)
|
||||
|
||||
-- Module Return
|
||||
return setmetatable(ThisModule,{__call=Admin.kick})
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin.Kick",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a kick function to the admin function set.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Admin",
|
||||
"ExpGaming",
|
||||
"Kick",
|
||||
"Commands"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingAdmin.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Server": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"FactorioStdLib.Color": "?^0.8.0",
|
||||
"ExpGamingCore.Sync": "?^4.0.0",
|
||||
"ExpGamingAdmin.ClearInventory": "?^4.0.0",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingAdmin@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
--- Adds a report system into the game that can also push notifactions to discord.
|
||||
-- @module ExpGamingAdmin.Reports@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
local Gui = require('ExpGamingCore.Gui')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color -- FactorioStdLib.Color@^0.8.0
|
||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
|
||||
end
|
||||
}
|
||||
|
||||
-- Global Define
|
||||
local global = {
|
||||
reports={},
|
||||
verified={}
|
||||
}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
|
||||
-- Local Variables
|
||||
local report_to_warnings = 1 -- used in count_reports
|
||||
local verified_to_warnings = 3 -- used in count_reports
|
||||
local reports_needed_for_jail = 6
|
||||
|
||||
-- Function Define
|
||||
local function report_message(player,by_player,reason)
|
||||
player, by_player = Admin.valid_players(player,by_player)
|
||||
if not player then return end
|
||||
if Admin.is_banned(player,true) == 'report' then return end
|
||||
Role.print(Role.meta.groups.User.lowest,{'ExpGamingAdmin.low-print',player.name,reason},defines.textcolor.info,true)
|
||||
Role.print(Role.meta.groups.Admin.lowest,{'ExpGamingAdmin.high-print',player.name,by_player.name,reason},defines.textcolor.med)
|
||||
if Sync then Sync.emit_embedded{
|
||||
title='Player Report',
|
||||
color=Color.to_hex(defines.textcolor.med),
|
||||
description='A player was reported.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player.name,
|
||||
['Reason:']=reason
|
||||
} end
|
||||
end
|
||||
|
||||
local function cheak_reports(player)
|
||||
player = Game.get_player(player)
|
||||
if not player then return end
|
||||
local reports = Admin.count_reports(player)
|
||||
if reports >= reports_needed_for_jail and Role.get_highest(player).group.name ~= 'Jail' then
|
||||
Admin.jail(player,'<server>','Too many user reports. Contact an Admin to be unjailed.')
|
||||
end
|
||||
end
|
||||
|
||||
function Admin.count_reports(player)
|
||||
player = Game.get_player(player)
|
||||
if not player then return 0 end
|
||||
local _count = 0
|
||||
if global.reports[player.name] then
|
||||
for _ in pairs(global.reports[player.name]) do
|
||||
_count=_count+report_to_warnings
|
||||
end
|
||||
end
|
||||
if global.verified[player.name] then
|
||||
for _ in pairs(global.verified[player.name]) do
|
||||
_count=_count+verified_to_warnings
|
||||
end
|
||||
end
|
||||
return _count
|
||||
end
|
||||
|
||||
function Admin.report(player,by_player,reason)
|
||||
player, by_player = Admin.valid_players(player,by_player)
|
||||
if not player or Role.has_flag(player,'not_reportable') then return end
|
||||
if Admin.is_banned(by_player) or Role.has_flag(by_player,'is_jail') then return end
|
||||
if Role.has_flag(by_player,'is_verified') then
|
||||
global.verified[player.name] = global.verified[player.name] or {}
|
||||
local reports = global.verified[player.name]
|
||||
for _,value in pairs(reports) do
|
||||
if value[1] == by_player.name then return end
|
||||
end
|
||||
table.insert(reports,{by_player.name,reason})
|
||||
else
|
||||
global.reports[player.name] = global.reports[player.name] or {}
|
||||
local reports = global.reports[player.name]
|
||||
for _,value in pairs(reports) do
|
||||
if value[1] == by_player.name then return end
|
||||
end
|
||||
table.insert(reports,{by_player.name,reason})
|
||||
end
|
||||
report_message(player,by_player,reason)
|
||||
cheak_reports(player)
|
||||
end
|
||||
|
||||
function Admin.clear_reports(player,by_player,no_emit)
|
||||
player, by_player = Admin.valid_players(player,by_player)
|
||||
if not player then return end
|
||||
global.reports[player.name]={}
|
||||
global.verified[player.name]={}
|
||||
if not no_emit and Sync then
|
||||
Sync.emit_embedded{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.textcolor.low),
|
||||
description='A player had their reports cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player.name,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local confirm_report = Gui.inputs{
|
||||
type='button',
|
||||
name='admin-report-confirm',
|
||||
caption='utility/spawn_flag',
|
||||
tooltip={'ExpGamingAdmin.report'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
local player = Game.get_player(parent.player.caption)
|
||||
local reason = parent.reason.text
|
||||
Admin.report(player,event.player_index,reason)
|
||||
Gui.center.clear(event.player_index)
|
||||
end)
|
||||
|
||||
Admin.report_btn = Gui.inputs{
|
||||
type='button',
|
||||
name='admin-report',
|
||||
caption='utility/spawn_flag',
|
||||
tooltip={'ExpGamingAdmin.report'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
local player = Game.get_player(parent.children[1].name)
|
||||
if not player then return end
|
||||
local _player = Game.get_player(event)
|
||||
Gui.center.clear(_player)
|
||||
local frame = Gui.center.get_flow(_player).add{
|
||||
type='frame',
|
||||
name='report-gui'
|
||||
}
|
||||
_player.opened=frame
|
||||
frame.caption={'ExpGamingAdmin.report'}
|
||||
frame.add{
|
||||
type='textfield',
|
||||
name='reason'
|
||||
}.style.width = 300
|
||||
local btn = confirm_report:draw(frame)
|
||||
btn.style.height = 30
|
||||
btn.style.width = 30
|
||||
frame.add{
|
||||
type='label',
|
||||
name='player',
|
||||
caption=player.name
|
||||
}.style.visible = false
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
return ThisModule
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin.Reports",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a report system into the game that can also push notifactions to discord.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Report",
|
||||
"Player",
|
||||
"Admin",
|
||||
"ExpGaming",
|
||||
"Player List",
|
||||
"Commands"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Server": "^4.0.0",
|
||||
"ExpGamingCore.Role": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"FactorioStdLib.Color": "?^0.8.0",
|
||||
"ExpGamingCore.Sync": "?^4.0.0",
|
||||
"ExpGamingCore.Gui": "^4.0.0",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingAdmin@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
--- Adds three function to admin: tp, bring and go to, these all move the player
|
||||
-- @module ExpGamingAdmin.Teleport@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local AdminGui = require('ExpGamingAdmin.Gui')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {}
|
||||
|
||||
-- Function Define
|
||||
AdminGui.add_button('Go To','utility/export_slot',{'ExpGamingAdmin.tooltip-go-to'},function(player,byPlayer)
|
||||
Admin.go_to(player,byPlayer)
|
||||
end)
|
||||
AdminGui.add_button('Bring','utility/import_slot',{'ExpGamingAdmin.tooltip-bring'},function(player,byPlayer)
|
||||
Admin.bring(player,byPlayer)
|
||||
end)
|
||||
|
||||
function Admin.tp(from_player, to_player)
|
||||
local _from_player = Game.get_player(from_player)
|
||||
local _to_player = Game.get_player(to_player)
|
||||
if not _from_player or not _to_player then return end
|
||||
_from_player.teleport(_to_player.surface.find_non_colliding_position('player',_to_player.position,32,1),_to_player.surface)
|
||||
end
|
||||
|
||||
function Admin.go_to(player,by_player)
|
||||
Admin.tp(by_player, player)
|
||||
end
|
||||
|
||||
function Admin.bring(player,by_player)
|
||||
Admin.tp(player, by_player)
|
||||
end
|
||||
|
||||
Admin.add_action('Go To',Admin.go_to)
|
||||
Admin.add_action('Bring',Admin.bring)
|
||||
|
||||
-- Module Return
|
||||
return setmetatable(ThisModule,{__call=Admin.tp})
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin.Teleport",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds three function to admin: tp, bring and go to, these all move the player.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Tp",
|
||||
"Bring",
|
||||
"Go To",
|
||||
"Admin",
|
||||
"ExpGaming",
|
||||
"Teleport",
|
||||
"Commands"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingAdmin.Gui": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingAdmin@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
--- Adds a temp ban function to the admin set, requires ExpGamingCore.Role to work.
|
||||
-- @module ExpGamingAdmin.KicTempBan@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color -- FactorioStdLib.Color@^0.8.0
|
||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
|
||||
end
|
||||
}
|
||||
|
||||
-- Function Define
|
||||
function Admin.temp_ban(player,by_player,reason)
|
||||
local player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
if not player or Admin.is_banned(player) then return end
|
||||
Admin.set_banned(player,'temp')
|
||||
if Sync then Sync.emit_embedded{
|
||||
title='Player Temp-Ban',
|
||||
color=Color.to_hex(defines.textcolor.high),
|
||||
description='A player was jailed.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=Admin.create_reason(reason,by_player_name)
|
||||
} end
|
||||
game.print({'ExpGamingAdmin.temp-ban',player.name,by_player_name,reason},defines.textcolor.info)
|
||||
if Admin.move_inventory then Admin.move_inventory(player) end
|
||||
Role.meta.last_jail = player.name
|
||||
Server.interface(Role.unassign,true,player,Role.get(player),by_player_name)
|
||||
Server.interface(Role.assign,true,player,'Jail',by_player_name)
|
||||
end
|
||||
|
||||
Admin.add_action('Temp Ban',Admin.temp_ban)
|
||||
|
||||
-- Module Return
|
||||
return setmetatable(ThisModule,{__call=Admin.temp_ban})
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin.TempBan",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a temp ban function to the admin set, requires ExpGamingCore.Role to work.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Jail",
|
||||
"Temp Ban",
|
||||
"Admin",
|
||||
"ExpGaming",
|
||||
"Roles"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Server": "^4.0.0",
|
||||
"ExpGamingCore.Role": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"FactorioStdLib.Color": "?^0.8.0",
|
||||
"ExpGamingCore.Sync": "?^4.0.0",
|
||||
"ExpGamingAdmin.ClearInventory": "?^4.0.0",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingAdmin@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
--- Adds a warning system into the admin set which can be used by admins and the script.
|
||||
-- @module ExpGamingAdmin.Warnings@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color -- FactorioStdLib.Color@^0.8.0
|
||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||
|
||||
-- Local Variables
|
||||
local take_action = 8 -- the first admin given warning jumps to this number, this case kick-warn is giving
|
||||
local remove_warnings_time = {}
|
||||
local min_time_to_remove_warning = 18000 -- this is in ticks
|
||||
local punishments = {
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'message',{'ExpGamingAdmin-Warnings.message'},defines.textcolor.info},
|
||||
{'message',{'ExpGamingAdmin-Warnings.message'},defines.textcolor.info},
|
||||
{'message',{'ExpGamingAdmin-Warnings.kick-warn'},defines.textcolor.med},
|
||||
{'kick'},
|
||||
{'message',{'ExpGamingAdmin-Warnings.temp-warn'},defines.textcolor.high},
|
||||
{'temp-ban'},
|
||||
{'message',{'ExpGamingAdmin-Warnings.ban-warn'},defines.textcolor.high},
|
||||
{'message',{'ExpGamingAdmin-Warnings.last-warn'},defines.textcolor.crit},
|
||||
{'ban'}
|
||||
}
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
|
||||
if loaded_modules['ExpGamingAdmin.Reports'] then
|
||||
take_action = take_action + 1
|
||||
table.insert(punishments,take_action,{'report',{'ExpGamingAdmin-Warnings.reported'},defines.textcolor.med})
|
||||
end
|
||||
end,
|
||||
on_post=function()
|
||||
local highest = nil
|
||||
for _,role in pairs(Role.roles) do
|
||||
local power = role.index
|
||||
if not highest and not role.not_reportable then highest = power-1 end
|
||||
local _power = power; if highest then _power = power-highest end
|
||||
if role.not_reportable then remove_warnings_time[power] = 0
|
||||
else remove_warnings_time[power] = min_time_to_remove_warning*_power end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
-- Global Define
|
||||
local global = {}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
|
||||
-- Function Define
|
||||
local function give_punishment(player,by_player,reason)
|
||||
player, by_player = Admin.valid_players(player,by_player)
|
||||
reason = reason or 'No Other Reason'
|
||||
local warnings = Admin.get_warnings(player)
|
||||
local punishment = punishments[warnings]
|
||||
if not punishment or punishment[1] == 'nothing' then return
|
||||
elseif punishment[1] == 'message' then
|
||||
local message = punishment[2]
|
||||
local colour = punishment[3]
|
||||
player_return(message,colour,player)
|
||||
elseif punishment[1] == 'report' then
|
||||
local message = punishment[2]
|
||||
local colour = punishment[3]
|
||||
player_return(message,colour,player)
|
||||
Admin.report(player,'<server>',reason)
|
||||
elseif punishment[1] == 'kick' then
|
||||
Admin.kick(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
|
||||
elseif punishment[1] == 'temp-ban' then
|
||||
Admin.temp_ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
|
||||
elseif punishment[1] == 'ban' then
|
||||
Admin.ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
|
||||
end
|
||||
end
|
||||
|
||||
function Admin.get_warnings(player)
|
||||
player = Game.get_player(player)
|
||||
return global[player.name] or 0
|
||||
end
|
||||
|
||||
function Admin.give_warning(player,by_player,reason,min)
|
||||
player, by_player = Admin.valid_players(player,by_player)
|
||||
if not player then return end
|
||||
min = Game.get_player(by_player) and Game.get_player(by_player) ~= SERVER and take_action or min or 0
|
||||
local warnings = Admin.get_warnings(player)
|
||||
if warnings < min then warnings = min-1 end
|
||||
warnings = warnings+1
|
||||
global[player.name] = warnings
|
||||
if warnings > take_action then
|
||||
player_return({'ExpGamingAdmin-Warnings.warning-given-by',by_player.name},defines.textcolor.info,player)
|
||||
game.print({'ExpGamingAdmin-Warnings.player-warning',player.name,by_player.name,reason})
|
||||
end
|
||||
give_punishment(player,by_player,reason)
|
||||
end
|
||||
|
||||
function Admin.clear_warnings(player,by_player,no_emit)
|
||||
player, by_player = Admin.valid_players(player,by_player)
|
||||
if not player then return end
|
||||
global[player.name]=nil
|
||||
if not no_emit and Sync then
|
||||
Sync.emit_embedded{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.textcolor.low),
|
||||
description='A player had their warnings cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player.name,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- Event Handlers Define
|
||||
Event.add(defines.events.on_tick,function(event)
|
||||
if (game.tick % min_time_to_remove_warning) == 0 then
|
||||
for name,warnings in pairs(global) do
|
||||
if warnings > 0 then
|
||||
local role = Role.get_highest(name)
|
||||
local time_to_remove = remove_warnings_time[role.index]
|
||||
if (game.tick % time_to_remove) == 0 then
|
||||
global[name]=warnings-1
|
||||
if global[name] > 5 then
|
||||
player_return({'ExpGamingAdmin-Warnings.remove-warn',global[name],tick_to_display_format(time_to_remove)},defines.textcolor.low,name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
return ThisModule
|
||||
@@ -1,11 +0,0 @@
|
||||
[ExpGamingAdmin-Warnings]
|
||||
warning-given-by=This Warnings Was Given By: __1__
|
||||
player-warning=__1__ was given a warning by __2__ reason: __3__
|
||||
temp-ban=__1__ was temp-ban by __2__ and will remain in jail untill next reset
|
||||
remove-warn=You are had a warning Removed, you have __1__ warnings, next removed in __2__
|
||||
message=You Are Currently Reciving Warnings From The Script, This Will Continue Unless You Cease And Desist
|
||||
reported=You Have Been Reported To The Admins By The Script, Further Acction May Be Taken If You Do Not Cease And Desist.
|
||||
kick-warn=You Are On A Warning To Be KICKED, The Script Will Auto Kick If You Do Not Cease And Desist.
|
||||
temp-warn=You Are On A Warning To Be TEMP BANNED, The Script Will Auto Ban If You Do Not Cease And Desist.
|
||||
ban-warn=You Are On A Warning To Be BANNED, The Script Will Auto Ban If You Do Not Cease And Desist.
|
||||
last-warn=YOU ARE ON A LAST WARNING TO BE BANNED, THE SCRIPT WILL AUTO BAN IF YOU DO NOT CEASE AND DESIST.
|
||||
@@ -1,10 +0,0 @@
|
||||
[ExpGamingAdmin-Warnings]
|
||||
warning-given-by=This warning was given by: __1__
|
||||
player-warning=__1__ was given a warning by __2__ for: __3__
|
||||
remove-warn=One of your warnings expired. You have __1__ warnings left, next warning will be removed in __2__
|
||||
message=You are currently being warned by the system. These will continue until you cease and desist.
|
||||
reported=You have been reported to the admins by the system. Further action may be taken if you do not cease and desist.
|
||||
kick-warn=This is your last warning before you get kicked. The system will automatically kick you if you do not cease and desist.
|
||||
temp-warn=This is your last warning before you get temporary banned. The system will automatically ban you if you do not cease and desist.
|
||||
ban-warn=WARNING: This is your last warning before you get BANNED. The system will automatically BAN you if you do not cease and desist.
|
||||
last-warn=WARNING: This is your last warning before you get PERMANENTLY BANNED. The system will automatically PERMANENTLY BAN you if you do not cease and desist.
|
||||
@@ -1,11 +0,0 @@
|
||||
[ExpGamingAdmin-Warnings]
|
||||
warning-given-by=This Warnings Was Given By: __1__
|
||||
player-warning=__1__ was given a warning by __2__ reason: __3__
|
||||
temp-ban=__1__ was temp-ban by __2__ and will remain in jail untill next reset
|
||||
remove-warn=You are had a warning Removed, you have __1__ warnings, next removed in __2__
|
||||
message=You Are Currently Reciving Warnings From The Script, This Will Continue Unless You Cease And Desist
|
||||
reported=You Have Been Reported To The Admins By The Script, Further Acction May Be Taken If You Do Not Cease And Desist.
|
||||
kick-warn=You Are On A Warning To Be KICKED, The Script Will Auto Kick If You Do Not Cease And Desist.
|
||||
temp-warn=You Are On A Warning To Be TEMP BANNED, The Script Will Auto Ban If You Do Not Cease And Desist.
|
||||
ban-warn=You Are On A Warning To Be BANNED, The Script Will Auto Ban If You Do Not Cease And Desist.
|
||||
last-warn=YOU ARE ON A LAST WARNING TO BE BANNED, THE SCRIPT WILL AUTO BAN IF YOU DO NOT CEASE AND DESIST.
|
||||
@@ -1,11 +0,0 @@
|
||||
[ExpGamingAdmin-Warnings]
|
||||
warning-given-by=Deze waarschuwing is gegeven door: __1__
|
||||
player-warning=__1__ is gewaarschuwd door __2__ met de reden: __3__
|
||||
temp-ban=__1__ is verbannen door __2__ en is gejailed tot de volgende reset.
|
||||
remove-warn=Een waarschuwing is verlopen. Je hebt nu nog maar __1__ waarschuwing, volgende waarschuwing verloopt in __2__
|
||||
message=Je ontvangt waarschuwingen door het systeem. Deze waarschuwingen stoppen niet tot je stopt met wat je verkeerd doet.
|
||||
reported=Je bent gerapporteerd aan de administrators door het systeem. Je zal bestraft worden als je niet stopt met wat je verkeerd doet.
|
||||
kick-warn=WAARSCHUWING: Dit is je laatste waarschuwing voordat je gekickt wordt.
|
||||
temp-warn=WAARSCHUWING: Dit is je laatste waarschuwing voordat je tijdelijk verbannen wordt.
|
||||
ban-warn=WAARSCHUWING: Dit is je laatste waarschuwing voordat je permanent verbannen wordt.
|
||||
last-warn=DIT IS JE LAATSTE WAARSCHUWING. Het systeem zal je automatisch VERBANNEN als je niet stopt met wat je verkeerd doet.
|
||||
@@ -1,10 +0,0 @@
|
||||
[ExpGamingAdmin-Warnings]
|
||||
warning-given-by=Den här varningen gavs av: __1__
|
||||
player-warning=__1__ var tillfälligt bannlyst av __2__ och kommer att förbli i fängelset tills nästa återställning (reset)
|
||||
remove-warn=En av dina varningar har gått ut. Du har __1__ varning kvar, nästa varning kommer at tas bort om __2__
|
||||
message=Du får för nuvarande varningar av systemet. De kommer fortsätta tills du upphör med överträdelsen.
|
||||
reported= Du har blivit rapporterad till administrationen av systemet. Mer påföljd kan komma att tas om du inte upphör med överträdelsen.
|
||||
kick-warn=Det här är din sista varning innan du blir sparkad. Systemet kommer att automatisk sparka dig om du inte upphör med överträdelsen
|
||||
temp-warn=Det här är din sista varning innan du blir tillfälligt bannlyst. Systemet kommer att automatiskt bannlysa dig om du inte upphör överträdelsen
|
||||
ban-warn=VARNING: Det här är din sista varning innan du blir bannlyst. Systemet kommer att automatisk bannlysa dig om du inte upphör med överträdelsen.
|
||||
last-warn=VARNING: Det här är din sista varning innan du blir permanent bannlyst. Systemet kommer att automatiskt permanent bannlysa dig om du inte upphör med överträdelsen.
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin.Warnings",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a warning system into the admin set which can be used by admins and the script.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Warning",
|
||||
"Admin",
|
||||
"ExpGaming",
|
||||
"Report",
|
||||
"Kick",
|
||||
"Punishments",
|
||||
"Ban"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Server": "^4.0.0",
|
||||
"ExpGamingCore.Role": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"FactorioStdLib.Color": "?^0.8.0",
|
||||
"ExpGamingAdmin.Reports": "?^4.0.0",
|
||||
"ExpGamingCore.Sync": "?^4.0.0",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingAdmin@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
--- The base functions required to make the others work.
|
||||
-- @module ExpGamingAdmin@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias Admin
|
||||
|
||||
-- Module Require
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color = require('FactorioStdLib.Color')
|
||||
local Role -- ExpGamingCore.Role@^4.0.0
|
||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||
local Server -- ExpGamingCore.Server@^4.0.0
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local Admin = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||
if loaded_modules['ExpGamingCore.Server'] then
|
||||
Server = require('ExpGamingCore.Server')
|
||||
Server.add_module_to_interface('Admin','ExpGamingAdmin')
|
||||
end
|
||||
end,
|
||||
actions={},
|
||||
action_functions={},
|
||||
action_names={}
|
||||
}
|
||||
|
||||
-- Global Define
|
||||
local global = {
|
||||
banned = {}
|
||||
}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
|
||||
-- Function Define
|
||||
function Admin.valid_players(player,by_player)
|
||||
player = Game.get_player(player)
|
||||
by_player = Game.get_player(by_player) or SERVER
|
||||
return player, by_player
|
||||
end
|
||||
|
||||
function Admin.create_reason(reason,name)
|
||||
reason = reason or 'No Reason'
|
||||
if not string.find(string.lower(reason),string.lower(name)) then reason = reason..' - '..name end
|
||||
if Sync and Sync.info.date ~= '0000/00/00' and not string.find(string.lower(reason),Sync.info.date) then reason = reason..' - '..Sync.info.date end
|
||||
if not string.find(string.lower(reason),'appeal') then reason = reason..' - Visit www.explosivegaming.nl to appeal.' end
|
||||
return reason
|
||||
end
|
||||
|
||||
function Admin.allowed(player)
|
||||
player = Game.get_player(player)
|
||||
if Role then
|
||||
return Role.allowed(player,'admin-commands')
|
||||
else return player.admin end
|
||||
end
|
||||
|
||||
function Admin.set_banned(player,set)
|
||||
player = Game.get_player(player)
|
||||
if not player then return false end
|
||||
global.banned[player.name] = set
|
||||
end
|
||||
|
||||
function Admin.is_banned(player,detail)
|
||||
player = Game.get_player(player)
|
||||
if not player then return false end
|
||||
local banned = global.banned[player.name]
|
||||
if banned == true then return true end
|
||||
if not banned then return false end
|
||||
if detail then return banned
|
||||
else return true end
|
||||
end
|
||||
|
||||
function Admin.add_action(action,callback)
|
||||
verbose('Added admin action: '..action)
|
||||
Admin.actions[string.lower(action)] = table.insert(Admin.action_names,action)
|
||||
Admin.action_functions[string.lower(action)] = callback
|
||||
end
|
||||
|
||||
function Admin.take_action(action,player,by_player,reason)
|
||||
if Admin.action_functions[string.lower(action)] then Admin.action_functions[string.lower(action)](player,by_player,reason) end
|
||||
if Admin[action] then Admin[action](player,by_player,reason) end
|
||||
end
|
||||
|
||||
function Admin.clear_player(player,by_player)
|
||||
player, by_player = Admin.valid_players(player,by_player)
|
||||
if not player then return end
|
||||
if Server and Admin.is_banned(player,true) == true then Server.interface(game.unban_player,true,player) end
|
||||
if Admin.clear_warnings then Admin.clear_warnings(player,by_player,true) end
|
||||
if Admin.clear_reports then Admin.clear_reports(player,by_player,true) end
|
||||
if Server and Role.has_flag(player,'is_jail') then Server.interface(Role.revert,true,player,by_player,2) end
|
||||
if Sync then Sync.emit_embedded{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.textcolor.low),
|
||||
description='A player had their reports and warnings cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player.name,
|
||||
} end
|
||||
Admin.set_banned(player,false)
|
||||
end
|
||||
|
||||
-- Module Return
|
||||
return Admin
|
||||
@@ -1,15 +0,0 @@
|
||||
[ExpGamingAdmin]
|
||||
name=Admin-Befehle
|
||||
tooltip=Die mächtigsten Befehle sind hier zuhause.
|
||||
no-info-file=Die Informationsdatei wurde nicht gefunden.
|
||||
message=Wähle einen Spieler und eine Aktion. Stell vor dem Ausführen sicher, dass der Richtige ist!
|
||||
warning=Achtung, dieser Spieler hat einen höheren Rang als du selbst, weshalb du seinen Rang nicht ändern kannst.
|
||||
short-reason=Achtung, dies ist ein sehr kurzer Grund. Bitte versuche, mehr Informationen anzugeben. (Warning: The reason is too short. UPDATE)
|
||||
rank-high=Dieser Spieler hat einen hohen Rang. Bitte benutze nur Ingame-Befehle gegen diese Person, wenn du dir sicher bist!
|
||||
invalid=Der Spieler oder die Aktion war ungültig. Bitte versuche es noch einmal!
|
||||
take-action= Ergreife Maßnahme
|
||||
tooltip-ban=Banne Spieler
|
||||
tooltip-kick=Kicke Spieler
|
||||
tooltip-jail=Sperre Spieler ins Gefängnis
|
||||
tooltip-go-to=Gehe zum Spieler
|
||||
tooltip-bring=Bringe den Spieler zu dir
|
||||
@@ -1,21 +0,0 @@
|
||||
[ExpGamingAdmin]
|
||||
name=Admin Commands
|
||||
tooltip=Admin commands make their home here
|
||||
no-info-file=No info file was found
|
||||
message=Please select a player and an action to take. Make sure to choose the correct one!
|
||||
warning=Warning: This player outranks you. Therefore, you cannot edit their rank.
|
||||
short-reason=Warning: The reason is too short.
|
||||
rank-high=Warning: This player outranks you. Therefore, you cannot edit their rank.
|
||||
invalid=The player or the action is invalid. Please try again!
|
||||
take-action=Take Action
|
||||
tooltip-ban=Ban Player
|
||||
tooltip-kick=Kick Player
|
||||
tooltip-jail=Jail Player
|
||||
tooltip-go-to=Go To Player
|
||||
tooltip-bring=Bring Player
|
||||
temp-ban=__1__ was temporary banned by __2__ and will remain in jail until next reset
|
||||
report=Report Player
|
||||
cant-report-ban=Invalid player as player is banned; Either unban or use /clear-all <player_name>
|
||||
low-print=__1__ has been reported by a user for: __2__
|
||||
high-print=__1__ has been reported by __2__ for: __3__
|
||||
cant-report=This player can't be reported.
|
||||
@@ -1,15 +0,0 @@
|
||||
[ExpGamingAdmin]
|
||||
name=Commandes Admin
|
||||
tooltip=Des commandes très puissantes résident ici.
|
||||
no-info-file=Aucun fichier info trouvé
|
||||
message=Veuillez sélectionner un joueur et une action, faites en sorte que ce soit la bonne !
|
||||
warning=Attention, ce joueur est de rang supérieur au vôtre, vous ne pouvez le modifier.
|
||||
short-reason=Attention, la raison indiquée est trop courte. Soyez concis mais aussi précis. (Warning: The reason is too short. UPDATE)
|
||||
rank-high=Ce joueur est de rang supérieur, veuillez utiliser une commande dont vous maîtriser l'utilisation !
|
||||
invalid=Le Joueur ou l'action est invalide, ré-essayez !
|
||||
take-action=Agir
|
||||
tooltip-ban=Bannir un Joueur
|
||||
tooltip-kick=Exclure un Joueur
|
||||
tooltip-jail=Emprisonner un Joueur
|
||||
tooltip-go-to=Aller à la position d'un Joueur
|
||||
tooltip-bring=Amener le Joueur à soi
|
||||
@@ -1,15 +0,0 @@
|
||||
[ExpGamingAdmin]
|
||||
name=Admin Commands
|
||||
tooltip=Admin Commands kan je hier vinden.
|
||||
no-info-file=Infobestand niet gevonden.
|
||||
message=Selecteer een speler en de bijbehorende actie. Wees er zeker van dat je de correcte actie kiest.
|
||||
warning=Fout: Je kan de rank van deze speler niet aanpassen omdat het jouw rank overtreft.
|
||||
short-reason=Fout: De reden is te kort. (Warning: The reason is too short. UPDATE)
|
||||
rank-high=Fout: Deze speler overtreft jouw rank.
|
||||
invalid=Fout: De speler kan niet gevonden worden en/of de actie is onjuist. Probeer opnieuw!
|
||||
take-action=Actie ondernemen
|
||||
tooltip-ban=Ban speler
|
||||
tooltip-kick=Kick speler
|
||||
tooltip-jail=Jail speler
|
||||
tooltip-go-to=Ga naar speler
|
||||
tooltip-bring=Breng speler
|
||||
@@ -1,19 +0,0 @@
|
||||
[ExpGamingAdmin]
|
||||
name=Adminkommandon
|
||||
tooltip=Adminkommando gör dit hem här
|
||||
no-info-file=Ingen informationsfil kunde hittas
|
||||
message=Var snäll och välj en spelare och en åtgärd att utfärda, se till att du väljer den rätta!
|
||||
warning=Warning: Den här spelaren har högre rang än dig. Därför kan du inte redigera dess rang.
|
||||
short-reason=Warning: Skälet är för kort.
|
||||
rank-high=Warning: Den här spelaren har högre rang än dig. Därför kan du inte redigera dess rang.
|
||||
invalid=Spelaren eller åtgärden är ogiltig. Var vänlig och försök igen!
|
||||
take-action=Utför åtgärd.
|
||||
tooltip-ban=Bannlys Spelare
|
||||
tooltip-kick=Sparka Spelare
|
||||
tooltip-jail=Fängsla Spelare
|
||||
tooltip-go-to=Gå till Spelare
|
||||
tooltip-bring=Hämta spelare
|
||||
report=Rapportera Spelare
|
||||
low-print=__1__ har blivit rapporterad av __2__ för: __3__
|
||||
high-print=__1__ har blivit rapporterad av __2__ för: __3__
|
||||
cant-report=Den här spelaren kan inte bli rapporterad.
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin",
|
||||
"version": "4.0.0",
|
||||
"description": "A set of useful admin commands and functions that can be used by other modules.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Admin",
|
||||
"ExpGaming",
|
||||
"Set",
|
||||
"Commands",
|
||||
"Functions",
|
||||
"Scripts",
|
||||
"Useful"
|
||||
],
|
||||
"author": "Cooldude2606",
|
||||
"contact": "Discord: Cooldude2606#5241",
|
||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||
"submodules": {
|
||||
"ExpGamingAdmin": "4.0.0",
|
||||
"ExpGamingAdmin.Ban": "4.0.0",
|
||||
"ExpGamingAdmin.ClearInventory": "4.0.0",
|
||||
"ExpGamingAdmin.Gui": "4.0.0",
|
||||
"ExpGamingAdmin.Jail": "4.0.0",
|
||||
"ExpGamingAdmin.Kick": "4.0.0",
|
||||
"ExpGamingAdmin.Reports": "4.0.0",
|
||||
"ExpGamingAdmin.Teleport": "4.0.0",
|
||||
"ExpGamingAdmin.TempBan": "4.0.0",
|
||||
"ExpGamingAdmin.Warnings": "4.0.0",
|
||||
"ExpGamingAdmin.Commands": "4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Role": "?^4.0.0",
|
||||
"ExpGamingCore.Sync": "?^4.0.0",
|
||||
"ExpGamingCore.Server": "?^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
--- Sends messages in chat in response to other messages
|
||||
-- @module ExpGamingBot.autoChat
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
local Role -- ExpGamingCore.Role@^4.0.0
|
||||
|
||||
-- Local Variables
|
||||
-- lots of these are jokes, but some have uses
|
||||
|
||||
-- white spaces removed and made into lower
|
||||
-- these messages are sent only to the player
|
||||
local messages = {
|
||||
['discord']={'ExpGamingBot-autoChat.discord'},
|
||||
['expgaming']={'ExpGamingBot-autoChat.website'},
|
||||
['website']={'ExpGamingBot-autoChat.website'},
|
||||
['command']={'ExpGamingBot-autoChat.custom-commands'},
|
||||
['commands']={'ExpGamingBot-autoChat.custom-commands'},
|
||||
['softmod']={'ExpGamingBot-autoChat.softmod'},
|
||||
['script']={'ExpGamingBot-autoChat.softmod'},
|
||||
['link']={'ExpGamingBot-autoChat.links'},
|
||||
['links']={'ExpGamingBot-autoChat.links'},
|
||||
['loop']={'ExpGamingBot-autoChat.loops'},
|
||||
['loops']={'ExpGamingBot-autoChat.loops'},
|
||||
['rhd']={'ExpGamingBot-autoChat.lhd'},
|
||||
['roundabout']={'ExpGamingBot-autoChat.loops'},
|
||||
['roundabouts']={'ExpGamingBot-autoChat.loops'},
|
||||
['redmew']={'ExpGamingBot-autoChat.redmew'},
|
||||
['afk']=function(_player) local max=_player for _,player in pairs(game.connected_players) do if max.afk_time < player.afk_time then max=player end end return {'ExpGamingBot-autoChat.afk',max.name,tick_to_display_format(max.afk_time)} end
|
||||
}
|
||||
-- white spaces removed and made into lower
|
||||
-- these are global chat commands that can be used
|
||||
-- commands start with ! (all messages are also commands)
|
||||
local command_syntax = '!'
|
||||
local commands = {
|
||||
['online']=function() return {'ExpGamingBot-autoChat.players-online',#game.connected_players} end,
|
||||
['playtime']=function() return {'ExpGamingBot-autoChat.map-time',tick_to_display_format(game.tick)} end,
|
||||
['players']=function() return {'ExpGamingBot-autoChat.players',#game.players} end,
|
||||
['dev']={'ExpGamingBot-autoChat.not-real-dev'},
|
||||
['blame']=function(player) local names = {'Cooldude2606','arty714','badgamernl',player.name} return {'ExpGamingBot-autoChat.blame',names[math.random(#names)]} end,
|
||||
['readme']={'ExpGamingBot-autoChat.read-readme'},
|
||||
['magic']={'ExpGamingBot-autoChat.magic'},
|
||||
['aids']={'ExpGamingBot-autoChat.aids'},
|
||||
['riot']={'ExpGamingBot-autoChat.riot'},
|
||||
['lenny']={'ExpGamingBot-autoChat.lenny'},
|
||||
['feedback']={'ExpGamingBot-autoChat.feedback'},
|
||||
['wiki']={'ExpGamingBot-autoChat.wiki'},
|
||||
['hodor']=function() local options = {'?','.','!','!!!'} return {'ExpGamingBot-autoChat.hodor',options[math.random(#options)]} end,
|
||||
['evolution']=function() return {'ExpGamingBot-autoChat.current-evolution',string.format('%.2f',game.forces['enemy'].evolution_factor)} end,
|
||||
--Jokes about food and drink
|
||||
['whattoeat']={'ExpGamingBot-autoChat.food'},
|
||||
|
||||
['makepopcorn']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-popcorn-2',self.data}} end
|
||||
end):open() return {'ExpGamingBot-autoChat.get-popcorn-1'} end,
|
||||
|
||||
['orderpizza']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.order-pizza-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.order-pizza-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2]+1
|
||||
end):open() return {'ExpGamingBot-autoChat.order-pizza-1'} end,
|
||||
|
||||
['passsomesnaps']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-snaps-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-snaps-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2]+1
|
||||
end):open() return {'ExpGamingBot-autoChat.get-snaps-1'} end,
|
||||
|
||||
['makecocktail']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-cocktail-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-cocktail-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2]+1
|
||||
end):open() return {'ExpGamingBot-autoChat.get-cocktail-1'} end,
|
||||
|
||||
['makecoffee']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.make-coffee-2',self.data}} end
|
||||
end):open() return {'ExpGamingBot-autoChat.make-coffee-1'} end,
|
||||
|
||||
['orderpizza']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.order-pizza-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.order-pizza-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2] + 1
|
||||
end):open() return {'ExpGamingBot-autoChat.order-pizza-1'} end,
|
||||
|
||||
['maketea']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.make-tea-2',self.data}} end
|
||||
end):open() return {'ExpGamingBot-autoChat.make-tea-1'} end,
|
||||
|
||||
['popcorn']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-popcorn-2',self.data}} end
|
||||
end):open() return {'ExpGamingBot-autoChat.get-popcorn-1'} end,
|
||||
|
||||
['meadplease']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-mead-2',self.data}} end
|
||||
end):open() return {'ExpGamingBot-autoChat.get-mead-1'} end,
|
||||
|
||||
['passabeer']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-beer-2',self.data}} end
|
||||
end):open() return {'ExpGamingBot-autoChat.get-beer-1'} end
|
||||
}
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||
end
|
||||
}
|
||||
|
||||
-- Event Handlers Define
|
||||
Event.add(defines.events.on_console_chat,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
local player_message = event.message:lower():gsub("%s+", "")
|
||||
local allowed = Role and Role.allowed(player,'global-chat') or player.admin
|
||||
for to_find,message in pairs(messages) do
|
||||
if player_message:match(command_syntax..to_find) then
|
||||
if allowed then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
game.print{'ExpGamingBot-autoChat.message',message}
|
||||
else player_return({'ExpGamingBot-autoChat.rank-error'},nil,player) end
|
||||
elseif player_message:match(to_find) then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
if not allowed then player_return({'ExpGamingBot-autoChat.message',message},nil,player) end
|
||||
end
|
||||
end
|
||||
for to_find,message in pairs(commands) do
|
||||
if player_message:match(command_syntax..to_find) then
|
||||
if allowed then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
game.print{'ExpGamingBot-autoChat.message',message}
|
||||
else player_return({'ExpGamingBot-autoChat.rank-error'},nil,player) end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
return ThisModule
|
||||
@@ -1,20 +0,0 @@
|
||||
[ExpGamingBot-autoChat]
|
||||
message=[Chat Bot]: __1__
|
||||
rank-error=You cant use global chat commands
|
||||
players-online=There are __1__ players online
|
||||
players=There have been __1__ players on this map
|
||||
map-time=This map has been on for __1__
|
||||
line-8=Type /help <command> for more info
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.explosivegaming.nl
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
|
||||
read-readme=Make sure you have read the Readme (can be found through the question mark on the top left)
|
||||
not-real-dev=Cooldude2606 is a dev for this server and makes the softmod (look top left) and is not a factorio dev.
|
||||
softmod=A softmod is a custom scenario that runs on this server, example is the player list.
|
||||
blame=Blame __1__ for what just happend!
|
||||
afk=Your afk? Look at __1__ they have been afk for: __2__
|
||||
links=To see links open the readme and click links.
|
||||
magic=Fear the admin magic (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
|
||||
aids=≖ ‿ ≖ Fear the aids of a public server ≖ ‿ ≖
|
||||
riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ ‹ ‹\(´ω` )/››‹‹\ ( ´)/››‹‹\ ( ´ω`)/›› (rest of server)
|
||||
@@ -1,48 +0,0 @@
|
||||
[ExpGamingBot-autoChat]
|
||||
message=[Chat Bot]: __1__
|
||||
rank-error=You can't use global chat commands
|
||||
players-online=There are __1__ players online
|
||||
players=There have been __1__ players on this map
|
||||
map-time=This map has been on for __1__
|
||||
line-8=Type /help <command> for more info
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.explosivegaming.nl
|
||||
website=Website: https://www.explosivegaming.nl
|
||||
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
|
||||
read-readme=Make sure you have read the Readme (It can be found through the question mark on the top left)
|
||||
not-real-dev=Cooldude2606 is a dev for this server and makes the softmod (look top left) and is not a factorio dev.
|
||||
softmod=A softmod is a custom scenario that runs on this server, example is the player list.
|
||||
redmew=We dont talk about redmew here; they beat us to 1000 members; F
|
||||
blame=Blame __1__ for what just happend!
|
||||
afk=Your afk? Look at __1__, that player has been afk for: __2__
|
||||
links=To see links open the readme and click links.
|
||||
current-evolution=Current evolution factor is __1__
|
||||
magic=Fear the admin magic (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
|
||||
aids=≖ ‿ ≖ Fear the aids of a public server ≖ ‿ ≖
|
||||
riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ ‹ ‹\(´ω` )/››‹‹\ ( ´)/››‹‹\ ( ´ω`)/›› (rest of server)
|
||||
loops=NO LOOPS; LOOPS ARE BAD; JUST NO LOOPS!!!!!; IF YOU MAKE A LOOP.... IT WILL NOT END WELL!!!!!!!
|
||||
lenny=( ͡° ͜ʖ ͡°)
|
||||
make-tea-1= ☕ Boiling the water... ☕
|
||||
make-tea-2= ☕ __1__ your tea is done! ☕
|
||||
order-pizza-1= 🍕 Finding nearest pizza supplier... 🍕
|
||||
order-pizza-2= 🍕 Figuring out the favourite pizza of __1__ 🍕
|
||||
order-pizza-3= 🍕 __1__ your pizza is here! 🍕
|
||||
make-coffee-1= ☕ Boiling the water and grinding the coffee beans... ☕
|
||||
make-coffee-2= ☕ __1__ we ran out of coffe beans! Have some tea instead. ☕
|
||||
get-beer-1= 🍺 Pouring A Glass 🍺
|
||||
get-beer-2= 🍻 Chears Mate 🍻
|
||||
get-mead-1= Filling the drinking horn
|
||||
get-mead-2= Skål!
|
||||
get-snaps-1=Pouring the glasses and finding the correct song book...
|
||||
get-snaps-2=Singing a song...🎤🎶
|
||||
get-snaps-3=skål, my friends!
|
||||
get-cocktail-1= 🍸 Inintiating mind reading unit... 🍸
|
||||
get-cocktail-2= 🍸 Mixing favourite ingredients of __1__ 🍸
|
||||
get-cocktail-3=🍸 __1__ your cocktail is done.🍸
|
||||
lhd=All trains must be LHD!
|
||||
food=Don't know what to make for dinner? Use a random recipe from the random dinner suggestion generator at http://www.whatthefuckshouldimakefordinner.com/
|
||||
get-popcorn-1=Heating the oil and waiting for the popping sound...
|
||||
get-popcorn-2=__1__ your popcorn is finished. Lean backwards and watch the drama unfold.
|
||||
wiki=You can get more information about us and the custom scenario from our wiki: https://wiki.explosivegaming.nl/
|
||||
feedback=Do you have feedback? leave it at https://exp.fider.io/
|
||||
hodor=Hodor
|
||||
@@ -1,20 +0,0 @@
|
||||
[ExpGamingBot-autoChat]
|
||||
message=[Chat Bot]: __1__
|
||||
rank-error=You cant use global chat commands
|
||||
players-online=There are __1__ players online
|
||||
players=There have been __1__ players on this map
|
||||
map-time=This map has been on for __1__
|
||||
line-8=Type /help <command> for more info
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.explosivegaming.nl
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
|
||||
read-readme=Make sure you have read the Readme (can be found through the question mark on the top left)
|
||||
not-real-dev=Cooldude2606 is a dev for this server and makes the softmod (look top left) and is not a factorio dev.
|
||||
softmod=A softmod is a custom scenario that runs on this server, example is the player list.
|
||||
blame=Blame __1__ for what just happend!
|
||||
afk=Your afk? Look at __1__ they have been afk for: __2__
|
||||
links=To see links open the readme and click links.
|
||||
magic=Fear the admin magic (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
|
||||
aids=≖ ‿ ≖ Fear the aids of a public server ≖ ‿ ≖
|
||||
riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ ‹ ‹\(´ω` )/››‹‹\ ( ´)/››‹‹\ ( ´ω`)/›› (rest of server)
|
||||
@@ -1,20 +0,0 @@
|
||||
[ExpGamingBot-autoChat]
|
||||
message=[Chat Bot]: __1__
|
||||
rank-error=You cant use global chat commands
|
||||
players-online=There are __1__ players online
|
||||
players=There have been __1__ players on this map
|
||||
map-time=This map has been on for __1__
|
||||
line-8=Type /help <command> for more info
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.explosivegaming.nl
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
|
||||
read-readme=Make sure you have read the Readme (can be found through the question mark on the top left)
|
||||
not-real-dev=Cooldude2606 is a dev for this server and makes the softmod (look top left) and is not a factorio dev.
|
||||
softmod=A softmod is a custom scenario that runs on this server, example is the player list.
|
||||
blame=Blame __1__ for what just happend!
|
||||
afk=Your afk? Look at __1__ they have been afk for: __2__
|
||||
links=To see links open the readme and click links.
|
||||
magic=Fear the admin magic (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
|
||||
aids=≖ ‿ ≖ Fear the aids of a public server ≖ ‿ ≖
|
||||
riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ ‹ ‹\(´ω` )/››‹‹\ ( ´)/››‹‹\ ( ´ω`)/›› (rest of server)
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
[ExpGamingBot-autoChat]
|
||||
message=[Chat Bot]: __1__
|
||||
rank-error=Du kan inte utföra globala chat-kommandon.
|
||||
players-online=Det är __1__ spelare online
|
||||
players=Det har varit __1__ spelare på den här kartan
|
||||
map-time=Den här kartan har varit igång under __1__
|
||||
line-8=Type /help <kommando> för mer information
|
||||
join-us=Var snäll och förena dig med oss:
|
||||
discord=Discord: https://discord.explosivegaming.nl
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=Vi använder oss av specialiserade kommandon, som till exempel /tag och /report, se kommandotabben i readme för mer information.
|
||||
read-readme=Se till att du har läst "Readme" (Finn den genom att klicka på frågetecknet högst upp i vänstra hörnet)
|
||||
not-real-dev=Cooldude2606 är dev för den här servern och gör mjukmodden ("the softmod") och är inte en factorio dev.
|
||||
ssoftmod=En mjukmod ("softmod") är ett specialscenario som används på den här servern, exempelvis listan över spelare.
|
||||
blame=Skyll på __1__ för vad som just hände!
|
||||
afk=Är du afk (borta från tangentbordet)? Titta på __1__, den spelaren har varit afk under: __2__
|
||||
links=För att se länkar, öppna readme och klicka "länkar".
|
||||
magic=Frukta admin-magin (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
|
||||
aids=≖ ‿ ≖Fear the aids of a public server ≖ ‿ ≖
|
||||
riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ ‹ ‹\(´ω` )/››‹‹\ ( ´)/››‹‹\ ( ´ω`)/›› (rest of server)
|
||||
loops=INGA LOOPAR; LOOPAR ÄR DÅLIGT; JUST INGA LOOPAR!!!!!; OM DU GJÖR EN LOOP.... DET KOMMER INTE ATT SLUTA VÄL!!!!!!!
|
||||
lhd=Alla tåg skall köras med vänstertrafik!
|
||||
current-evolution=Nuvarande evolutionsfaktor är __1__
|
||||
wiki=Du kan få mer information om oss och scenariot på vår wiki: https://wiki.explosivegaming.nl/
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingBot.autoChat",
|
||||
"version": "4.0.0",
|
||||
"description": "Sends messages in chat based on what has been said by other players",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Chat",
|
||||
"Bot",
|
||||
"Jokes",
|
||||
"Fun"
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Server": "^4.0.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingBot@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
--- Prints a message every 15 minutes to chat.
|
||||
-- @module ExpGamingBot.autoMessage
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Role -- ExpGamingCore.Role@4.0.0
|
||||
local Sync -- ExpGamingCore.Sync@4.0.0
|
||||
|
||||
-- Local Variables
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||
end,
|
||||
on_post=function()
|
||||
--code
|
||||
end
|
||||
}
|
||||
|
||||
-- Event Handlers Define
|
||||
script.on_init(function()
|
||||
Server.new_thread{
|
||||
name='auto-message',
|
||||
timeout=54000, -- 3240000 = 15 hours dont make the mistake i did, 54000 is 15 minutes
|
||||
reopen=true,
|
||||
data={
|
||||
high_role= 'Owner',
|
||||
low_role= 'Regular',
|
||||
low={
|
||||
{'ExpGamingBot-autoMessage.join-us'},
|
||||
{'ExpGamingBot-autoMessage.discord'},
|
||||
{'ExpGamingBot-autoMessage.website'},
|
||||
{'ExpGamingBot-autoMessage.custom-commands'},
|
||||
{'ExpGamingBot-autoMessage.read-readme'}
|
||||
}
|
||||
}
|
||||
}:on_event('timeout',function(self)
|
||||
local data = self.data
|
||||
if not data.high_role or not data.low_role
|
||||
or not data.low then self.reopen = false return end
|
||||
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.players-online',#game.connected_players}}
|
||||
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.map-time',tick_to_display_format(game.tick)}}
|
||||
self.reopen = true
|
||||
end):on_event(defines.events.on_player_joined_game,function(self,event)
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
local data = self.data
|
||||
if not data.high_role or not data.low_role
|
||||
or not data.low then self.reopen = false return end
|
||||
if Role and Role.get_highest(player).index <= Role.get(data.low_role).index or player.admin then return end
|
||||
for _,message in pairs(data.low) do
|
||||
player_return({'ExpGamingBot-autoMessage.message',message},nil,player)
|
||||
end
|
||||
end):on_event('error',function(self,err)
|
||||
if Sync then Sync.emit_embedded{
|
||||
title='Auto Message Error',
|
||||
color=Color.to_hex(defines.textcolor.bg),
|
||||
description='Auto Message Error - Closed Thread',
|
||||
Error=err
|
||||
} end
|
||||
self.reopen = false
|
||||
self:close()
|
||||
end):open()
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
return ThisModule
|
||||
@@ -1,9 +0,0 @@
|
||||
[ExpGamingBot-autoMessage]
|
||||
message=[Chat Bot]: __1__
|
||||
players-online=There are __1__ players online
|
||||
map-time=This map has been on for __1__
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.explosivegaming.nl
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
|
||||
read-readme=Make sure you have read the Readme (can be found through the question mark on the top left)
|
||||
@@ -1,9 +0,0 @@
|
||||
[ExpGamingBot-autoMessage]
|
||||
message=[Chat Bot]: __1__
|
||||
players-online=There are __1__ players online
|
||||
map-time=This map has been on for __1__
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.explosivegaming.nl
|
||||
website=Website: https://www.explosivegaming.nl
|
||||
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
|
||||
read-readme=Make sure you have read the Readme (It can be found through the question mark on the top left)
|
||||
@@ -1,9 +0,0 @@
|
||||
[ExpGamingBot-autoMessage]
|
||||
message=[Chat Bot]: __1__
|
||||
players-online=There are __1__ players online
|
||||
map-time=This map has been on for __1__
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.explosivegaming.nl
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
|
||||
read-readme=Make sure you have read the Readme (can be found through the question mark on the top left)
|
||||
@@ -1,9 +0,0 @@
|
||||
[ExpGamingBot-autoMessage]
|
||||
message=[Chat Bot]: __1__
|
||||
players-online=There are __1__ players online
|
||||
map-time=This map has been on for __1__
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.explosivegaming.nl
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
|
||||
read-readme=Make sure you have read the Readme (can be found through the question mark on the top left)
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
[ExpGamingBot-autoMessage]
|
||||
message=[Chat Bot]: __1__
|
||||
players-online=Det är __1__ spelare online
|
||||
map-time=Den här kartan har varit igång under __1__
|
||||
join-us=Var snäll och förena dig med oss:
|
||||
discord=Discord: https://discord.explosivegaming.nl
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=Vi använder oss av specialiserade kommandon, som till exempel /tag och /report, se kommandotabben i readme för mer information.
|
||||
read-readme=Se till att du har läst "Readme" (Finn den genom att klicka på frågetecknet högst upp i vänstra hörnet)
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingBot.autoMessage",
|
||||
"version": "4.0.0",
|
||||
"description": "Prints a message every 15 minutes to chat.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Bot",
|
||||
"Chat",
|
||||
"Auto Message",
|
||||
"Message"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Server": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0",
|
||||
"ExpGamingCore.Sync": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingBot@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
--- Sends alerts to discord once there is a bot set up to read the alerts.
|
||||
-- @module ExpGamingBot.discordAlerts@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Sync = require('ExpGamingCore.Sync')
|
||||
local Color = require('FactorioStdLib.Color')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {}
|
||||
|
||||
-- Event Handlers Define
|
||||
Event.add(defines.events.on_console_command,function(event)
|
||||
local command = event.command
|
||||
local args = {}
|
||||
if event.parameters then for word in event.parameters:gmatch('%S+') do table.insert(args,word) end end
|
||||
local data = {}
|
||||
data.title = string.gsub(command,'^%l',string.upper)
|
||||
data.by = event.player_index and game.players[event.player_index].name or '<server>'
|
||||
if data.by == '<server>' then return end
|
||||
if command == 'config' or command == 'banlist' then
|
||||
Sync.emit_embedded{
|
||||
title='Edit To '..data.title,
|
||||
color=Color.to_hex(defines.textcolor.bg),
|
||||
description='A player edited the '..command..'.',
|
||||
['By:']=data.by,
|
||||
['Edit:']=table.concat(args,' ',1)
|
||||
}
|
||||
else
|
||||
if command == 'ban' then
|
||||
data.colour = Color.to_hex(defines.textcolor.crit)
|
||||
data.reason = table.concat(args,' ',2)
|
||||
elseif command == 'kick' then
|
||||
data.colour = Color.to_hex(defines.textcolor.high)
|
||||
data.reason = table.concat(args,' ',2)
|
||||
elseif command == 'unban' then data.colour = Color.to_hex(defines.textcolor.low)
|
||||
elseif command == 'mute' then data.colour = Color.to_hex(defines.textcolor.med)
|
||||
elseif command == 'unmute' then data.colour = Color.to_hex(defines.textcolor.low)
|
||||
elseif command == 'promote' then data.colour = Color.to_hex(defines.textcolor.info)
|
||||
elseif command == 'demote' then data.colour = Color.to_hex(defines.textcolor.info)
|
||||
elseif command == 'purge' then data.colour = Color.to_hex(defines.textcolor.med)
|
||||
else return end
|
||||
data.username = args[1]
|
||||
if not Game.get_player(data.username) then return end
|
||||
if string.sub(command,-1) == 'e' then data.command = command..'d' else data.command = command..'ed' end
|
||||
data.reason = data.reason and data.reason ~= '' and data.reason or 'No Reason Required'
|
||||
Sync.emit_embedded{
|
||||
title='Player '..data.title,
|
||||
color=data.colour,
|
||||
description='There was a player '..data.command..'.',
|
||||
['Player:']='<<inline>>'..data.username,
|
||||
['By:']='<<inline>>'..data.by,
|
||||
['Reason:']=data.reason
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
return ThisModule
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingBot.discordAlerts",
|
||||
"version": "4.0.0",
|
||||
"description": "Sends alerts to discord once there is a bot set up to read the alerts.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Bot",
|
||||
"Discord",
|
||||
"Alerts",
|
||||
"Messages",
|
||||
"Acctions"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Sync": "^4.0.0",
|
||||
"FactorioStdLib.Color": "^0.8.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
},
|
||||
"collection": "ExpGamingBot@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingBot",
|
||||
"version": "4.0.0",
|
||||
"description": "Different parts of a useful bot to help run a server. Discord Bot Not Included.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Discord",
|
||||
"Bot",
|
||||
"Messages",
|
||||
"Chat",
|
||||
"Auto"
|
||||
],
|
||||
"author": "Cooldude2606",
|
||||
"contact": "Discord: Cooldude2606#5241",
|
||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||
"submodules": {
|
||||
"ExpGamingBot.autoChat": "4.0.0",
|
||||
"ExpGamingBot.autoMessage": "4.0.0",
|
||||
"ExpGamingBot.discordAlerts": "4.0.0"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingCommands.bonus@^4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local global = {}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
|
||||
-- these are the settings which are changed with scale being as +100%
|
||||
local settings = {
|
||||
character_mining_speed_modifier=3,
|
||||
character_crafting_speed_modifier=3,
|
||||
character_running_speed_modifier=3,
|
||||
character_build_distance_bonus=20,
|
||||
character_reach_distance_bonus=20,
|
||||
character_inventory_slots_bonus=200
|
||||
}
|
||||
|
||||
--- Allows a player to set there bonus
|
||||
-- @command bonus
|
||||
-- @param bonus the amount of bonus there will get
|
||||
commands.add_command('bonus', 'Set your player bonus (default is 20, guest has 0)', {
|
||||
['bonus'] = {true,'number-range-int',-1,50} -- -1 < math.floor(bonus) <= 50
|
||||
}, function(event,args)
|
||||
local player = Game.get_player(event)
|
||||
local bonus = args.bonus
|
||||
for key,setting in pairs(settings) do player[key] = setting*math.floor(bonus)*0.01 end
|
||||
global[player.index]=bonus
|
||||
player_return('Bonus set to: '..math.floor(bonus)..'%')
|
||||
end).default_admin_only = true
|
||||
|
||||
Event.add(defines.events.on_player_respawned,function(event)
|
||||
local player = Game.get_player(event)
|
||||
local bonus = global[player.index]
|
||||
if bonus then
|
||||
for key,setting in pairs(settings) do player[key] = setting*math.floor(bonus)*0.01 end
|
||||
end
|
||||
end)
|
||||
|
||||
-- overridden by ExpGamingCore.Role if present
|
||||
Event.add(defines.events.on_pre_player_died,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if player.admin then
|
||||
player.ticks_to_respawn = 120
|
||||
-- manually dispatch death event because it is not fired when ticks_to_respawn is set pre death
|
||||
Event.dispatch{
|
||||
name=defines.events.on_player_died,
|
||||
tick=event.tick,
|
||||
player_index=event.player_index,
|
||||
cause = event.cause
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
return {
|
||||
on_init= function(self)
|
||||
if loaded_modules['ExpGamingCore.Role'] then
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
-- instant respawn
|
||||
Event.add(defines.events.on_pre_player_died,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if Role.allowed(player,'bonus-respawn') then
|
||||
player.ticks_to_respawn = 120
|
||||
-- manually dispatch death event because it is not fired when ticks_to_respawn is set pre death
|
||||
script.raise_event(defines.events.on_player_died,{
|
||||
name=defines.events.on_player_died,
|
||||
tick=event.tick,
|
||||
player_index=event.player_index,
|
||||
cause = event.cause
|
||||
})
|
||||
end
|
||||
end)
|
||||
-- either clears or adds default when rank changed
|
||||
Event.add(defines.events.role_change,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if Role.allowed(player,'bonus') then
|
||||
for key,setting in pairs(settings) do player[key] = setting*0.2 end
|
||||
global[player.index]=20
|
||||
else
|
||||
for key in pairs(settings) do player[key] = 0 end
|
||||
global[player.index]=nil
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingCommands.bonus",
|
||||
"version": "4.0.0",
|
||||
"description": "Allows a bonus to be applied to players and instant respawn.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Instant Respawn",
|
||||
"Bonus",
|
||||
"Cheat",
|
||||
"Commands",
|
||||
"ExpGaming",
|
||||
"Respawn"
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingCommands.cheatMode@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
--- Toggles cheat mode for a player
|
||||
-- @command cheat-mode
|
||||
-- @param[opt] player the player to toggle if nil then the player using the command
|
||||
commands.add_command('cheat-mode', 'Toggles cheat mode for a player', {
|
||||
['player']={false,'player'}
|
||||
}, function(event,args)
|
||||
local player = args.player or game.player
|
||||
if player.cheat_mode == true then player.cheat_mode = false else player.cheat_mode = true end
|
||||
end).default_admin_only = true
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingCommands.cheatMode",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a command which allow you to toggle cheatmode",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Cheat",
|
||||
"Commands",
|
||||
"Admin",
|
||||
"ExpGaming",
|
||||
"Cheat Mode",
|
||||
"Hacks"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Command": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingCommands.home@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local global = {}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
|
||||
--- Sets the home for a player
|
||||
-- @command set-home
|
||||
commands.add_command('home', 'Allows you to set, remove and goto your homes', {
|
||||
['command'] = {false,'string-list',{'set','remove','goto','list','return'}},
|
||||
['name'] = {false,'string-len',10}
|
||||
}, function(event,args)
|
||||
local player = Game.get_player(event)
|
||||
if not global[player.index] then local spawn_pos = player.force.get_spawn_position(player.surface) global[player.index] = {Spawn={spawn_pos.x,spawn_pos.y},_m=3,_n=1,_r={spawn_pos.x,spawn_pos.y}} end
|
||||
local homes = global[player.index]
|
||||
local command = args.command
|
||||
local name = args.name
|
||||
if command == 'set' then
|
||||
local pos = {math.floor(player.position.x),math.floor(player.position.y)}
|
||||
if homes._n+1 > homes._m then player_return{'ExpGamingCommands-home.too-many-homes',homes._m} return commands.error end
|
||||
if not homes[name] then homes._n=homes._n+1 end
|
||||
homes[name] = pos
|
||||
player_return{'ExpGamingCommands-home.set',name,pos[1],pos[2]}
|
||||
elseif command == 'remove' then
|
||||
if not homes[name] then player_return{'ExpGamingCommands-home.invalid',name} return commands.error end
|
||||
homes[name] = nil
|
||||
homes._n=homes._n-1
|
||||
player_return{'ExpGamingCommands-home.remove',name}
|
||||
elseif command == 'goto' then
|
||||
if not homes[name] then player_return{'ExpGamingCommands-home.invalid',name} return commands.error end
|
||||
local pos = {math.floor(player.position.x),math.floor(player.position.y)}
|
||||
player.teleport(player.surface.find_non_colliding_position('player',homes[name],32,1),player.surface)
|
||||
homes._r = pos
|
||||
player_return{'ExpGamingCommands-home.goto',name}
|
||||
elseif command == 'return' then
|
||||
local pos = {math.floor(player.position.x),math.floor(player.position.y)}
|
||||
player.teleport(player.surface.find_non_colliding_position('player',homes._r,32,1),player.surface)
|
||||
homes._r = pos
|
||||
player_return{'ExpGamingCommands-home.return',pos[1],pos[2]}
|
||||
else
|
||||
player_return{'ExpGamingCommands-home.homes',homes._n,homes._m}
|
||||
local index = 1
|
||||
for home_name,pos in pairs(homes) do if home_name ~= '_n' and home_name ~= '_r' and home_name ~= '_m' then player_return{'ExpGamingCommands-home.home',index,home_name,pos[1],pos[2]} index=index+1 end end
|
||||
end
|
||||
end)
|
||||
@@ -1,9 +0,0 @@
|
||||
[ExpGamingCommands-home]
|
||||
too-many-homes=You have too many homes, to add more you must remove one. Your max is __1__.
|
||||
homes=Your Homes: (__1__/__2__)
|
||||
home=__1__) __2__: __3__ , __4__
|
||||
set=Your home "__1__" has been set to __2__ , __3__
|
||||
remove=Your home "__1__" has been removed
|
||||
goto=You are now at "__1__"
|
||||
return=You are now at your previous location: __1__ , __2__
|
||||
invalid=Invalid name, __1__
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingCommands.home",
|
||||
"version": "4.0.0",
|
||||
"description": "Allows players to set homes and then return to them later.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Teleport",
|
||||
"ExpGaming",
|
||||
"Home",
|
||||
"Return",
|
||||
"Set Home",
|
||||
"Commands"
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Command": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingCommands.kill@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
|
||||
--- Kills a player of a lower rank
|
||||
-- @command kill
|
||||
-- @param player the player to be killed
|
||||
commands.add_command('kill', 'Kills a player. No player name kills yourself.', {
|
||||
['player']={false,'player-rank-alive'}
|
||||
}, function(event,args)
|
||||
local _player = Game.get_player(event)
|
||||
local player = args.player
|
||||
if player then player.character.die()
|
||||
else _player.character.die() end
|
||||
end).default_admin_only = true
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingCommands.kill",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a command which can be used to kill a player or yourself.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Command",
|
||||
"ExpGaming",
|
||||
"Kill",
|
||||
"Death",
|
||||
"Admin",
|
||||
"Tool"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingCore.Role": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingCommands.repair@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
|
||||
-- Set an item to true to disallow it from being repaired
|
||||
local disallow = {
|
||||
['loader']=true,
|
||||
['fast-loader']=true,
|
||||
['express-loader']=true,
|
||||
['electric-energy-interface']=true,
|
||||
['infinity-chest']=true
|
||||
}
|
||||
|
||||
-- Given const = 100: admin+ has unlimited, admin has const (100), mod has const / 2 (50), member has const / 5 (20)
|
||||
local const = 100
|
||||
local repairDisallow
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init = function(self)
|
||||
if loaded_modules['ExpGamingAdmin.TempBan'] then verbose('ExpGamingAdmin.TempBan is installed; Loading tempban src') repairDisallow = require(module_path..'/src/tempban') end
|
||||
end
|
||||
}
|
||||
|
||||
--- Used so that the value can be overridden if tempban is present
|
||||
-- @local
|
||||
-- @function repairDisallow
|
||||
-- @param player the player who called the command
|
||||
-- @param entity the entity which was repaired
|
||||
repairDisallow = function(player,entity)
|
||||
player_return('You have repaired: '..entity.name..' this item is not allowed.',defines.textcolor.crit,player)
|
||||
entity.destroy()
|
||||
end
|
||||
|
||||
--- Used to repair and heal items in an area, different ranks get different size areas
|
||||
-- @command repair
|
||||
-- @param range the range that items are repaired in
|
||||
commands.add_command('repair', 'Repairs all destroyed and damaged entities in an area.', {
|
||||
['range']={true,'number-int'}
|
||||
}, function(event,args)
|
||||
local range = args.range
|
||||
local player = Game.get_player(event)
|
||||
local role = Role.get_highest(player)
|
||||
local highest_admin_power = Role.meta.groups.Admin.highest-1
|
||||
local max_range = role.index-highest_admin_power > 0 and const/(role.index-highest_admin_power) or nil
|
||||
local center = player and player.position or {x=0,y=0}
|
||||
if not range or max_range and range > max_range then player_return({'ExpGamingCore_Command.invalid-range',0,math.floor(max_range)}) return commands.error end
|
||||
local area = {{center.x-range,center.y-range},{center.x+range,center.y+range}}
|
||||
local max_time_to_live = 2^32 - 1
|
||||
local sq_range = range^2
|
||||
for key, entity in pairs(player.surface.find_entities_filtered({area=area,type='entity-ghost'})) do
|
||||
if entity.force == player.force and (entity.position.x-center.x)^2+(entity.position.y-center.y)^2 < sq_range then
|
||||
if disallow[entity.ghost_prototype.name] then repairDisallow(player,entity)
|
||||
elseif entity.time_to_live ~= max_time_to_live then entity.revive() end
|
||||
end
|
||||
end
|
||||
for key, entity in pairs(player.surface.find_entities(area)) do
|
||||
if entity.force == player.force and (entity.position.x-center.x)^2+(entity.position.y-center.y)^2 < sq_range and entity.health then entity.health = 10000 end
|
||||
end
|
||||
end).default_admin_only = true
|
||||
|
||||
return ThisModule
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingCommands.repair",
|
||||
"version": "4.0.0",
|
||||
"description": "Allows items to be healed and repaired with a command",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"ExpGaming",
|
||||
"Command",
|
||||
"Heal",
|
||||
"Repair",
|
||||
"Ghosts",
|
||||
"Revive"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Role": "^4.0.0",
|
||||
"ExpGamingAdmin.TempBan": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
-- not_luadoc=true
|
||||
local temp_ban = require('ExpGamingAdmin').temp_ban
|
||||
return function(player,entity)
|
||||
player_return('You have repaired: '..entity.name..' this item is not allowed.',defines.textcolor.crit,player)
|
||||
temp_ban(player,'<server>','Attempt To Repair A Banned Item')
|
||||
entity.destroy()
|
||||
end
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingCommands",
|
||||
"version": "4.0.0",
|
||||
"description": "A Collection of all of the custom commands used on ExpGaming servers.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Commands",
|
||||
"ExpGaming",
|
||||
"Admin",
|
||||
"Tools"
|
||||
],
|
||||
"author": "Cooldude2606",
|
||||
"contact": "Discord: Cooldude2606#5241",
|
||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||
"submodules": {
|
||||
"ExpGamingCommands.bonus": "4.0.0",
|
||||
"ExpGamingCommands.cheatMode": "4.0.0",
|
||||
"ExpGamingCommands.home": "4.0.0",
|
||||
"ExpGamingCommands.kill": "4.0.0",
|
||||
"ExpGamingCommands.repair": "4.0.0",
|
||||
"ExpGamingCommands.tags": "4.0.0",
|
||||
"ExpGamingCommands.teleport": "4.0.0"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingCommands@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Role -- ExpGamingCore.Role@^4.0.0
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||
end
|
||||
}
|
||||
|
||||
--- Gives you a tag
|
||||
-- @command tag
|
||||
-- @param tag the tag you want to have
|
||||
commands.add_command('tag', 'Give yourself a custom tag. Use "" to have more than one word.', {
|
||||
['tag'] = {true,'string-len',20}
|
||||
}, function(event,args)
|
||||
local player = Game.get_player(event)
|
||||
if Role then
|
||||
local role = Role.get_highest(player)
|
||||
player.tag = role.tag..' - '..args.tag
|
||||
else player.tag = args.tag end
|
||||
player_return('Your tag has been set. Use /tag-clear to remove your tag')
|
||||
end)
|
||||
|
||||
--- Gives you a tag
|
||||
-- @command tag
|
||||
-- @param tag the tag you want to have
|
||||
commands.add_command('tag-clear', 'Removes a custom tag.', {
|
||||
['player'] = {false,'player-rank'}
|
||||
}, function(event,args)
|
||||
local player = args.player or game.player
|
||||
if Role then
|
||||
local role = Role.get_highest(player)
|
||||
player.tag = role.tag
|
||||
else player.tag = '' end
|
||||
player_return('Your tag has been removed.')
|
||||
end)
|
||||
|
||||
return ThisModule
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingCommands.tags",
|
||||
"version": "4.0.0",
|
||||
"description": "Allows tags to be used by users.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Tags",
|
||||
"Custom Tags",
|
||||
"Commands",
|
||||
"ExpGaming"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingCommands.teleport@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
|
||||
--- Teleports the user to the player given
|
||||
-- @command go-to
|
||||
-- @param player player to go to
|
||||
commands.add_command('go-to', 'Go to a player\'s location', {
|
||||
['player']={true,'player-online'}
|
||||
}, function(event,args)
|
||||
Admin.go_to(args.player,event)
|
||||
end)
|
||||
|
||||
--- Teleports a player to the user
|
||||
-- @command bring
|
||||
-- @param player player to go to
|
||||
commands.add_command('bring', 'Bring a player to your location', {
|
||||
['player']={true,'player-online'}
|
||||
}, function(event,args)
|
||||
Admin.bring(args.player,event)
|
||||
end)
|
||||
|
||||
--- Teleports one player to another
|
||||
-- @command tp
|
||||
-- @param player_one the player that is teleported
|
||||
-- @param player_two the player who is the destination
|
||||
commands.add_command('tp', 'Teleport a player to another player\'s location', {
|
||||
['player_one']={true,'player-online'},
|
||||
['player_two']={true,'player-online'}
|
||||
}, function(event,args)
|
||||
Admin.tp(args.player_one,args.player_two)
|
||||
end)
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingCommands.teleport",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a few commands used to teleport players.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Teleport",
|
||||
"Tp",
|
||||
"Bring",
|
||||
"GoTo",
|
||||
"ExpGaming",
|
||||
"Command",
|
||||
"Admin",
|
||||
"Tools"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingAdmin.Teleport": "^4.0.0",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,298 +0,0 @@
|
||||
--- Command system that allows middle ware and auto validation of command arguments.
|
||||
-- @module ExpGamingCore.Command@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias commands
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color = require('FactorioStdLib.Color')
|
||||
|
||||
--- Used as an error constant for validation
|
||||
-- @field commands.error
|
||||
-- @usage return commands.error, 'err message'
|
||||
-- @usage return commands.error('err message')
|
||||
commands.error = setmetatable({},{__call=function(...) return ... end})
|
||||
commands._add_command = commands.add_command
|
||||
local commandDataStore = {}
|
||||
local middleware = {}
|
||||
|
||||
--- Used to add middle ware to the command handler, functions should return true or false
|
||||
-- @tparam function callback function(player,commandName,event) should return true to allow next middle ware to run
|
||||
function commands.add_middleware(callback) if not is_type(callback,'function') then error('Callback is not a function',2) return end table.insert(middleware,callback) end
|
||||
|
||||
--- Index of all command data
|
||||
-- @field commands.data
|
||||
-- @usage commands.command_name -- returns command data
|
||||
-- @usage commands.data -- returns all data
|
||||
-- @tparam ?string|table|event key the command that will be returned: string is the name, table is the command data, event is event from add_command
|
||||
-- @treturn table the command data
|
||||
setmetatable(commands,{
|
||||
__index=function(tbl,key) return is_type(key,'table') and (key.command and rawget(commandDataStore,key.name) or key) or key == 'data' and commandDataStore or rawget(commandDataStore,key) end
|
||||
})
|
||||
|
||||
--- Collection of functions that can be used to validate inputs
|
||||
-- @table commands.validate
|
||||
-- @usage commands.validate[type](value,event,...)
|
||||
-- @tparam string type the type that the value should be
|
||||
-- @param value the value that will be tested
|
||||
-- @param ... any other data that can be passed to the function
|
||||
-- @return[1] the validated value
|
||||
-- @return[2] error constant
|
||||
-- @return[2] the err message
|
||||
-- @field __comment replace _ with - the ldoc did not like me using - in the names
|
||||
-- @field string basically does nothing but a type filed is required
|
||||
-- @field string_inf same as string but is infinite in length, must be last arg
|
||||
-- @field string_len same as string but can define a max length
|
||||
-- @field number converts the input into a number
|
||||
-- @field number_int converts the input to a number and floors it
|
||||
-- @field number_range allows a number in a range min < X <= max
|
||||
-- @field number_range allows a number in a range after it has been floored min < math.floor(X) <= max
|
||||
-- @field player converts the input into a valid player
|
||||
-- @field player_online converts the input to a player if the player is online
|
||||
-- @field player_alive converts the input to a player if the player is online and alive
|
||||
-- @field player_role converts the input to a player if the player is a lower rank than the user or if the person is not admin and the user is
|
||||
-- @field player_role-online converts the input to a player if the player is a lower rank than the user and online
|
||||
-- @field player_role_alive converts the input to a player if the player is a lower rank than the user and online and alive
|
||||
commands.validate = {
|
||||
['boolean']=function(value) value = value.lower() if value == 'true' or value == 'yes' or value == 'y' or value == '1' then return true else return false end end,
|
||||
['string']=function(value) return tostring(value) end,
|
||||
['string-inf']=function(value) return tostring(value) end,
|
||||
['string-list']=function(value,event,list)
|
||||
local rtn = tostring(value) and table.includes(list,tostring(value)) and tostring(value) or nil
|
||||
if not rtn then return commands.error{'ExpGamingCore_Command.error-string-list',table.concat(list,', ')} end return rtn end,
|
||||
['string-len']=function(value,event,max)
|
||||
local rtn = tostring(value) and tostring(value):len() <= max and tostring(value) or nil
|
||||
if not rtn then return commands.error{'ExpGamingCore_Command.error-string-len',max} end return rtn end,
|
||||
['number']=function(value)
|
||||
local rtn = tonumber(value) or nil
|
||||
if not rtn then return commands.error{'ExpGamingCore_Command.error-number'} end return rtn end,
|
||||
['number-int']=function(value)
|
||||
local rtn = tonumber(value) and math.floor(tonumber(value)) or nil
|
||||
if not rtn then return commands.error{'ExpGamingCore_Command.error-number'} end return rtn end,
|
||||
['number-range']=function(value,event,min,max)
|
||||
local rtn = tonumber(value) and tonumber(value) > min and tonumber(value) <= max and tonumber(value) or nil
|
||||
if not rtn then return commands.error{'ExpGamingCore_Command.error-number-range',min,max} end return rtn end,
|
||||
['number-range-int']=function(value,event,min,max)
|
||||
local rtn = tonumber(value) and math.floor(tonumber(value)) > min and math.floor(tonumber(value)) <= max and math.floor(tonumber(value)) or nil
|
||||
if not rtn then return commands.error{'ExpGamingCore_Command.error-number-range',min,max} end return rtn end,
|
||||
['player']=function(value)
|
||||
local rtn = Game.get_player(value) or nil
|
||||
if not rtn then return commands.error{'ExpGamingCore_Command.error-player',value} end return rtn end,
|
||||
['player-online']=function(value)
|
||||
local player,err = commands.validate['player'](value)
|
||||
if err then return commands.error(err) end
|
||||
local rtn = player.connected and player or nil
|
||||
if not rtn then return commands.error{'ExpGamingCore_Command.error-player-online'} end return rtn end,
|
||||
['player-alive']=function(value)
|
||||
local player,err = commands.validate['player-online'](value)
|
||||
if err then return commands.error(err) end
|
||||
local rtn = player.character and player.character.health > 0 and player or nil
|
||||
if not rtn then return commands.error{'ExpGamingCore_Command.error-player-alive'} end return rtn end,
|
||||
['player-rank']=function(value,event)
|
||||
local player,err = commands.validate['player'](value)
|
||||
if err then return commands.error(err) end
|
||||
local rtn = player.admin and Game.get_player(event).admin and player or nil
|
||||
if not rtn then return commands.error{'ExpGamingCore_Command.error-player-rank'} end return rtn end,
|
||||
['player-rank-online']=function(value)
|
||||
local player,err = commands.validate['player-online'](value)
|
||||
if err then return commands.error(err) end
|
||||
local player,err = commands.validate['player-rank'](player)
|
||||
if err then return commands.error(err) end return player end,
|
||||
['player-rank-alive']=function(value)
|
||||
local player,err = commands.validate['player-alive'](value)
|
||||
if err then return commands.error(err) end
|
||||
local player,err = commands.validate['player-rank'](player)
|
||||
if err then return commands.error(err) end return player end,
|
||||
}
|
||||
--- Adds a function to the validation list
|
||||
-- @tparam string name the name of the validation
|
||||
-- @tparam function callback function(value,event) which returns either the value to be used or commands.error{'error-message'}
|
||||
function commands.add_validation(name,callback) if not is_type(callback,'function') then error('Callback is not a function',2) return end commands.validate[name]=callback end
|
||||
|
||||
--- Returns the inputs of this command as a formated string
|
||||
-- @usage commands.format_inputs('interface') -- returns <code> (if you have ExpGamingCore.Server)
|
||||
-- @tparam ?string|table|event command the command to get the inputs of
|
||||
-- @treturn string the formated string for the inputs
|
||||
function commands.format_inputs(command)
|
||||
command = commands[command]
|
||||
if not is_type(command,'table') then error('Command is not valid',2) end
|
||||
local rtn = ''
|
||||
for name,data in pairs(command.inputs) do
|
||||
if data[1] == false then rtn=rtn..string.format('[%s] ',name)
|
||||
else rtn=rtn..string.format('<%s> ',name) end
|
||||
end
|
||||
return rtn
|
||||
end
|
||||
|
||||
--- Used to validate the arguments of a command, will understand strings with "" as a single param else spaces divede the params
|
||||
-- @usage commands.validate_args(event) -- returns args table
|
||||
-- @tparam table event this is the event created by add_command not on_console_command
|
||||
-- @treturn[1] table the args for this command
|
||||
-- @return[2] command.error
|
||||
-- @treturn string the error that happend while parsing the args
|
||||
function commands.validate_args(event)
|
||||
local command = commands[event.name]
|
||||
if not is_type(command,'table') then error('Command not valid',2) end
|
||||
local rtn = {}
|
||||
local count = 0
|
||||
local count_opt = 0
|
||||
for _,data in pairs(command.inputs) do count = count + 1 if data[1] == false then count_opt = count_opt + 1 end end
|
||||
-- checks that there is some args given if there is meant to be
|
||||
if not event.parameter then
|
||||
if count == count_opt then return rtn
|
||||
else return commands.error('invalid-inputs') end
|
||||
end
|
||||
-- splits the args into words so that it can be used to assign values
|
||||
local words = string.split(event.parameter,' ')
|
||||
local index = 0
|
||||
for _,word in pairs(words) do
|
||||
index = index+1
|
||||
if not word then break end
|
||||
local pos, _pos = word:find('"')
|
||||
local hasSecond = pos and word:find('"',pos+1) or nil
|
||||
while not hasSecond and pos and pos == _pos do
|
||||
local next = table.remove(words,index+1)
|
||||
if not next then return commands.error('invalid-parse') end
|
||||
words[index] = words[index]..' '..next
|
||||
_pos = words[index]:find('"',pos+1)
|
||||
end
|
||||
end
|
||||
-- assigns the values from the words to the args
|
||||
index = 0
|
||||
for name,data in pairs(command.inputs) do
|
||||
index = index+1
|
||||
local arg = words[index]
|
||||
if not arg and data[1] then return commands.error('invalid-inputs') end
|
||||
if data[2] == 'string-inf' then rtn[name] = table.concat(words,' ',index) break end
|
||||
local valid = is_type(data[2],'function') and data[2] or commands.validate[data[2]] or error('Invalid validation ("'..tostring(data[2])..'") for command: "'..command.name..'/'..name..'"')
|
||||
local temp_tbl = table.deepcopy(data) table.remove(temp_tbl,1) table.remove(temp_tbl,1)
|
||||
local value, err = valid(arg,event,unpack(temp_tbl))
|
||||
if value == commands.error then return value, err end
|
||||
rtn[name] = is_type(value,'string') and value:gsub('"','') or value
|
||||
end
|
||||
return rtn
|
||||
end
|
||||
|
||||
--- Used to return all the commands a player can use
|
||||
-- @usage get_commands(1) -- return table of command data for each command that the player can use
|
||||
-- @tparam ?index|name|player| player the player to test as
|
||||
-- @treturn table a table containg all the commands the player can use
|
||||
function commands.get_commands(player)
|
||||
player = Game.get_player(player)
|
||||
local commands = {}
|
||||
if not player then return error('Invalid player',2) end
|
||||
for name,data in pairs(commandDataStore) do
|
||||
if #middleware > 0 then for _,callback in pairs(middleware) do
|
||||
local success, err = pcall(callback,player,name,data)
|
||||
if not success then error(err)
|
||||
elseif err then table.insert(commands,data) end
|
||||
end elseif data.default_admin_only == true and player.admin then table.insert(commands,data) end
|
||||
end
|
||||
return commands
|
||||
end
|
||||
|
||||
local function logMessage(player_name,command,message,args)
|
||||
game.write_file('commands.log',
|
||||
game.tick
|
||||
..' Player: "'..player_name..'"'
|
||||
..' '..message..': "'..command.name..'"'
|
||||
..' With args of: '..table.tostring(args)
|
||||
..'\n'
|
||||
, true, 0)
|
||||
end
|
||||
|
||||
--- Used to call the custom commands
|
||||
-- @usage You dont its an internal command
|
||||
-- @tparam table command the event rasied by the command
|
||||
local function run_custom_command(command)
|
||||
local data = commands.data[command.name]
|
||||
local player = Game.get_player(command) or SERVER
|
||||
-- runs all middle ware if any, if there is no middle where then it relies on .default_admin_only
|
||||
if #middleware > 0 then for _,callback in pairs(middleware) do
|
||||
local success, err = pcall(callback,player,command.name,command)
|
||||
if not success then error(err)
|
||||
elseif not err then
|
||||
player_return({'ExpGamingCore_Command.command-fail',{'ExpGamingCore_Command.unauthorized'}},defines.textcolor.crit)
|
||||
logMessage(player.name,command,'Failed to use command (Unauthorized)',commands.validate_args(command))
|
||||
game.player.play_sound{path='utility/cannot_build'}
|
||||
return
|
||||
end
|
||||
end elseif data.default_admin_only == true and player and not player.admin then
|
||||
player_return({'ExpGamingCore_Command.command-fail',{'ExpGamingCore_Command.unauthorized'}},defines.textcolor.crit)
|
||||
logMessage(player.name,command,'Failed to use command (Unauthorized)',commands.validate_args(command))
|
||||
game.player.play_sound{path='utility/cannot_build'}
|
||||
return
|
||||
end
|
||||
-- gets the args for the command
|
||||
local args, err = commands.validate_args(command)
|
||||
if args == commands.error then
|
||||
if is_type(err,'table') then table.insert(err,command.name) table.insert(err,commands.format_inputs(data))
|
||||
player_return({'ExpGamingCore_Command.command-fail',err},defines.textcolor.high) else player_return({'ExpGamingCore_Command.command-fail',{'ExpGamingCore_Command.invalid-inputs',command.name,commands.format_inputs(data)}},defines.textcolor.high) end
|
||||
logMessage(player.name,command,'Failed to use command (Invalid Args)',args)
|
||||
player.play_sound{path='utility/deconstruct_big'}
|
||||
return
|
||||
end
|
||||
-- runs the command
|
||||
local success, err = pcall(data.callback,command,args)
|
||||
if not success then error(err) end
|
||||
if err ~= commands.error then player_return({'ExpGamingCore_Command.command-ran'},defines.textcolor.info) end
|
||||
logMessage(player.name,command,'Used command',args)
|
||||
end
|
||||
|
||||
--- Used to define commands
|
||||
-- @usage --see examples in file
|
||||
-- @tparam string name the name of the command
|
||||
-- @tparam[opt='No Description'] string description the description of the command
|
||||
-- @tparam[opt=an infinite string] table inputs a table of the inputs to be used, last index being true makes the last parameter open ended (longer than one word)
|
||||
-- @tparam function callback the function to call on the event
|
||||
commands.add_command = function(name, description, inputs, callback)
|
||||
if commands[name] then error('That command is already registered',2) end
|
||||
if not is_type(name,'string') then error('Command name has not been given') end
|
||||
if not is_type(callback,'function') or not is_type(inputs,'table') then
|
||||
if is_type(inputs,'function') then commands._add_command(name,description,inputs)
|
||||
else error('Invalid args given to add_command') end
|
||||
end
|
||||
verbose('Created Command: '..name)
|
||||
-- test for string and then test for locale string
|
||||
description = is_type(description,'string') and description
|
||||
or is_type(description,'table') and is_type(description[1],'string') and string.find(description[1],'.+[.].+') and {description,''}
|
||||
or 'No Description'
|
||||
inputs = is_type(inputs,'table') and inputs or {['param']={false,'string-inf'}}
|
||||
commandDataStore[name] = {
|
||||
name=name,
|
||||
description=description,
|
||||
inputs=inputs,
|
||||
callback=callback,
|
||||
admin_only=false
|
||||
}
|
||||
local help = is_type(description,'string') and commands.format_inputs(name)..'- '..description
|
||||
or is_type(description,'table') and is_type(description[1],'string') and string.find(description[1],'.+[.].+') and {description,commands.format_inputs(name)..'- '}
|
||||
or commands.format_inputs(name)
|
||||
commandDataStore[name].help = help
|
||||
commands._add_command(name,help,function(...)
|
||||
local success, err = Manager.sandbox(run_custom_command,{},...)
|
||||
if not success then error(err) end
|
||||
end)
|
||||
return commandDataStore[name]
|
||||
end
|
||||
|
||||
return commands
|
||||
|
||||
--[[
|
||||
command example
|
||||
|
||||
**locale file**
|
||||
[foo]
|
||||
description=__1__ this is a command
|
||||
|
||||
**control.lua**
|
||||
commands.add_command('foo',{'foo.description'},{
|
||||
['player']={true,'player'}, -- a required arg that must be a valid player
|
||||
['number']={true,'number-range',0,10}, -- a required arg that must be a number 0<X<=10
|
||||
['pwd']={true,function(value,event) if value == 'password123' then return true else return commands.error('Invalid Password') end} -- a required arg pwd that has custom validation
|
||||
['reason']={false,'string-inf'} -- an optional arg that is and infinite length (useful for reasons)
|
||||
},function(event,args)
|
||||
args.player.print(args.number)
|
||||
if args.reasons then args.player.print(args.reason) end
|
||||
end)
|
||||
]]
|
||||
@@ -1,9 +0,0 @@
|
||||
[ExpGamingCore_Command]
|
||||
unauthorized=401 - Unbefugt: Zugang verweigert. Du hast keinen Zugriff auf diese Befehle!
|
||||
invalid-inputs=ungültige Eingabe, /__1__ __2__
|
||||
invalid-range=ungültige Reichweite, Min: __1__, Max: __2__
|
||||
invalid-length=ungültige Länge, Max: __1__
|
||||
invalid-player=ungültiger Spieler Name, __1__ , Versuche "Tab" zu benutzen, damit sich der Name automatisch vervollständigt.
|
||||
offline-player=Der betroffene Spieler ist offline, Befehl konnte nicht ausgeführt werden.
|
||||
dead-player=Der betroffene Spieler ist Tod, Befehl konnte nicht ausgeführt werden.
|
||||
command-ran=Befehl ausgeführt.
|
||||
@@ -1,14 +0,0 @@
|
||||
[ExpGamingCore_Command]
|
||||
unauthorized=Unauthorized, Access is denied due to invalid credentials
|
||||
error-string-list=Invalid Option, Must be one of: __1__
|
||||
error-string-len=Invalid Length, Max: __1__
|
||||
error-number=Invalid Number
|
||||
error-number-range=Invalid Range, Min (exclusive): __1__, Max (inclusive): __2__
|
||||
error-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name
|
||||
error-player-online=Player is offline.
|
||||
error-player-alive=Player is dead.
|
||||
error-player-rank=Player is of Higher Rank.
|
||||
invalid-inputs=Invalid Input, /__1__ __2__
|
||||
invalid-parse=Invalid Input, There was a problem prasing the paramaters
|
||||
command-ran=Command Complete
|
||||
command-fail=Command failed to run: __1__
|
||||
@@ -1,9 +0,0 @@
|
||||
[ExpGamingCore_Command]
|
||||
unauthorized=401 - Unauthorized: Access is denied due to invalid credentials
|
||||
invalid-inputs=Invalid Input, /__1__ __2__
|
||||
invalid-range=Invalid Range, Min: __1__, Max: __2__
|
||||
invalid-length=Invalid Length, Max: __1__
|
||||
invalid-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name
|
||||
offline-player=Player is offline, Command Failed To Run
|
||||
dead-player=Player is dead, Command Failed To Run
|
||||
command-ran=Command Complete
|
||||
@@ -1,9 +0,0 @@
|
||||
[ExpGamingCore_Command]
|
||||
unauthorized=401 - Onbevoegd: toegang wordt geweigerd vanwege ongeldige inloggegevens
|
||||
invalid-inputs=Onjuiste invoer, /__1__ __2__
|
||||
invalid-range=Onjuiste radius, Min: __1__, Max: __2__
|
||||
invalid-length=Onjuiste lengte, Max: __1__
|
||||
invalid-player=Onjuiste naam, __1__ , probeer tab te gebruiken om de naam automatisch in te vullen
|
||||
offline-player=Speler is offline.
|
||||
dead-player=Speler is dood.
|
||||
command-ran=Commando uitgevoerd.
|
||||
@@ -1,9 +0,0 @@
|
||||
[ExpGamingCore_Command]
|
||||
unauthorized=401 - Otillåten: Tillgång nekas på grund av otillräcklig säkerhetsprövning.
|
||||
invalid-inputs=Igiltig inmatning, /__1__ __2__
|
||||
invalid-range=Invalid räckvid, Min: __1__, Max: __2__
|
||||
invalid-length=ogiltig längd, Max: __1__
|
||||
invalid-player=Ogiltigt spelarnamn, __1__ , försök använda tab-tangenten för att auto-slutföra namn.
|
||||
offline-player=Spelare är offline. Kommando misslyckades med att köras.
|
||||
dead-player=Spelare är död. Kommando misslyckades med att köras.
|
||||
command-ran=Kommandot slutfört
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingCore.Command",
|
||||
"version": "4.0.0",
|
||||
"description": "A better command handler than the base game.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Library",
|
||||
"Lib",
|
||||
"ExpGaming",
|
||||
"Core",
|
||||
"Commands"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"FactorioStdLib.Table": "^0.8.0",
|
||||
"FactorioStdLib.Color": "^0.8.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
},
|
||||
"collection": "ExpGamingCore@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
-- defines for groups
|
||||
Group{
|
||||
name='Admin',
|
||||
disallow={
|
||||
'edit_permission_group',
|
||||
'delete_permission_group',
|
||||
'add_permission_group'
|
||||
}
|
||||
}
|
||||
|
||||
Group{
|
||||
name='HiMember',
|
||||
disallow={
|
||||
'edit_permission_group',
|
||||
'delete_permission_group',
|
||||
'add_permission_group'
|
||||
}
|
||||
}
|
||||
|
||||
Group{
|
||||
name='Member',
|
||||
disallow={
|
||||
'edit_permission_group',
|
||||
'delete_permission_group',
|
||||
'add_permission_group',
|
||||
'set_auto_launch_rocket',
|
||||
'change_programmable_speaker_alert_parameters',
|
||||
'drop_item'
|
||||
}
|
||||
}
|
||||
|
||||
Group{
|
||||
name='User',
|
||||
disallow={
|
||||
'edit_permission_group',
|
||||
'delete_permission_group',
|
||||
'add_permission_group',
|
||||
'set_auto_launch_rocket',
|
||||
'change_programmable_speaker_alert_parameters',
|
||||
'drop_item',
|
||||
'build_terrain',
|
||||
'remove_cables',
|
||||
'launch_rocket',
|
||||
'reset_assembling_machine',
|
||||
'cancel_research'
|
||||
}
|
||||
}
|
||||
|
||||
Group{
|
||||
name='Jail',
|
||||
disallow={
|
||||
'set_allow_commands',
|
||||
'edit_permission_group',
|
||||
'delete_permission_group',
|
||||
'add_permission_group',
|
||||
'open_character_gui',
|
||||
'begin_mining',
|
||||
'start_walking',
|
||||
'player_leave_game',
|
||||
'open_blueprint_library_gui',
|
||||
'build_item',
|
||||
'use_item',
|
||||
'select_item',
|
||||
'rotate_entity',
|
||||
'open_train_gui',
|
||||
'open_train_station_gui',
|
||||
'open_gui',
|
||||
'open_item',
|
||||
'deconstruct',
|
||||
'build_rail',
|
||||
'cancel_research',
|
||||
'start_research',
|
||||
'set_train_stopped',
|
||||
'select_gun',
|
||||
'open_technology_gui',
|
||||
'open_trains_gui',
|
||||
'edit_custom_tag',
|
||||
'craft',
|
||||
'setup_assembling_machine',
|
||||
}
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
--- Adds a system to manage and auto-create permission groups.
|
||||
-- @module ExpGamingCore@Group
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias Group
|
||||
|
||||
-- Module Require
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
|
||||
--- Used as an interface for factorio permissions groups
|
||||
-- @type Group
|
||||
-- @field _prototype the prototype of this class
|
||||
-- @field groups a table of all groups, includes auto complete on the indexing
|
||||
local _GroupSelfRef
|
||||
local Group = {
|
||||
_prototype = {},
|
||||
groups = setmetatable({},{
|
||||
__index=table.autokey,
|
||||
__newindex=function(tbl,key,value)
|
||||
rawset(tbl,key,_GroupSelfRef.define(value))
|
||||
end
|
||||
}),
|
||||
on_init = function()
|
||||
if loaded_modules['ExpGamingCore.Server'] then require('ExpGamingCore.Server') end
|
||||
end,
|
||||
on_post = function(self)
|
||||
-- creates a root role that the server can use
|
||||
self{name='Root',disallow={}}
|
||||
-- loads the groups in config
|
||||
require(module_path..'/config',{Group=self})
|
||||
end
|
||||
}
|
||||
_GroupSelfRef=Group
|
||||
|
||||
-- Function Define
|
||||
|
||||
--- Defines a new instance of a group
|
||||
-- @usage Group.define{name='foo',disallow={'edit_permission_group','delete_permission_group','add_permission_group'}} -- returns new group
|
||||
-- @usage Group{name='foo',disallow={'edit_permission_group','delete_permission_group','add_permission_group'}} -- returns new group
|
||||
-- @tparam table obj contains string name and table disallow of defines.input_action
|
||||
-- @treturn Group the group which has been made
|
||||
function Group.define(obj)
|
||||
if not type_error(game,nil,'Cant define Group during runtime.') then return end
|
||||
if not type_error(obj.name,'string','Group creation is invalid: group.name is not a string') then return end
|
||||
if not type_error(obj.disallow,'table','Group creation is invalid: group.disallow is not a table') then return end
|
||||
verbose('Created Group: '..obj.name)
|
||||
setmetatable(obj,{__index=function(tbl,key) return Group._prototype[key] or game and game.permissions.get_group(tbl.name)[key] or nil end})
|
||||
obj.connected_players = setmetatable({self=obj},Group._prototype.connected_players_mt)
|
||||
rawset(Group.groups,obj.name,obj)
|
||||
return obj
|
||||
end
|
||||
|
||||
--- Used to get the group of a player or the group by name
|
||||
-- @usage Group.get('foo') -- returns group foo
|
||||
-- @usage Group.get(player) -- returns group of player
|
||||
-- @tparam ?LuaPlayer|pointerToPlayer|string mixed can either be the name or raw group of a group or a player indenifier
|
||||
-- @treturn table the group which was found or nil
|
||||
function Group.get(mixed)
|
||||
if is_type(mixed,'table') and mixed.name then mixed = mixed.name end
|
||||
if game and Game.get_player(mixed) then mixed = Game.get_player(mixed).permission_group.name end
|
||||
local rtn = Group.groups[mixed]
|
||||
if not rtn and game and is_type(mixed,'string') and game.permissions.get_group(mixed) then
|
||||
rtn = setmetatable({disallow={},name=mixed},{
|
||||
__index=function(tbl,key) return Group._prototype[key] or game and game.permissions.get_group(tbl.name)[key] or nil end
|
||||
})
|
||||
rtn.connected_players = setmetatable({self=rtn},Group._prototype.connected_players_mt)
|
||||
end
|
||||
return rtn
|
||||
end
|
||||
|
||||
--- Used to place a player into a group
|
||||
-- @usage Group.assign(player,group)
|
||||
-- @tparam ?LuaPlayer|pointerToPlayer player the player to assign the group to
|
||||
-- @tparam ?string|LuaPermissionGroup the group to add the player to
|
||||
-- @treturn boolean was the player assigned
|
||||
function Group.assign(player,group)
|
||||
player = Game.get_player(player)
|
||||
if not player then error('Invalid player #1 given to Group.assign.',2) return end
|
||||
group = Group.get(group)
|
||||
if not group then error('Invalid group #2 given to Group.assign.',2) return end
|
||||
return group:add_player(player)
|
||||
end
|
||||
|
||||
--- Used to get the factorio permission group linked to this group
|
||||
-- @usage group:get_raw() -- returns LuaPermissionGroup of this group
|
||||
-- @treturn LuaPermissionGroup the factorio group linked to this group
|
||||
function Group._prototype:get_raw()
|
||||
if not self_test(self,'group','get_raw') then return end
|
||||
local _group = game.permissions.get_group(self.name)
|
||||
if not _group or _group.valid == false then error('No permissions group found, please to not remove groups with /permissions',2) return end
|
||||
return setmetatable({},{__index=_group})
|
||||
end
|
||||
|
||||
--- Used to add a player to this group
|
||||
-- @usage group:add_player(player) -- returns true if added
|
||||
-- @tparam ?LuaPlayer|pointerToPlayer player the player to add to the group
|
||||
-- @treturn boolean if the player was added
|
||||
function Group._prototype:add_player(player)
|
||||
if not self_test(self,'group','add_player') then return end
|
||||
player = Game.get_player(player)
|
||||
if not player then error('Invalid player #1 given to group.add_player.',2) return end
|
||||
local raw_group = self:get_raw()
|
||||
return raw_group.add_player(player)
|
||||
end
|
||||
|
||||
--- Used to remove a player from this group
|
||||
-- @usage group:remove_player(player) -- returns true if removed
|
||||
-- @tparam ?LuaPlayer|pointerToPlayer player the player to remove from the group
|
||||
-- @treturn boolean if the player was removed
|
||||
function Group._prototype:remove_player(player)
|
||||
if not self_test(self,'group','remove_player') then return end
|
||||
player = Game.get_player(player)
|
||||
if not player then error('Invalid player #1 given to group.remove_player.',2) return end
|
||||
local raw_group = self:get_raw()
|
||||
return raw_group.remove_player(player)
|
||||
end
|
||||
|
||||
--- Gets all players in this group
|
||||
-- @usage group:get_players() -- returns table of players
|
||||
-- @usage group.players -- returns table of players
|
||||
-- @usage group.connected_players -- returns table of online players
|
||||
-- @tparam[opt=false] boolean online if true returns only online players
|
||||
-- @treturn table table of players
|
||||
function Group._prototype:get_players(online)
|
||||
if not self_test(self,'group','get_players') then return end
|
||||
if online and not type_error(online,'boolean','Invalid argument #1 to group:get_players, online is not a boolean.') then return end
|
||||
local raw_group = self:get_raw()
|
||||
local rtn = {}
|
||||
if online then for _,player in pairs(raw_group.players) do if player.connected then table.insert(rtn,player) end end end
|
||||
return online and rtn or raw_group.players
|
||||
end
|
||||
|
||||
-- this is used to create a connected_players table
|
||||
Group._prototype.connected_players_mt = {
|
||||
__call=function(tbl) return tbl.self:get_players(true) end,
|
||||
__pairs=function(self)
|
||||
local players = self.self:get_players(true)
|
||||
local function next_pair(tbl,key)
|
||||
local k, v = next(players, key)
|
||||
if v then return k,v end
|
||||
end
|
||||
return next_pair, players, nil
|
||||
end,
|
||||
__ipairs=function(self)
|
||||
local players = self.self:get_players(true)
|
||||
local function next_pair(tbl,key)
|
||||
local k, v = next(players, key)
|
||||
if v then return k,v end
|
||||
end
|
||||
return next_pair, players, nil
|
||||
end
|
||||
}
|
||||
|
||||
--- Prints a message or value to all online players in this group
|
||||
-- @usage group.print('Hello, World!')
|
||||
-- @param rtn any value you wish to print, string not required
|
||||
-- @param colour the colour to print the message in
|
||||
-- @treturn number the number of players who received the message
|
||||
function Group._prototype:print(rtn,colour)
|
||||
if not self_test(self,'group','print') then return end
|
||||
if colour and not type_error(colour,'table','Invalid argument #2 to group:print, colour is not a table.') then return end
|
||||
local players = self:get_players()
|
||||
local ctn = 0
|
||||
for _,player in pairs(players) do if player.connected then player_return(rtn,colour,player) ctn=ctn+1 end end
|
||||
return ctn
|
||||
end
|
||||
|
||||
-- Event Handlers Define
|
||||
|
||||
-- creates all permission groups and links them
|
||||
Event.add('on_init',function()
|
||||
for name,group in pairs(Group.groups) do
|
||||
local _group = game.permissions.create_group(name)
|
||||
verbose('Created Permission Group: '..name)
|
||||
local count = 0
|
||||
for _,to_remove in pairs(group.disallow) do
|
||||
count=count+1
|
||||
_group.set_allows_action(defines.input_action[to_remove],false)
|
||||
end
|
||||
verbose('Disalowed '..count..' input actions.')
|
||||
end
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
-- calling will attempt to define a new group
|
||||
return setmetatable(Group,{__call=function(tbl,...) tbl.define(...) end})
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingCore.Group",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a system to manage and auto-create permission groups.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Groups",
|
||||
"ExpGaming",
|
||||
"System",
|
||||
"Management",
|
||||
"Manage",
|
||||
"Permissions"
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib": "^0.8.0",
|
||||
"ExpGamingCore.Server": "?^4.0.0",
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
},
|
||||
"collection": "ExpGamingCore@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,221 +0,0 @@
|
||||
--- Adds a uniform preset for guis in the center of the screen which allow for different tabs to be opened
|
||||
-- @module ExpGamingCore.Gui.center
|
||||
-- @alias center
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color = require('FactorioStdLib.Color')
|
||||
local Gui = require('ExpGamingCore.Gui')
|
||||
local mod_gui = require('mod-gui')
|
||||
|
||||
local center = {}
|
||||
center._prototype = {}
|
||||
|
||||
--- Adds a new obj to the center gui
|
||||
-- @usage Gui.center.add{name='foo',caption='Foo',tooltip='Testing',draw=function}
|
||||
-- @usage return_value(player) -- opens the center gui for that player
|
||||
-- @param obj contains the new object, needs name, frame is opt and is function(root_frame)
|
||||
-- @return the object made, used to add tabs, calling the returned value will open the center for the given player
|
||||
function center.add(obj)
|
||||
if not is_type(obj,'table') then return end
|
||||
if not is_type(obj.name,'string') then return end
|
||||
verbose('Created Center Gui: '..obj.name)
|
||||
setmetatable(obj,{__index=center._prototype,__call=function(self,player,...) return center.open(player,self.name,...) end})
|
||||
obj.tabs = {}
|
||||
obj._tabs = {}
|
||||
Gui.data('center',obj.name,obj)
|
||||
if Gui.toolbar then Gui.toolbar(obj.name,obj.caption,obj.tooltip,function(event) return obj:open(event.player_index) end) end
|
||||
return obj
|
||||
end
|
||||
|
||||
--- Used to get the center frame of the player, used mainly in script
|
||||
-- @usage Gui.center.get_flow(player) -- returns gui element
|
||||
-- @param player a player identifier to get the flow for
|
||||
-- @treturn table the gui element flow
|
||||
function center.get_flow(player)
|
||||
player = Game.get_player(player)
|
||||
if not player then error('Invalid player',2) end
|
||||
return player.gui.center.exp_center or player.gui.center.add{name='exp_center',type='flow'}
|
||||
end
|
||||
|
||||
--- Used to open a center frame for a player, extra params are sent to open event
|
||||
-- @usage Gui.center.open(player,'server-info') -- return true
|
||||
-- @param player a player identifier to get the flow for
|
||||
-- @tparam string center_name the name of the center frame to open
|
||||
-- @treturn boolean based on if it succeeded or not
|
||||
function center.open(player,center_name,...)
|
||||
player = Game.get_player(player)
|
||||
if not player then error('Invalid player',2) return false end
|
||||
Gui.center.clear(player)
|
||||
if not Gui.data.center[center_name] then return false end
|
||||
local self = Gui.data.center[center_name]
|
||||
-- this function is the draw function passed to the open event
|
||||
self:open(player,function(...) Gui.center._draw(self,...) end,...)
|
||||
return true
|
||||
end
|
||||
|
||||
-- used as a piece of middle ware for the open event
|
||||
function center._draw(self,frame,...)
|
||||
game.players[frame.player_index].opened=frame
|
||||
if is_type(self.draw,'function') then
|
||||
local success, err = pcall(self.draw,self,frame,...)
|
||||
if not success then error(err) end
|
||||
else error('No Callback on center frame '..self.name) end
|
||||
end
|
||||
|
||||
--- Used to open a center frame for a player
|
||||
-- @usage Gui.center.open_tab(player,'readme','rules') -- return true
|
||||
-- @param player a player identifier to get the flow for
|
||||
-- @tparam string center the name of the center frame to open
|
||||
-- @tparam string tab the name of the tab to open
|
||||
-- @treturn boolean based on if it succeeded or not
|
||||
function center.open_tab(player,center_name,tab)
|
||||
player = Game.get_player(player)
|
||||
if not player then error('Invalid player',2) end
|
||||
if not Gui.center.open(player,center_name) then return false end
|
||||
local name = center_name..'_'..tab
|
||||
if not Gui.data.inputs_button[name] then return false end
|
||||
Gui.data.inputs_button[name].events[defines.events.on_gui_click]{
|
||||
element=Gui.center.get_flow(player)[center_name].tab_bar.tab_bar_scroll.tab_bar_scroll_flow[name],
|
||||
}
|
||||
return true
|
||||
end
|
||||
|
||||
--- Used to clear the center frame of the player, used mainly in script
|
||||
-- @usage Gui.center.clear(player)
|
||||
-- @param player a player identifier to get the flow for
|
||||
function center.clear(player)
|
||||
player = Game.get_player(player)
|
||||
center.get_flow(player).clear()
|
||||
end
|
||||
|
||||
-- opens this gui for this player, draw is the draw function when event is called from center.open
|
||||
-- this is the default function it can be overridden when the gui is defined, simply call draw on the frame you create
|
||||
-- extra values passed to draw will also be passed to the draw event
|
||||
-- extra values from center.draw and passed to the open event
|
||||
function center._prototype:open(player,draw,...)
|
||||
player = Game.get_player(player)
|
||||
draw = draw or function(...) center._draw(self,...) end
|
||||
local center_flow = center.get_flow(player)
|
||||
if center_flow[self.name] then Gui.center.clear(player) return end
|
||||
local center_frame = center_flow.add{
|
||||
name=self.name,
|
||||
type='frame',
|
||||
caption=self.caption,
|
||||
direction='vertical',
|
||||
style=mod_gui.frame_style
|
||||
}
|
||||
if is_type(center_frame.caption,'string') and player.gui.is_valid_sprite_path(center_frame.caption) then center_frame.caption = '' end
|
||||
draw(center_frame,...)
|
||||
end
|
||||
|
||||
-- this is the default draw function if one is not provided, can be overridden
|
||||
-- not recommended for direct use see Gui.center.open
|
||||
function center._prototype:draw(frame)
|
||||
Gui.bar(frame,510)
|
||||
local tab_bar = frame.add{
|
||||
type='frame',
|
||||
name='tab_bar',
|
||||
style='image_frame',
|
||||
direction='vertical'
|
||||
}
|
||||
tab_bar.style.width = 510
|
||||
tab_bar.style.height = 65
|
||||
local tab_bar_scroll = tab_bar.add{
|
||||
type='scroll-pane',
|
||||
name='tab_bar_scroll',
|
||||
horizontal_scroll_policy='auto-and-reserve-space',
|
||||
vertical_scroll_policy='never'
|
||||
}
|
||||
tab_bar_scroll.style.vertically_squashable = false
|
||||
tab_bar_scroll.style.vertically_stretchable = true
|
||||
tab_bar_scroll.style.width = 500
|
||||
local tab_bar_scroll_flow = tab_bar_scroll.add{
|
||||
type='flow',
|
||||
name='tab_bar_scroll_flow',
|
||||
direction='horizontal'
|
||||
}
|
||||
Gui.bar(frame,510)
|
||||
local tab = frame.add{
|
||||
type ='frame',
|
||||
name='tab',
|
||||
direction='vertical',
|
||||
style='image_frame'
|
||||
}
|
||||
tab.style.width = 510
|
||||
tab.style.height = 305
|
||||
local tab_scroll = tab.add{
|
||||
type ='scroll-pane',
|
||||
name='tab_scroll',
|
||||
horizontal_scroll_policy='never',
|
||||
vertical_scroll_policy='auto'
|
||||
}
|
||||
tab_scroll.style.vertically_squashable = false
|
||||
tab_scroll.style.vertically_stretchable = true
|
||||
tab_scroll.style.width = 500
|
||||
local tab_scroll_flow = tab_scroll.add{
|
||||
type='flow',
|
||||
name='tab_scroll_flow',
|
||||
direction='vertical'
|
||||
}
|
||||
tab_scroll_flow.style.width = 480
|
||||
Gui.bar(frame,510)
|
||||
local first_tab = nil
|
||||
for name,button in pairs(self.tabs) do
|
||||
first_tab = first_tab or name
|
||||
button(tab_bar_scroll_flow).style.font_color = defines.color.white
|
||||
end
|
||||
self._tabs[self.name..'_'..first_tab](tab_scroll_flow)
|
||||
tab_bar_scroll_flow.children[1].style.font_color = defines.color.orange
|
||||
frame.parent.add{type='frame',name='temp'}.destroy()--recenter the GUI
|
||||
end
|
||||
|
||||
--- If default draw is used then you can add tabs to the gui with this function
|
||||
-- @usage _center:add_tab('foo','Foo','Just a tab',function)
|
||||
-- @tparam string name this is the name of the tab
|
||||
-- @tparam string caption this is the words that appear on the tab button
|
||||
-- @tparam[opt] string tooltip the tooltip that is on the button
|
||||
-- @tparam function callback this is called when button is pressed with function(root_frame)
|
||||
-- @return self to allow chaining of _center:add_tab
|
||||
function center._prototype:add_tab(name,caption,tooltip,callback)
|
||||
verbose('Created Tab: '..self.name..'/'..name)
|
||||
self._tabs[self.name..'_'..name] = callback
|
||||
self.tabs[name] = Gui.inputs.add{
|
||||
type='button',
|
||||
name=self.name..'_'..name,
|
||||
caption=caption,
|
||||
tooltip=tooltip
|
||||
}:on_event('click',function(event)
|
||||
local tab = event.element.parent.parent.parent.parent.tab.tab_scroll.tab_scroll_flow
|
||||
tab.clear()
|
||||
local frame_name = tab.parent.parent.parent.name
|
||||
local _center = Gui.data.center[frame_name]
|
||||
local _tab = _center._tabs[event.element.name]
|
||||
if is_type(_tab,'function') then
|
||||
for _,button in pairs(event.element.parent.children) do
|
||||
if button.name == event.element.name then
|
||||
button.style.font_color = defines.color.orange
|
||||
else
|
||||
button.style.font_color = defines.color.white
|
||||
end
|
||||
end
|
||||
local success, err = pcall(_tab,tab)
|
||||
if not success then error(err) end
|
||||
end
|
||||
end)
|
||||
return self
|
||||
end
|
||||
|
||||
-- used so that when gui close key is pressed this will close the gui
|
||||
Event.add(defines.events.on_gui_closed,function(event)
|
||||
if event.element and event.element.valid then event.element.destroy() end
|
||||
end)
|
||||
|
||||
Event.add(defines.events.on_player_respawned,center.clear)
|
||||
|
||||
function center.on_init()
|
||||
if loaded_modules['ExpGamingCore.Role'] then Event.add(defines.events.on_role_change,center.clear) end
|
||||
end
|
||||
-- calling will attempt to add a new gui
|
||||
return setmetatable(center,{__call=function(self,...) return self.add(...) end})
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "ExpGamingCore.Gui.center",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a pre-made center gui format.",
|
||||
"author": "Cooldude2606",
|
||||
"contact": "Discord: Cooldude2606#5241",
|
||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Gui",
|
||||
"Center"
|
||||
],
|
||||
"collection": "ExpGamingCore.Gui@4.0.0",
|
||||
"dependencies": {
|
||||
"mod-gui": "*",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"FactorioStdLib.Color": "^0.8.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0",
|
||||
"ExpGamingCore.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Gui.inputs": "^4.0.0",
|
||||
"ExpGamingCore.Gui.toolbar": "?^4.0.0"
|
||||
},
|
||||
"submodules": {}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
--- Adds a objective version to custom guis.
|
||||
-- @module ExpGamingCore.Gui
|
||||
-- @alias Gui
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color = require('FactorioStdLib.Color')
|
||||
local Server -- ExpGamingCore.Server@?^4.0.0
|
||||
|
||||
local Gui = {}
|
||||
local global = {}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
--- Used to set and get data about different guis
|
||||
-- @usage Gui.data[location] -- returns the gui data for that gui location ex center
|
||||
-- @usage Gui.data(location,gui_name,gui_data) -- adds gui data for a gui at a location
|
||||
-- @tparam string location the location to get/set the data, center left etc...
|
||||
-- @tparam[opt] string key the name of the gui to set the value of
|
||||
-- @param[opt] value the data that will be set can be any value but table advised
|
||||
-- @treturn[1] table all the gui data that is located in that location
|
||||
Gui.data = setmetatable({},{
|
||||
__call=function(tbl,location,key,value)
|
||||
if not location then return tbl end
|
||||
if not key then return rawget(tbl,location) or rawset(tbl,location,{}) and rawget(tbl,location) end
|
||||
if game then error('New guis cannot be added during runtime',2) end
|
||||
if not rawget(tbl,location) then rawset(tbl,location,{}) end
|
||||
rawset(rawget(tbl,location),key,value)
|
||||
end
|
||||
})
|
||||
|
||||
--- Add a white bar to any gui frame
|
||||
-- @usage Gui.bar(frame,100)
|
||||
-- @param frame the frame to draw the line to
|
||||
-- @param[opt=10] width the width of the bar
|
||||
-- @return the line that was made type is progress bar
|
||||
function Gui.bar(frame,width)
|
||||
local line = frame.add{
|
||||
type='progressbar',
|
||||
size=1,
|
||||
value=1
|
||||
}
|
||||
line.style.height = 3
|
||||
line.style.width = width or 10
|
||||
line.style.color = defines.color.white
|
||||
return line
|
||||
end
|
||||
|
||||
--- Adds a label that is centered
|
||||
-- @usage Gui.centered_label(frame, 'Hello, world!')
|
||||
-- @tparam LuaGuiElement frame the parent frame to add the label to
|
||||
-- @tparam string string the string that the label will have
|
||||
function Gui.centered_label(frame, string)
|
||||
local flow = frame.add {frame = 'flow'}
|
||||
local flow_style = flow.style
|
||||
flow_style.align = 'center'
|
||||
flow_style.horizontally_stretchable = true
|
||||
|
||||
local label = flow.add {type = 'label', caption = string}
|
||||
local label_style = label.style
|
||||
label_style.align = 'center'
|
||||
label_style.single_line = false
|
||||
|
||||
return label
|
||||
end
|
||||
|
||||
--- Used to set the index of a drop down to a certain item
|
||||
-- @usage Gui.set_dropdown_index(dropdown,player.name) -- will select the index with the players name as the value
|
||||
-- @param dropdown the dropdown that is to be effected
|
||||
-- @param _item this is the item to look for
|
||||
-- @return returns the dropdown if it was successful
|
||||
function Gui.set_dropdown_index(dropdown,_item)
|
||||
if not dropdown or not dropdown.valid or not dropdown.items or not _item then return end
|
||||
local _index = 1
|
||||
for index, item in pairs(dropdown.items) do
|
||||
if item == _item then _index = index break end
|
||||
end
|
||||
dropdown.selected_index = _index
|
||||
return dropdown
|
||||
end
|
||||
|
||||
--- Prams for Gui.cam_link
|
||||
-- @table ParametersForCamLink
|
||||
-- @field entity this is the entity that the camera will follow
|
||||
-- @field cam a camera that you already have in the gui
|
||||
-- @field frame the frame to add the camera to, no effect if cam param is given
|
||||
-- @field zoom the zoom to give the new camera
|
||||
-- @field width the width to give the new camera
|
||||
-- @field height the height to give the new camera
|
||||
-- @field surface this will over ride the surface that the camera follows on, allowing for a 'ghost surface' while keeping same position
|
||||
-- @field respawn_open if set to true then the camera will auto re link to the player after a respawn
|
||||
|
||||
--- Adds a camera that updates every tick (or less depending on how many are opening) it will move to follow an entity
|
||||
-- @usage Gui.cam_link{entity=game.player.character,frame=frame,width=50,hight=50,zoom=1}
|
||||
-- @usage Gui.cam_link{entity=game.player.character,cam=frame.camera,surface=game.surfaces['testing']}
|
||||
-- @tparam table data contains all other params given below
|
||||
-- @return the camera that the function used be it made or given as a param
|
||||
function Gui.cam_link(data)
|
||||
if not data.entity or not data.entity.valid then return end
|
||||
if is_type(data.cam,'table') and data.cam.__self and data.cam.valid then
|
||||
data.cam = data.cam
|
||||
elseif data.frame then
|
||||
data.cam={}
|
||||
data.cam.type='camera'
|
||||
data.cam.name='camera'
|
||||
data.cam.position= data.entity.position
|
||||
data.cam.surface_index= data.surface and data.surface.index or data.entity.surface.index
|
||||
data.cam.zoom = data.zoom
|
||||
data.cam = data.frame.add(data.cam)
|
||||
data.cam.style.width = data.width or 100
|
||||
data.cam.style.height = data.height or 100
|
||||
else return end
|
||||
if not Server or not Server.get_thread('camera-follow') then
|
||||
if not global.cams then
|
||||
global.cams = {}
|
||||
global.cam_index = 1
|
||||
end
|
||||
if data.cam then
|
||||
local surface = data.surface and data.surface.index or nil
|
||||
table.insert(global.cams,{cam=data.cam,entity=data.entity,surface=surface})
|
||||
end
|
||||
if not global.players then
|
||||
global.players = {}
|
||||
end
|
||||
if data.respawn_open then
|
||||
if data.entity.player then
|
||||
if not global.players[data.entity.player.index] then global.players[data.entity.player.index] = {} end
|
||||
table.insert(global.players[data.entity.player.index],data.cam)
|
||||
end
|
||||
end
|
||||
else
|
||||
local thread = Server.get_thread('camera-follow')
|
||||
local surface = data.surface and data.surface.index or nil
|
||||
table.insert(thread.data.cams,{cam=data.cam,entity=data.entity,surface=surface})
|
||||
if data.respawn_open then
|
||||
if data.entity.player then
|
||||
if not thread.data.players[data.entity.player.index] then thread.data.players[data.entity.player.index] = {} end
|
||||
table.insert(thread.data.players[data.entity.player.index],data.cam)
|
||||
end
|
||||
end
|
||||
end
|
||||
return data.cam
|
||||
end
|
||||
|
||||
Event.add('on_tick', function(event)
|
||||
if loaded_modules['ExpGamingCore.Server'] then return end
|
||||
if global.cams and is_type(global.cams,'table') and #global.cams > 0 then
|
||||
local update = 4
|
||||
if global.cam_index >= #global.cams then global.cam_index = 1 end
|
||||
if update > #global.cams then update = #global.cams end
|
||||
for cam_offset = 0,update do
|
||||
local _cam = global.cams[global.cam_index+cam_offset]
|
||||
if not _cam then break end
|
||||
if not _cam.cam.valid then table.remove(global.cams,global.cam_index)
|
||||
elseif not _cam.entity.valid then table.remove(global.cams,global.cam_index)
|
||||
else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end global.cam_index = global.cam_index+1
|
||||
end
|
||||
end
|
||||
global.cam_index = global.cam_index+update
|
||||
end
|
||||
end)
|
||||
|
||||
Event.add('on_player_respawned',function(event)
|
||||
if loaded_modules['ExpGamingCore.Server'] then return end
|
||||
if global.players and is_type(global.players,'table') and #global.players > 0 and global.players[event.player_index] then
|
||||
local remove = {}
|
||||
local player = Game.get_player(event)
|
||||
for index,cam in pairs(global.players[event.player_index]) do
|
||||
if cam.valid then table.insert(global.cams,{cam=cam,entity=player.character,surface=player.surface})
|
||||
else table.insert(remove,index) end
|
||||
end
|
||||
for n,index in pairs(remove) do
|
||||
table.remove(global.players[event.player_index],index-n+1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function Gui:on_init()
|
||||
if loaded_modules['ExpGamingCore.Server'] then
|
||||
Server = require('ExpGamingCore.Server')
|
||||
verbose('ExpGamingCore.Server is installed; Loading server src')
|
||||
script.on_init(require(module_path..'/src/server',{Gui=self}))
|
||||
end
|
||||
end
|
||||
|
||||
function Gui.on_post()
|
||||
Gui.test = require(module_path..'/src/test',{Gui=Gui})
|
||||
end
|
||||
|
||||
|
||||
return Gui
|
||||
@@ -1,375 +0,0 @@
|
||||
--- Adds a clean way of making new inputs for a gui allowing for sliders and text inputs to be hanndleded with custom events
|
||||
-- @module ExpGamingCore.Gui.Inputs
|
||||
-- @alias inputs
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
--- This is a submodule of ExpGamingCore.Gui but for ldoc reasons it is under its own module
|
||||
-- @function _comment
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color = require('FactorioStdLib.Color')
|
||||
local mod_gui = require('mod-gui')
|
||||
local Gui = require('ExpGamingCore.Gui')
|
||||
|
||||
local inputs = {}
|
||||
inputs._prototype = {}
|
||||
-- these are just so you can have short cuts to this
|
||||
inputs.events = {
|
||||
--error={}, -- this is added after event calls are added as it is not a script event
|
||||
state=defines.events.on_gui_checked_state_changed,
|
||||
click=defines.events.on_gui_click,
|
||||
elem=defines.events.on_gui_elem_changed,
|
||||
selection=defines.events.on_gui_selection_state_changed,
|
||||
text=defines.events.on_gui_text_changed,
|
||||
slider=defines.events.on_gui_value_changed
|
||||
}
|
||||
|
||||
--- Sets the input to trigger on an certain event
|
||||
-- @usage button:on_event(defines.events.on_gui_click,player_return)
|
||||
-- @param event the event to raise callback on | can be number of the event | can be a key of inputs.events
|
||||
-- @tparam function callback the function you want to run on the event
|
||||
-- @treturn table returns self so you can chain together
|
||||
function inputs._prototype:on_event(event,callback)
|
||||
if not is_type(callback,'function') then return self end
|
||||
if inputs.events[event] then event = inputs.events[event] end
|
||||
if event == inputs.events.error then self._error = callback return self end
|
||||
self.events[event] = callback
|
||||
return self
|
||||
end
|
||||
|
||||
--- Draw the input into the root element
|
||||
-- @usage button:draw(frame)
|
||||
-- @param root the element you want to add the input to
|
||||
-- @return returns the element that was added
|
||||
function inputs._prototype:draw(root)
|
||||
local player = Game.get_player(root.player_index)
|
||||
if is_type(self.draw_data.caption,'string') and player.gui.is_valid_sprite_path(self.draw_data.caption) then
|
||||
local data = table.deepcopy(self.draw_data)
|
||||
data.type = 'sprite-button'
|
||||
data.sprite = data.caption
|
||||
data.caption = nil
|
||||
return root.add(data)
|
||||
elseif is_type(self.draw_data.sprite,'string') and player.gui.is_valid_sprite_path(self.draw_data.sprite) then
|
||||
local data = table.deepcopy(self.draw_data)
|
||||
data.type = 'sprite-button'
|
||||
return root.add(data)
|
||||
elseif is_type(self.data._state,'function') then
|
||||
local data = table.deepcopy(self.draw_data)
|
||||
local success, err = pcall(self.data._state,player,root)
|
||||
if success then data.state = err else error(err) end
|
||||
return root.add(data)
|
||||
elseif is_type(self.data._start,'function') then
|
||||
local data = table.deepcopy(self.draw_data)
|
||||
local success, err = pcall(self.data._start,player,root)
|
||||
if success then data.value = err else error(err) end
|
||||
return root.add(data)
|
||||
elseif is_type(self.data._index,'function') then
|
||||
local data = table.deepcopy(self.draw_data)
|
||||
local success, err = pcall(self.data._index,player,root)
|
||||
if success then data.selected_index = err else error(err) end
|
||||
if is_type(self.data._items,'function') then
|
||||
local success, err = pcall(self.data._items,player,root)
|
||||
if success then data.items = err else error(err) end
|
||||
end
|
||||
return root.add(data)
|
||||
elseif is_type(self.data._items,'function') then
|
||||
local data = table.deepcopy(self.draw_data)
|
||||
local success, err = pcall(self.data._items,player,root)
|
||||
if success then data.items = err else error(err) end
|
||||
if is_type(self.data._index,'function') then
|
||||
local _success, _err = pcall(self.data._index,player,root)
|
||||
if _success then data.selected_index = _err else error(_err) end
|
||||
end
|
||||
return root.add(data)
|
||||
else
|
||||
return root.add(self.draw_data)
|
||||
end
|
||||
end
|
||||
|
||||
--- Add a new input, this is the same as doing frame.add{} but returns a different object
|
||||
-- @usage Gui.inputs.add{type='button',name='test',caption='Test'}
|
||||
-- @usage return_value(frame) -- draws the button onto that frame
|
||||
-- @tparam table obj the new element to add if caption is a sprite path then sprite is used
|
||||
-- @treturn table the custom input object, calling the returned value will draw the button
|
||||
function inputs.add(obj)
|
||||
if not is_type(obj,'table') then return end
|
||||
if not is_type(obj.type,'string') then return end
|
||||
local type = obj.type
|
||||
if type ~= 'button'
|
||||
and type ~= 'sprite-button'
|
||||
and type ~= 'choose-elem-button'
|
||||
and type ~= 'checkbox'
|
||||
and type ~= 'radiobutton'
|
||||
and type ~= 'textfield'
|
||||
and type ~= 'text-box'
|
||||
and type ~= 'slider'
|
||||
and type ~= 'drop-down'
|
||||
then return end
|
||||
verbose('Created Input: '..obj.name..' ('..obj.type..')')
|
||||
if obj.type == 'button' or obj.type == 'sprite-button' then obj.style = mod_gui.button_style end
|
||||
obj.draw_data = table.deepcopy(obj)
|
||||
obj.data = {}
|
||||
obj.events = {}
|
||||
setmetatable(obj,{__index=inputs._prototype,__call=function(self,...) return self:draw(...) end})
|
||||
Gui.data('inputs_'..type,obj.name,obj)
|
||||
return obj
|
||||
end
|
||||
|
||||
-- this just runs the events given to inputs
|
||||
function inputs._event_handler(event)
|
||||
if not event.element then return end
|
||||
local elements = Gui.data['inputs_'..event.element.type] or {}
|
||||
local element = elements[event.element.name]
|
||||
if not element and event.element.type == 'sprite-button' then
|
||||
elements = Gui.data.inputs_button or {}
|
||||
element = elements[event.element.name]
|
||||
end
|
||||
if element then
|
||||
verbose('There was a gui event ('..Event.names[event.name]..') with element: '..event.element.name)
|
||||
if not is_type(element.events[event.name],'function') then return end
|
||||
local success, err = Manager.sandbox(element.events[event.name],{},event)
|
||||
if not success then
|
||||
if is_type(element._error,'function') then pcall(element._error)
|
||||
else error(err) end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(inputs.events,inputs._event_handler)
|
||||
inputs.events.error = {}
|
||||
|
||||
-- the following functions are just to make inputs easier but if what you want is not include use inputs.add(obj)
|
||||
--- Used to define a button, can have many function
|
||||
-- @usage Gui.inputs.add_button('test','Test','Just for testing',{{condition,callback},...})
|
||||
-- @tparam string name the name of this button
|
||||
-- @tparam string the display for this button, either text or sprite path
|
||||
-- @tparam string tooltip the tooltip to show on the button
|
||||
-- @param callbacks can either be a single function or a list of function pairs see examples at bottom
|
||||
-- @treturn table the button object that was made, to allow a custom error event if wanted
|
||||
function inputs.add_button(name,display,tooltip,callbacks)
|
||||
local rtn_button = inputs.add{
|
||||
type='button',
|
||||
name=name,
|
||||
caption=display,
|
||||
tooltip=tooltip
|
||||
}
|
||||
rtn_button.data._callbacks = callbacks
|
||||
rtn_button:on_event('click',function(event)
|
||||
local elements = Gui.data['inputs_'..event.element.type] or {}
|
||||
local button = elements[event.element.name]
|
||||
if not button and event.element.type == 'sprite-button' then
|
||||
elements = Gui.data.inputs_button or {}
|
||||
button = elements[event.element.name]
|
||||
end
|
||||
local player = Game.get_player(event)
|
||||
local mouse = event.button
|
||||
local keys = {alt=event.alt,ctrl=event.control,shift=event.shift}
|
||||
local element = event.element
|
||||
local btn_callbacks = button.data._callbacks
|
||||
if is_type(btn_callbacks,'function') then btn_callbacks = {{function() return true end,btn_callbacks}} end
|
||||
for _,data in pairs(btn_callbacks) do
|
||||
if is_type(data[1],'function') and is_type(data[2],'function') then
|
||||
local success, err = pcall(data[1],player,mouse,keys,event)
|
||||
if success and err == true then
|
||||
local _success, _err = pcall(data[2],player,element,event)
|
||||
if not _success then error(_err) end
|
||||
elseif not success then error(err) end
|
||||
else error('Invalid Callback Condition Format') end
|
||||
end
|
||||
end)
|
||||
return rtn_button
|
||||
end
|
||||
|
||||
--- Used to define a choose-elem-button callback only on elem_changed
|
||||
-- @usage Gui.inputs.add_elem_button('test','Test','Just for testing',function)
|
||||
-- @tparam string name the name of this button
|
||||
-- @tparam string elem_type the display for this button, either text or sprite path
|
||||
-- @tparam string tooltip the tooltip to show on the button
|
||||
-- @tparam function callback the callback to call on change function(player,element,elem)
|
||||
-- @treturn table the button object that was made, to allow a custom error event if wanted
|
||||
function inputs.add_elem_button(name,elem_type,tooltip,callback)
|
||||
local button = inputs.add{
|
||||
type='choose-elem-button',
|
||||
name=name,
|
||||
elem_type=elem_type,
|
||||
tooltip=tooltip
|
||||
}
|
||||
button.data._callback = callback
|
||||
button:on_event('elem',function(event)
|
||||
local button = Gui.data['inputs_'..event.element.type][event.element.name]
|
||||
local player = Game.get_player(event)
|
||||
local element = event.element or {elem_type=nil,elem_value=nil}
|
||||
local elem = {type=element.elem_type,value=element.elem_value}
|
||||
if is_type(button.data._callback,'function') then
|
||||
local success, err = pcall(button.data._callback,player,element,elem)
|
||||
if not success then error(err) end
|
||||
else error('Invalid Callback') end
|
||||
end)
|
||||
return button
|
||||
end
|
||||
|
||||
--- Used to define a checkbox callback only on state_changed
|
||||
-- @usage Gui.inputs.add_checkbox('test',false,'Just for testing',function,function,funvtion)
|
||||
-- @tparam string name the name of this button
|
||||
-- @tparam boolean radio if this is a radio button
|
||||
-- @tparam string display the display for this button, either text or sprite path
|
||||
-- @tparam function default the callback which choses the default check state
|
||||
-- @tparam function callback_true the callback to call when changed to true
|
||||
-- @tparam function callback_false the callback to call when changed to false
|
||||
-- @treturn table the button object that was made, to allow a custom error event if wanted
|
||||
function inputs.add_checkbox(name,radio,display,default,callback_true,callback_false)
|
||||
local type = 'checkbox'; if radio then type='radiobutton' end
|
||||
local state = false; if is_type(default,'boolean') then state = default end
|
||||
local rtn_checkbox = inputs.add{
|
||||
type=type,
|
||||
name=name,
|
||||
caption=display,
|
||||
state=state
|
||||
}
|
||||
if is_type(default,'function') then rtn_checkbox.data._state = default end
|
||||
rtn_checkbox.data._true = callback_true
|
||||
rtn_checkbox.data._false = callback_false
|
||||
rtn_checkbox:on_event('state',function(event)
|
||||
local checkbox = Gui.data['inputs_'..event.element.type][event.element.name]
|
||||
local player = Game.get_player(event)
|
||||
if event.element.state then
|
||||
if is_type(checkbox.data._true,'function') then
|
||||
local success, err = pcall(checkbox.data._true,player,event.element)
|
||||
if not success then error(err) end
|
||||
else error('Invalid Callback') end
|
||||
else
|
||||
if is_type(checkbox.data._false,'function') then
|
||||
local success, err = pcall(checkbox.data._false,player,event.element)
|
||||
if not success then error(err) end
|
||||
else error('Invalid Callback') end
|
||||
end
|
||||
end)
|
||||
return rtn_checkbox
|
||||
end
|
||||
|
||||
--- Used to reset the state of radio buttons, recommended to be called on_state_change to reset any radio buttons it is meant to work with.
|
||||
-- @usage Gui.inputs.reset_radio{radio1,radio2,...}
|
||||
-- @param elements can be a list of elements or a single element
|
||||
function inputs.reset_radio(elements)
|
||||
if #elements > 0 then
|
||||
for _,element in pairs(elements) do
|
||||
if element.valid then
|
||||
local _elements = Gui.data['inputs_'..element.type] or {}
|
||||
local _element = _elements[element.name]
|
||||
local player = Game.get_player(element.player_index)
|
||||
local state = false
|
||||
local success, err = pcall(_element.data._state,player,element.parent)
|
||||
if success then state = err else error(err) end
|
||||
element.state = state
|
||||
end
|
||||
end
|
||||
else
|
||||
if elements.valid then
|
||||
local _elements = Gui.data['inputs_'..elements.type] or {}
|
||||
local _element = _elements[elements.name]
|
||||
local player = Game.get_player(elements.player_index)
|
||||
local state = false
|
||||
local success, err = pcall(_element.data._state,player,elements.parent)
|
||||
if success then state = err else error(err) end
|
||||
elements.state = state
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Used to define a text callback only on text_changed
|
||||
-- @usage Gui.inputs.add_text('test',false,'Just for testing',function)
|
||||
-- @tparam string name the name of this button
|
||||
-- @tparam boolean box is it a text box rather than a text field
|
||||
-- @tparam string text the starting text
|
||||
-- @tparam function callback the callback to call on change function(player,text,element)
|
||||
-- @treturn table the text object that was made, to allow a custom error event if wanted
|
||||
function inputs.add_text(name,box,text,callback)
|
||||
local type = 'textfield'; if box then type='text-box' end
|
||||
local rtn_textbox = inputs.add{
|
||||
type=type,
|
||||
name=name,
|
||||
text=text
|
||||
}
|
||||
rtn_textbox.data._callback = callback
|
||||
rtn_textbox:on_event('text',function(event)
|
||||
local textbox = Gui.data['inputs_'..event.element.type][event.element.name]
|
||||
local player = Game.get_player(event)
|
||||
local element = event.element
|
||||
local event_callback = textbox.data._callback
|
||||
if is_type(event_callback,'function') then
|
||||
local success, err = pcall(event_callback,player,element.text,element)
|
||||
if not success then error(err) end
|
||||
else error('Invalid Callback Condition Format') end
|
||||
end)
|
||||
return rtn_textbox
|
||||
end
|
||||
|
||||
--- Used to define a slider callback only on value_changed
|
||||
-- @usage Gui.inputs.add_slider('test','horizontal',1,10,5,function)
|
||||
-- @tparam string name the name of this button
|
||||
-- @tparam string orientation direction of the slider
|
||||
-- @tparam number min the lowest number
|
||||
-- @tparam number max the highest number
|
||||
-- @tparam function start_callback either a number or a function to return a number
|
||||
-- @tparam function callback the function to be called on value_changed function(player,value,percent,element)
|
||||
-- @treturn table the slider object that was made, to allow a custom error event if wanted
|
||||
function inputs.add_slider(name,orientation,min,max,start_callback,callback)
|
||||
local slider = inputs.add{
|
||||
type='slider',
|
||||
name=name,
|
||||
orientation=orientation,
|
||||
minimum_value=min,
|
||||
maximum_value=max,
|
||||
value=start_callback
|
||||
}
|
||||
slider.data._start = start_callback
|
||||
slider.data._callback = callback
|
||||
slider:on_event('slider',function(event)
|
||||
local slider = Gui.data['inputs_'..event.element.type][event.element.name]
|
||||
local player = Game.get_player(event)
|
||||
local value = event.element.slider_value
|
||||
local data = slider.data
|
||||
local percent = value/event.element.get_slider_maximum()
|
||||
if is_type(data._callback,'function') then
|
||||
local success, err = pcall(data._callback,player,value,percent,event.element)
|
||||
if not success then error(err) end
|
||||
else error('Invalid Callback Condition Format') end
|
||||
end)
|
||||
return slider
|
||||
end
|
||||
|
||||
--- Used to define a drop down callback only on value_changed
|
||||
-- @usage Gui.inputs.add_drop_down('test',{1,2,3},1,function)
|
||||
-- @tparam string name name of the drop down
|
||||
-- @param items either a list or a function which returns a list
|
||||
-- @param index either a number or a function which returns a number
|
||||
-- @tparam function callback the callback which is called when a new index is selected function(player,selected,items,element)
|
||||
-- @treturn table the drop-down object that was made, to allow a custom error event if wanted
|
||||
function inputs.add_drop_down(name,items,index,callback)
|
||||
local rtn_dropdown = inputs.add{
|
||||
type='drop-down',
|
||||
name=name,
|
||||
items=items,
|
||||
selected_index=index
|
||||
}
|
||||
rtn_dropdown.data._items = items
|
||||
rtn_dropdown.data._index = index
|
||||
rtn_dropdown.data._callback = callback
|
||||
rtn_dropdown:on_event('selection',function(event)
|
||||
local dropdown = Gui.data['inputs_'..event.element.type][event.element.name]
|
||||
local player = Game.get_player(event)
|
||||
local element = event.element
|
||||
local drop_items = element.items
|
||||
local selected = drop_items[element.selected_index]
|
||||
local drop_callback = dropdown.data._callback
|
||||
if is_type(drop_callback,'function') then
|
||||
local success, err = pcall(drop_callback,player,selected,drop_items,element)
|
||||
if not success then error(err) end
|
||||
else error('Invalid Callback Condition Format') end
|
||||
end)
|
||||
return rtn_dropdown
|
||||
end
|
||||
|
||||
-- calling will attempt to add a new input
|
||||
return setmetatable(inputs,{__call=function(self,...) return self.add(...) end})
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user