aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/advtrains/init.lua2
-rw-r--r--advtrains/advtrains/nodedb.lua24
2 files changed, 15 insertions, 11 deletions
diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua
index 926619c..7793a42 100644
--- a/advtrains/advtrains/init.lua
+++ b/advtrains/advtrains/init.lua
@@ -90,7 +90,7 @@ atwarn=function(t, ...)
minetest.log("warning", "[advtrains]"..text)
minetest.chat_send_all("[advtrains] -!- "..text)
end
-sid=function(id) return string.sub(id, -6) end
+sid=function(id) if id then return string.sub(id, -6) end end
if minetest.settings:get_bool("advtrains_enable_debugging") then
atprint=function(t, ...)
diff --git a/advtrains/advtrains/nodedb.lua b/advtrains/advtrains/nodedb.lua
index 4dc451a..3986633 100644
--- a/advtrains/advtrains/nodedb.lua
+++ b/advtrains/advtrains/nodedb.lua
@@ -107,14 +107,7 @@ function ndb.get_node_or_nil(pos)
return node
else
--maybe we have the node in the database...
- local cid=ndbget(pos.x, pos.y, pos.z)
- if cid then
- local nodeid = ndb_nodeids[u14b(cid)]
- if nodeid then
- --atprint("ndb.get_node_or_nil",pos,"found node",nodeid,"cid",cid,"par2",l2b(cid))
- return {name=nodeid, param2 = l2b(cid)}
- end
- end
+ return ndb.get_node_raw(pos)
end
atprint("ndb.get_node_or_nil",pos,"not found")
end
@@ -125,6 +118,17 @@ function ndb.get_node(pos)
end
return n
end
+function ndb.get_node_raw(pos)
+ local cid=ndbget(pos.x, pos.y, pos.z)
+ if cid then
+ local nodeid = ndb_nodeids[u14b(cid)]
+ if nodeid then
+ return {name=nodeid, param2 = l2b(cid)}
+ end
+ end
+ return nil
+end
+
function ndb.swap_node(pos, node)
minetest.swap_node(pos, node)
@@ -248,7 +252,7 @@ ndb.restore_all = function()
local node=minetest.get_node_or_nil(pos)
if node then
local ori_ndef=minetest.registered_nodes[node.name]
- local ndbnode=ndb.get_node(pos)
+ local ndbnode=ndb.get_node_raw(pos)
if ori_ndef and ori_ndef.groups.save_in_nodedb then --check if this node has been worldedited, and don't replace then
if (ndbnode.name~=node.name or ndbnode.param2~=node.param2) then
minetest.swap_node(pos, ndbnode)
@@ -283,7 +287,7 @@ advtrains.ndb=ndb
local ptime=0
-minetest.register_chatcommand("at_restore_ndb",
+minetest.register_chatcommand("at_sync_ndb",
{
params = "", -- Short parameter description
description = "Write node db back to map and find ghost nodes", -- Full description