1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

Add seeds command

This commit is contained in:
Matthew Heguy 2019-01-22 15:03:34 -05:00
parent 41c89a0ca8
commit 2f203a435c

View File

@ -7,6 +7,7 @@ local Command = require 'utils.command'
local format = string.format
local ceil = math.ceil
local concat = table.concat
--- Kill a player with fish as the cause of death.
local function do_fish_kill(player, suicide)
@ -191,6 +192,22 @@ local function search_command(arguments)
p(format('-------- Page %d / %d --------', page, pages))
end
local function list_seeds()
local seeds = {}
local count_of_seeds = 0
for _, surface in pairs(game.surfaces) do
seeds[count_of_seeds + 1] = surface.name
seeds[count_of_seeds + 2] = ': '
seeds[count_of_seeds + 3] = tostring(surface.map_gen_settings.seed)
count_of_seeds = count_of_seeds + 4
seeds[count_of_seeds] = ', '
end
seeds[#seeds] = nil
seeds = concat(seeds)
Game.player_print(seeds)
end
-- Command registrations
Command.add(
@ -259,6 +276,15 @@ Command.add(
search_command
)
Command.add(
'seeds',
{
description = 'List the seeds of all surfaces',
allowed_by_server = true,
},
list_seeds
)
-- Commands with no functions, only calls to other modules
Command.add(