mirror of
https://github.com/Beanzilla/OreTracker.git
synced 2024-11-22 07:13:53 +01:00
V1.3: Crash Repairer
The ABM appears to be perfect only if the server crashed, else swapnode seems to be perfect for our code. The ABM appears to be fired at a hard coded rate so I have set the intervals to 0 to fire instantly. (Which means nodes will be cleaned up quickly when a crash occured)
This commit is contained in:
parent
09d3792df0
commit
31f430bf22
128
xray/abm.lua
Normal file
128
xray/abm.lua
Normal file
@ -0,0 +1,128 @@
|
||||
-- https://rubenwardy.com/minetest_modding_book/en/map/timers.html#active-block-modifiers
|
||||
-- An ABM seems slow, so this is a great feature for cleaning up those crashs
|
||||
|
||||
-- MTG
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mtg_stone"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "default:stone"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mtg_dstone"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "default:desert_stone"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mtg_sstone"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "default:sandstone"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mtg_dsstone"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "default:desert_sandstone"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mtg_ssstone"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "default:silver_sandstone"})
|
||||
end
|
||||
})
|
||||
|
||||
-- MCL (2 and 5)
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mcl_stone"},
|
||||
interval = xray.scan_frequency / 2, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "mcl_core:stone"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mcl_granite"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "mcl_core:granite"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mcl_andesite"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "mcl_core:andesite"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mcl_diorite"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "mcl_core:diorite"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mcl_sstone"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "mcl_core:sandstone"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mcl_rsstone"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "mcl_core:redsandstone"})
|
||||
end
|
||||
})
|
||||
|
||||
-- MCL (5 only)
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mcl_bstone"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "mcl_blackstone:blackstone"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mcl_basalt"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "mcl_blackstone:basalt"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mcl_netherrack"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "mcl_nether:netherrack"})
|
||||
end
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"xray:mcl_deepslate"},
|
||||
interval = 0, -- Run every X seconds
|
||||
action = function(pos, node, active_object_count,
|
||||
active_object_count_wider)
|
||||
minetest.set_node(pos, {name = "mcl_deepslate:deepslate"})
|
||||
end
|
||||
})
|
@ -55,6 +55,7 @@ xray.add_pos = function(pname, pos)
|
||||
end
|
||||
|
||||
-- Clears all invisible nodes back to their originals (per player)
|
||||
-- Not really needed since the nodes themselves will reset automagically
|
||||
xray.clear_pos = function(pname)
|
||||
--local player = minetest.get_player_by_name(pname)
|
||||
local wps = xray.store[pname] or {}
|
||||
@ -102,6 +103,7 @@ xray.clear_pos = function(pname)
|
||||
end
|
||||
|
||||
-- Attempt to repair the damage to this node (In the process of development I found my system made a ball of unrepairable goo, invisible blocks)
|
||||
-- Not really needed since the nodes themselves will reset automagically
|
||||
xray.fix_pos = function (pos)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if node == nil then
|
||||
|
@ -20,7 +20,7 @@ xray.scan_frequency = 1 -- Frequency in seconds
|
||||
xray.light_level = 4 -- From 0-14
|
||||
|
||||
-- Only turn this on if you have strange blobs of invisible blocks (due to a server crash, etc.)
|
||||
local fix_mode = false
|
||||
--local fix_mode = false
|
||||
|
||||
-- This attempts to detect the gamemode
|
||||
if not minetest.registered_nodes["default:stone"] then
|
||||
@ -45,6 +45,7 @@ xray.nodes = {}
|
||||
|
||||
-- Make our counterparts
|
||||
dofile(xray.modpath .. "/register.lua")
|
||||
dofile(xray.modpath .. "/abm.lua") -- The ABM passively will fix any nodes (and add a strange effect)
|
||||
|
||||
-- Make our api
|
||||
dofile(xray.modpath .. "/api.lua")
|
||||
@ -123,10 +124,6 @@ xray.check_player = function(p)
|
||||
if xray.p_stats[pname] then
|
||||
-- Adds the counter since we are enabled
|
||||
xray.add_pos(pname, area[i])
|
||||
elseif string.find(node.name, "xray") and fix_mode then
|
||||
-- Attempt to cleanup that node if it's one of ours
|
||||
-- Warning don't leave fix_mode on all the time, can cause someone elses xray to be blocked because of ordering
|
||||
xray.fix_pos(area[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user