From: tenplus1 Date: Mon, 28 Mar 2016 19:14:35 +0000 (+0100) Subject: Beds: Quicker saves with tidy output X-Git-Tag: 0.4.14~13 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=dc7cbdd5ab9efa83327f057a4e4376ffacab6c0e;p=oweals%2Fminetest_game.git Beds: Quicker saves with tidy output Tweaked the beds.save_spawns() function to compile list then output to file with shortened co-ordinates containing 1 decimal place --- diff --git a/mods/beds/spawns.lua b/mods/beds/spawns.lua index f3980a7a..48b8a669 100644 --- a/mods/beds/spawns.lua +++ b/mods/beds/spawns.lua @@ -41,10 +41,12 @@ function beds.save_spawns() if not beds.spawn then return end + local data = {} local output = io.open(org_file, "w") - for i, v in pairs(beds.spawn) do - output:write(v.x .. " " .. v.y .. " " .. v.z .. " " .. i .. "\n") + for k, v in pairs(beds.spawn) do + table.insert(data, string.format("%.1f %.1f %.1f %s\n", v.x, v.y, v.z, k)) end + output:write(table.concat(data)) io.close(output) end