diff --git a/config/file_loader.lua b/config/file_loader.lua index 993582b8..caa0a1a8 100644 --- a/config/file_loader.lua +++ b/config/file_loader.lua @@ -14,6 +14,7 @@ return { 'modules.commands.cheat-mode', 'modules.commands.interface', 'modules.commands.help', + 'modules.commands.roles', -- QoL Addons 'modules.addons.chat-popups', 'modules.addons.damage-popups', diff --git a/config/pollution_grading.lua b/config/pollution_grading.lua new file mode 100644 index 00000000..b19fd3ef --- /dev/null +++ b/config/pollution_grading.lua @@ -0,0 +1,7 @@ +-- This controls how pollution is viewed on the map +return { + reference_point = {x=0,y=0}, -- where pollution is read from + max_scalar = 0.5, -- the scale between true max and max + min_scalar = 0.17, -- the scale between the lowest max and min + update_delay = 15 -- time in minutes between view updates +} \ No newline at end of file diff --git a/config/roles.lua b/config/roles.lua index 4cead3dd..81cf5b7d 100644 --- a/config/roles.lua +++ b/config/roles.lua @@ -58,6 +58,8 @@ Roles.new_role('Moderator','Mod') :set_flag('is_spectator') :set_parent('Trainee') :allow{ + 'command/assign-role', + 'command/unassign-role' } Roles.new_role('Trainee','TrMod') @@ -141,7 +143,8 @@ Roles.new_role('Guest','') 'command/me', 'command/tag', 'command/tag-clear', - 'command/chelp' + 'command/chelp', + 'command/list-roles' } --- Jail role diff --git a/config/worn_paths.lua b/config/scorched_earth.lua similarity index 100% rename from config/worn_paths.lua rename to config/scorched_earth.lua diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index ddf4213b..e1cff318 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -7,4 +7,7 @@ chelp-title=Help results for "__1__": chelp-footer=(__1__ results found; page __2__ of __3__) chelp-format=/__1__ __2__ - __3__ __4__ chelp-alias=Alias: __1__ -chelp-out-of-range=__1__ is an invalid page number. \ No newline at end of file +chelp-out-of-range=__1__ is an invalid page number. +roles-higher-role=The role you tried to assign is higher than your highest. +roles-list=All active roles are: +roles-list-element=__1__, [color=__2__]__3__ \ No newline at end of file diff --git a/modules/addons/compilatron.lua b/modules/addons/compilatron.lua index f7142b3d..f184baf5 100644 --- a/modules/addons/compilatron.lua +++ b/modules/addons/compilatron.lua @@ -20,6 +20,8 @@ Global.register( end ) +local Public = {} + --- This will re-create the speech bubble after it de-spawns called with set_timeout local callback = Token.register( @@ -38,6 +40,9 @@ local callback = --- This will move the messages onto the next message in the loop local function circle_messages() for name, ent in pairs(compilatrons) do + if not ent.valid then + Public.spawn_compilatron(game.players[1].surface,name) + end local current_message = current_messages[name] local msg_number local message @@ -58,8 +63,6 @@ end Event.on_nth_tick(config.message_cycle, circle_messages) -local Public = {} - --- This will add a compilatron to the global and start his message cycle -- @tparam entity LuaEntity the compilatron entity that moves around -- @tparam name string the name of the location that the complitron is at diff --git a/modules/addons/pollution-grading.lua b/modules/addons/pollution-grading.lua new file mode 100644 index 00000000..8166cebd --- /dev/null +++ b/modules/addons/pollution-grading.lua @@ -0,0 +1,13 @@ +local Event = require 'utils.event' +local config = require 'config.pollution_grading' + +local delay = config.update_delay * 3600 -- convert from minutes to ticks +Event.on_nth_tick(delay,function() + local surface = game.surfaces[1] + local true_max = surface.get_pollution(config.reference_point) + local max = true_max*config.max_scalar + local min = max*config.min_scalar + local settings = game.map_settings.pollution + settings.expected_max_per_chunk = max + settings.min_to_show_per_chunk = min +end) \ No newline at end of file diff --git a/modules/addons/worn-paths.lua b/modules/addons/scorched-earth.lua similarity index 99% rename from modules/addons/worn-paths.lua rename to modules/addons/scorched-earth.lua index 2d301a3d..15660669 100644 --- a/modules/addons/worn-paths.lua +++ b/modules/addons/scorched-earth.lua @@ -2,7 +2,7 @@ local Event = require 'utils.event' local Game = require 'utils.game' local Global = require 'utils.global' local print_grid_value, clear_flying_text = ext_require('expcore.common','print_grid_value','clear_flying_text') -local config = require 'config.worn_paths' +local config = require 'config.scorched_earth' -- Loops over the config and finds the wile which has the highest value for strength local max_strength = 0 diff --git a/modules/commands/roles.lua b/modules/commands/roles.lua new file mode 100644 index 00000000..64bdb74e --- /dev/null +++ b/modules/commands/roles.lua @@ -0,0 +1,45 @@ +local Commands = require 'expcore.commands' +local Roles = require 'expcore.roles' +local Colours = require 'resources.color_presets' + +Commands.new_command('assign-role','Assigns a role to a player') +:add_param('player',false,'player-role') +:add_param('role',false,'role') +:set_flag('admin-only',true) +:add_alias('rpromote','assign','role','add-role') +:register(function(player,action_player,role,raw) + local player_highest = Roles.get_player_highest(player) + if player_highest.index < role.index then + Roles.assign_player(action_player,role,player.name) + else + return Commands.error{'exp-commands.roles-higher-role'} + end +end) + +Commands.new_command('unassign-role','Unassigns a role from a player') +:add_param('player',false,'player-role') +:add_param('role',false,'role') +:set_flag('admin-only',true) +:add_alias('rdemote','unassign','remove-role') +:register(function(player,action_player,role,raw) + local player_highest = Roles.get_player_highest(player) + if player_highest.index < role.index then + Roles.unassign_player(action_player,role,player.name) + else + return Commands.error{'exp-commands.roles-higher-role'} + end +end) + +Commands.new_command('list-roles','Lists all roles in they correct order') +:add_alias('lroles','roles') +:register(function(player,raw) + local roles = Roles.config.order + local message = {'exp-commands.roles-list'} + for _,role_name in pairs(roles) do + local role = Roles.get_role_by_name(role_name) + local colour = role.custom_color or Colours.white + colour = string.format('%d,%d,%d',colour.r,colour.g,colour.b) + message = {'exp-commands.roles-list-element',message,colour,role_name} + end + return Commands.success(message) +end) \ No newline at end of file