summaryrefslogtreecommitdiff
path: root/server/map.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-02-06 12:50:21 +0000
committerubq323 <ubq323@ubq323.website>2023-02-06 12:50:21 +0000
commit7952bbc2a606ab22e04112eb2f21a573d0db116e (patch)
tree06d1e456b542ab82efe6a3343756ae3e90cf18e1 /server/map.lua
parent911dc535a9930ef5380ecf31fabbd5123461fc3c (diff)
hook up save/loading of chunks
Diffstat (limited to 'server/map.lua')
-rw-r--r--server/map.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/server/map.lua b/server/map.lua
index 335997a..0bb09c7 100644
--- a/server/map.lua
+++ b/server/map.lua
@@ -2,6 +2,7 @@ local Map = require"common.map".Map
local class = require"common.class"
local worldgen = require"worldgen"
local json = require"common.dkjson"
+local Chunk = require"common.chunk".Chunk
local MapS = class.extend(Map)
function MapS.obtain(self,cp)
@@ -17,13 +18,18 @@ function MapS.obtain(self,cp)
local f = io.open(cp:filename(),"r")
if f then
+ print("loading from file",cp)
local j = json.decode(f:read("a"))
- ch = Chunk:from_packet_data(j)
+ print(j)
+ for k in pairs(j) do print(k) end
+ ch = Chunk.from_packet_data(j)
f:close()
else
ch = worldgen.gen_chunk(cp)
end
+
+ print(ch.cp.u,ch.cp.v)
self:add_chunk(ch)
return ch
end