From 325ffcf73de4b8f190a95a6e1c928fa695692bed Mon Sep 17 00:00:00 2001 From: grilledham Date: Fri, 29 Jun 2018 11:13:47 +0100 Subject: [PATCH] reduced number of file writes --- user_groups.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/user_groups.lua b/user_groups.lua index 8ccc7388..ef78d909 100644 --- a/user_groups.lua +++ b/user_groups.lua @@ -5,14 +5,15 @@ local Utils = require 'utils.utils' local Module = {} local function update_file() - local file = 'regulars.lua' - game.write_file(file, '{', false, 0) - local line = '' + local data = {'{\n'} for player_name, _ in pairs(global.regulars) do - line = string.format('["%s"] = true,\n', player_name) - game.write_file(file, line, true, 0) + table.insert(data, '["') + table.insert(data, player_name) + table.insert(data, '"] = true,\n') end - game.write_file(file, '}', true, 0) + table.insert(data, '}') + + game.write_file('regulars.lua', table.concat(data), false, 0) end Module.is_regular =