diff options
author | orwell96 <mono96.mml@gmail.com> | 2017-04-05 13:57:09 +0200 |
---|---|---|
committer | orwell96 <mono96.mml@gmail.com> | 2017-04-29 14:53:00 +0200 |
commit | f42b01c74bdc7e91d3def03125a0e24e6a3bb0d4 (patch) | |
tree | 58a7230e725eb15cf49eedb80254ae0fa88433d1 /advtrains/advtrains/nodedb.lua | |
parent | 337db2a573ccaa1672e713855022e96106679803 (diff) | |
download | advtrains-f42b01c74bdc7e91d3def03125a0e24e6a3bb0d4.tar.gz advtrains-f42b01c74bdc7e91d3def03125a0e24e6a3bb0d4.tar.bz2 advtrains-f42b01c74bdc7e91d3def03125a0e24e6a3bb0d4.zip |
Add pcall wrapper to prevent server crashes when advtrains throws an error
Instead, read save files again and restore state before the crash
Rebased to latest commit
Diffstat (limited to 'advtrains/advtrains/nodedb.lua')
-rw-r--r-- | advtrains/advtrains/nodedb.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/advtrains/advtrains/nodedb.lua b/advtrains/advtrains/nodedb.lua index ddd1a67..2fb3656 100644 --- a/advtrains/advtrains/nodedb.lua +++ b/advtrains/advtrains/nodedb.lua @@ -203,6 +203,8 @@ minetest.register_abm({ nodenames = {"group:save_in_nodedb"}, run_at_every_load = true, action = function(pos, node) + return advtrains.pcall(function() + local cid=ndbget(pos.x, pos.y, pos.z) if cid then --if in database, detect changes and apply. @@ -227,14 +229,18 @@ minetest.register_abm({ atprint("nodedb: ", pos, "not in database") ndb.update(pos, node) end + end) end, interval=10, chance=1, }) minetest.register_on_dignode(function(pos, oldnode, digger) +return advtrains.pcall(function() + ndb.clear(pos) end) +end) function ndb.get_nodes() return ndb_nodes |