Added Player Auto Color

This commit is contained in:
Cooldude2606
2019-04-18 23:20:19 +01:00
parent 652fb42ec9
commit 6af7bc1074
7 changed files with 63 additions and 0 deletions

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,48 @@
--- Assigns random colours to players (larger range than default) and allows predefined colours for users.
-- @module PlayerAutoColor@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Color = require('FactorioStdLib.Color')
-- Module Define
local module_verbose = false
local ThisModule = {}
-- Global Define
local global = {
BADgamerNL={r=255,g=20,b=147},
arty714={r=150,g=68,b=161},
Cooldude2606={r=57,g=192,b=207},
mark9064={r=99,g=0,b=255},
eissturm={r=25,g=25,b=112},
Sakama={r=20,g=213,b=80},
Sakama={r=20,g=213,b=80},
freek18={r=50,g=0,b=255},
aldldl={r=0,g=131,b=255},
NAD4X4={r=135,g=206,b=250},
cydes={r=82,g=249,b=155},
UUBlueFire={r=0,g=204,b=255}
}
Global.register(global,function(tbl) global = tbl end)
-- Event Handlers Define
Event.add(defines.events.on_player_created, function(event)
local player = game.players[event.player_index]
local colours = table.keys(defines.color)
player.color = defines.color.black
while player.color.r == defines.color.black.r and player.color.g == defines.color.black.g and player.color.b == defines.color.black.b
or player.color.r == defines.color.white.r and player.color.g == defines.color.white.g and player.color.b == defines.color.white.b do
player.color = defines.color[colours[math.random(#colours)]]
if global[player.name] then
local c = global[player.name]
player.color = Color.from_rgb(c.r,c.g,c.b)
end
end
player.chat_color = player.color
end)
-- Module Return
return ThisModule

View File

@@ -0,0 +1,19 @@
{
"name": "PlayerAutoColor",
"version": "4.0.0",
"description": "Assigns random colours to players (larger range than default) and allows predefined colours for users.",
"location": "FSM_ARCHIVE",
"keywords": [
"Colour",
"Color",
"Player",
"Vibrant"
],
"author": "Cooldude2606",
"contact": "Discord: Cooldude2606#5241",
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
"dependencies": {
"FactorioStdLib.Color": "^0.8.0"
},
"submodules": {}
}