Refactor of commands

This commit is contained in:
Cooldude2606
2019-03-01 20:24:23 +00:00
parent e547f76d6f
commit 62dcfe8694
288 changed files with 5364 additions and 1067 deletions

View File

@@ -0,0 +1,87 @@
--- 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
}

View File

@@ -0,0 +1,22 @@
{
"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": {}
}

View File

@@ -0,0 +1,14 @@
--- 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

View File

@@ -0,0 +1,19 @@
{
"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": {}
}

View File

@@ -0,0 +1,48 @@
--- 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)

View File

@@ -0,0 +1,9 @@
[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__

View File

@@ -0,0 +1,20 @@
{
"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": {}
}

View File

@@ -0,0 +1,18 @@
--- 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

View File

@@ -0,0 +1,21 @@
{
"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": {}
}

View File

@@ -0,0 +1,68 @@
--- 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

View File

@@ -0,0 +1,22 @@
{
"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": {}
}

View File

@@ -0,0 +1,7 @@
-- 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

View File

@@ -0,0 +1,25 @@
{
"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": {}
}

View File

@@ -0,0 +1,45 @@
--- 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

View File

@@ -0,0 +1,20 @@
{
"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": {}
}

View File

@@ -0,0 +1,35 @@
--- 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)

View File

@@ -0,0 +1,23 @@
{
"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": {}
}