Skip to content
Permalink
Browse files
Use safe_file_write to save forceloaded blocks
  • Loading branch information
sfan5 committed May 30, 2021
1 parent f30dcdb commit 1bc753f655db4c7de030f2700361011e1c0278a5
Showing with 2 additions and 7 deletions.
  1. +2 −7 builtin/game/forceloading.lua
@@ -86,12 +86,6 @@ local function read_file(filename)
return core.deserialize(t) or {}
end

local function write_file(filename, table)
local f = io.open(filename, "w")
f:write(core.serialize(table))
f:close()
end

blocks_forceloaded = read_file(wpath.."/force_loaded.txt")
for _, __ in pairs(blocks_forceloaded) do
total_forceloaded = total_forceloaded + 1
@@ -106,7 +100,8 @@ end)

-- persists the currently forceloaded blocks to disk
local function persist_forceloaded_blocks()
write_file(wpath.."/force_loaded.txt", blocks_forceloaded)
local data = core.serialize(blocks_forceloaded)
core.safe_file_write(wpath.."/force_loaded.txt", data)
end

-- periodical forceload persistence

0 comments on commit 1bc753f

Please sign in to comment.