diff --git a/control.lua b/control.lua index e5cecb07..d41b1700 100644 --- a/control.lua +++ b/control.lua @@ -21,7 +21,6 @@ require 'features.donator_messages' require 'features.train_saviour' require 'features.fish_market' require 'features.free_item_logging' ---require 'features.infinite_storage_chest' require 'features.nuke_control' require 'features.player_colors' require 'features.reactor_meltdown' diff --git a/features/silly_player_names.lua b/features/silly_player_names.lua deleted file mode 100644 index 1ee1c187..00000000 --- a/features/silly_player_names.lua +++ /dev/null @@ -1,159 +0,0 @@ -require 'utils.list_utils' -local Game = require 'utils.game' -local Event = require 'utils.event' -local naming_words = require 'resources.naming_words' -local Utils = require('utils.utils') -global.actual_name = {} -global.silly_names = {} -global.silly_names.count = 0 - -local name_combinations = #naming_words.adverbs * #naming_words.adjectives * #naming_words.nouns - ---- Creates name by combining elements from the passed table --- @param1 table including adverbs, adjectives, and nouns --- @returns name as a string -local function create_name(words_table) - local adverb, adjective, noun - adverb = table.get_random(words_table.adverbs) - adjective = table.get_random(words_table.adjectives) - noun = table.get_random(words_table.nouns) - return adverb .. '_' .. adjective .. '_' .. noun -end - ---- Calls create_name until a unique name is returned --- @param1 table including adverbs, adjectives, and nouns --- @returns name as a string -local function create_unique_name(words_table) - local silly_names = global.silly_names - local name = create_name(words_table) - - while table.contains(silly_names, name) do - name = create_name(words_table) - end - return name -end - ---- Assigns a player a name, stores their old and silly names --- @param1 Takes a LuaPlayer -local function name_player(player) - -- Store a player's original name in case they want it back. - if not global.actual_name[player.index] then - global.actual_name[player.index] = player.name - end - - -- Because create_unique_name enters a while loop looking for a unique name, ensure we never get stuck. - local ceiling = math.min(name_combinations * 0.25, 10000) - if global.silly_names.count > ceiling then - global.silly_names = {} - global.silly_names.count = 0 - end - - local name = create_unique_name(naming_words) - - table.insert(global.silly_names, name) - global.silly_names.count = global.silly_names.count + 1 - local str = player.name .. ' will now be known as: ' .. name - game.print(str) - Utils.print_admins(str .. ' (ID: ' .. player.index .. ')', false) - player.name = name -end - ---- Restores a player's actual name -local function restore_name(cmd) - local player = Game.get_player_by_index(cmd.player_index) - player.name = global.actual_name[player.index] - player.print('Your true name has been restored.') -end - ---- Passes _event_ on to name_players -local function name_player_event(event) - local player = Game.get_player_by_index(event.player_index) - name_player(player) -end - ---- Passes target or player on to name_players -local function name_player_command(cmd) - local player = game.player - local param = cmd.parameter - local target - - if param then - target = game.players[param] - if player and not player.admin then - -- Yes param, yes player, no admin/server = fail, non-admins, non-server cannot use command on others - Game.player_print("Sorry you don't have permission to use the roll-name command on other players.") - return - else - -- Yes param, yes admin/server = check target - if target then - -- Yes param, yes admin/server, yes target = change name - name_player(target) - return - else - -- Yes param, yes admin/server, no target = fail, wrong player name - Game.player_print(table.concat {"Sorry, player '", param, "' was not found."}) - return - end - end - else - -- No param = check if server - if not player then - -- No param, no player = server trying to change its name - Game.player_print('The server cannot change its name') - return - end - -- No param, not server = change self name - name_player(player) - return - end -end - ---- Prints the original name of the target -local function check_name(cmd) - local current_name = cmd.parameter - if not current_name then - Game.player_print('Usage: /name-check ') - return - end - - local target = game.players[current_name] - if not target then - Game.player_print('player ' .. current_name .. ' not found') - return - end - - local actual_name = global.actual_name[target.index] - Game.player_print(target.name .. ' is actually: ' .. actual_name) -end - ---- Prints the index of the target -local function get_player_id(cmd) - local player = game.player - -- Check if the player can run the command - if player and not player.admin then - Utils.cant_run(cmd.name) - return - end - -- Check if the target is valid - local target_name = cmd['parameter'] - if not target_name then - Game.player_print('Usage: /get-player-id ') - return - end - local target_index = game.players[target_name].index - Game.player_print(target_name .. ' -- ' .. target_index) -end - -if global.scenario.config.players_assigned_names == true then - Event.add(defines.events.on_player_created, name_player_event) -end - -if global.scenario.config.players_roll_names == true then - commands.add_command('name-roll', 'Assigns you a random, silly name', name_player_command) -end - -if global.scenario.config.players_roll_names == true or global.scenario.config.players_assigned_names == true then - commands.add_command('name-restore', 'Removes your fun name and gives you back your actual name', restore_name) - commands.add_command('name-check', ' Check the original name of a player', check_name) - commands.add_command('get-player-id', 'Gets the ID of a player (Admin only)', get_player_id) -end diff --git a/features/infinite_storage_chest.lua b/map_gen/misc/infinite_storage_chest.lua similarity index 100% rename from features/infinite_storage_chest.lua rename to map_gen/misc/infinite_storage_chest.lua diff --git a/features/spawn_control.lua b/map_gen/misc/spawn_control.lua similarity index 100% rename from features/spawn_control.lua rename to map_gen/misc/spawn_control.lua diff --git a/map_gen/presets/mobius_strip.lua b/map_gen/presets/mobius_strip.lua index ac66bd21..2513f689 100644 --- a/map_gen/presets/mobius_strip.lua +++ b/map_gen/presets/mobius_strip.lua @@ -105,7 +105,7 @@ end map = b.apply_effect(map, effect) -local Spawn_Control = require 'features.spawn_control' +local Spawn_Control = require 'map_gen.misc.spawn_control' Spawn_Control.add_spawn('left', -88, -88) Spawn_Control.add_spawn('right', 88, 88) diff --git a/map_layout.lua b/map_layout.lua index e923e422..31a96e45 100644 --- a/map_layout.lua +++ b/map_layout.lua @@ -141,6 +141,7 @@ local terrain_modules = { --require 'map_gen.misc.car_body' -- gives players cars instead of characters --require 'features.silly_player_names' -- assigns players random names when they first join --require 'map_gen.misc.naughty_words' -- admonishes players for cursing +--require 'map_gen.misc.infinite_storage_chest' if #entity_modules > 0 then shape = shape or b.full_shape