]> git.lizzy.rs Git - elidragon_v2.git/commitdiff
Dummy databases
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 13 Mar 2021 15:21:44 +0000 (16:21 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 13 Mar 2021 15:21:44 +0000 (16:21 +0100)
mods/elidragon_db/init.lua
mods/elidragon_plot/init.lua

index c4329214a74a83336fe827ae06cec37dddb3b9da..cdf2a4dce2178f5e1b4a8da4a5d49088aff4a34b 100644 (file)
@@ -6,7 +6,11 @@ local private = {}
 local worldpath = minetest.get_worldpath()
 
 function db:constructor(name, initial_data, dir, env)
-       private[self] = {env = env or _G, path = (dir or worldpath) .. "/" .. name .. ".json"}
+       local path = env and dir or worldpath .. "/" .. (dir or "")
+       if dir and not env then
+               minetest.mkdir(path)
+       end
+       private[self] = {env = env or _G, path = path .. "/" .. name .. ".json"}
        self:load(initial_data or {})
 end
 
@@ -35,10 +39,16 @@ function db:save()
 end
 
 function db:close()
-       self:save()
+       if not private[self].dummy then
+               self:save()
+       end
        private[self] = nil
 end
 
+function db:set_dummy(v)
+       private[self].dummy = v
+end
+
 minetest.register_on_shutdown(function()
        for d in pairs(private) do
                d:save()
index 7942f2ad6cd90181c9c2b77dcc879548026129aa..d03e513845729a602acaee40b2a67d5571588411 100644 (file)
@@ -1,9 +1,15 @@
-local plot = {}
+local plot = {
+       loaded = {}
+}
 
+local loaded = plot.loaded
 local old_is_protected = minetest.is_protected
 
 function minetest.is_protected(pos, name)
        return old_is_protected(pos, name)
 end
 
+function plot.get(pos)
+end
+
 elidragon.plot = plot