mirror of
https://github.com/Beanzilla/OreTracker.git
synced 2024-11-26 01:03:50 +01:00
commit
d0d2a0eb3a
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
|
end
|
||||||
|
|
||||||
-- Clears all invisible nodes back to their originals (per player)
|
-- 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)
|
xray.clear_pos = function(pname)
|
||||||
--local player = minetest.get_player_by_name(pname)
|
--local player = minetest.get_player_by_name(pname)
|
||||||
local wps = xray.store[pname] or {}
|
local wps = xray.store[pname] or {}
|
||||||
@ -102,6 +103,7 @@ xray.clear_pos = function(pname)
|
|||||||
end
|
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)
|
-- 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)
|
xray.fix_pos = function (pos)
|
||||||
local node = minetest.get_node_or_nil(pos)
|
local node = minetest.get_node_or_nil(pos)
|
||||||
if node == nil then
|
if node == nil then
|
||||||
|
@ -20,7 +20,7 @@ xray.scan_frequency = 1 -- Frequency in seconds
|
|||||||
xray.light_level = 4 -- From 0-14
|
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.)
|
-- 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
|
-- This attempts to detect the gamemode
|
||||||
if not minetest.registered_nodes["default:stone"] then
|
if not minetest.registered_nodes["default:stone"] then
|
||||||
@ -45,6 +45,7 @@ xray.nodes = {}
|
|||||||
|
|
||||||
-- Make our counterparts
|
-- Make our counterparts
|
||||||
dofile(xray.modpath .. "/register.lua")
|
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
|
-- Make our api
|
||||||
dofile(xray.modpath .. "/api.lua")
|
dofile(xray.modpath .. "/api.lua")
|
||||||
@ -123,10 +124,6 @@ xray.check_player = function(p)
|
|||||||
if xray.p_stats[pname] then
|
if xray.p_stats[pname] then
|
||||||
-- Adds the counter since we are enabled
|
-- Adds the counter since we are enabled
|
||||||
xray.add_pos(pname, area[i])
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user