mirror of
https://github.com/Beanzilla/OreTracker.git
synced 2024-11-22 15:23:52 +01:00
V1.4: HUD Graphics
We now display XRAY or OREHUD when either feature is enabled. We also fix an issue where in singleplayer mode xray nodes don't get cleaned up. (Like they do on a server) < The ABM is still needed on the server in cases where the server crashed.
This commit is contained in:
parent
d0d2a0eb3a
commit
4d73085af4
@ -171,7 +171,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end
|
end
|
||||||
-- I need to clean up the player's ore waypoints added by the latter code
|
-- I need to clean up the player's ore waypoints added by the latter code
|
||||||
orehud.clear_pos(p:get_player_name())
|
orehud.clear_pos(p:get_player_name())
|
||||||
if orehud.p_stats[p:get_player_name()] or false then
|
if orehud.p_stats[p:get_player_name()] then
|
||||||
-- Only run if that player wants to run
|
-- Only run if that player wants to run
|
||||||
orehud.check_player(p)
|
orehud.check_player(p)
|
||||||
end
|
end
|
||||||
@ -181,7 +181,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player, laston)
|
minetest.register_on_joinplayer(function(player, laston)
|
||||||
orehud.p_stats[player:get_player_name()] = false
|
orehud.p_stats[player:get_player_name()] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player, timeout)
|
minetest.register_on_leaveplayer(function(player, timeout)
|
||||||
@ -195,6 +195,7 @@ minetest.register_on_leaveplayer(function(player, timeout)
|
|||||||
indx = indx + 1
|
indx = indx + 1
|
||||||
end
|
end
|
||||||
if found then
|
if found then
|
||||||
|
player:hud_remove(orehud.p_stats(orehud.p_stats[player:get_player_name()]))
|
||||||
table.remove(orehud.p_stats, indx)
|
table.remove(orehud.p_stats, indx)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@ -212,11 +213,24 @@ minetest.register_chatcommand("orehud", {
|
|||||||
},
|
},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if orehud.p_stats[name] then
|
if orehud.p_stats[name] then
|
||||||
orehud.p_stats[name] = false
|
local p = minetest.get_player_by_name(name)
|
||||||
minetest.chat_send_player(name, "Orehud: OFF")
|
if p ~= nil then
|
||||||
|
p:hud_remove(orehud.p_stats[name])
|
||||||
|
orehud.p_stats[name] = nil
|
||||||
|
end
|
||||||
else
|
else
|
||||||
orehud.p_stats[name] = true
|
local p = minetest.get_player_by_name(name)
|
||||||
minetest.chat_send_player(name, "Orehud: ON")
|
if p ~= nil then
|
||||||
|
orehud.p_stats[name] = p:hud_add({
|
||||||
|
hud_elem_type = "text",
|
||||||
|
position = {x = 0.9, y = 0.87},
|
||||||
|
offset = {x = 0.0, y = 0.0},
|
||||||
|
text = "OREHUD",
|
||||||
|
number = 0x00e100, -- 0, 225, 0 (RGB)
|
||||||
|
alignment = {x = 0.0, y = 0.0},
|
||||||
|
scale = {x = 100.0, y = 100.0}
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
28
xray/abm.lua
28
xray/abm.lua
@ -4,7 +4,7 @@
|
|||||||
-- MTG
|
-- MTG
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mtg_stone"},
|
nodenames = {"xray:mtg_stone"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "default:stone"})
|
minetest.set_node(pos, {name = "default:stone"})
|
||||||
@ -12,7 +12,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mtg_dstone"},
|
nodenames = {"xray:mtg_dstone"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "default:desert_stone"})
|
minetest.set_node(pos, {name = "default:desert_stone"})
|
||||||
@ -20,7 +20,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mtg_sstone"},
|
nodenames = {"xray:mtg_sstone"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "default:sandstone"})
|
minetest.set_node(pos, {name = "default:sandstone"})
|
||||||
@ -28,7 +28,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mtg_dsstone"},
|
nodenames = {"xray:mtg_dsstone"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "default:desert_sandstone"})
|
minetest.set_node(pos, {name = "default:desert_sandstone"})
|
||||||
@ -36,7 +36,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mtg_ssstone"},
|
nodenames = {"xray:mtg_ssstone"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "default:silver_sandstone"})
|
minetest.set_node(pos, {name = "default:silver_sandstone"})
|
||||||
@ -54,7 +54,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mcl_granite"},
|
nodenames = {"xray:mcl_granite"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "mcl_core:granite"})
|
minetest.set_node(pos, {name = "mcl_core:granite"})
|
||||||
@ -62,7 +62,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mcl_andesite"},
|
nodenames = {"xray:mcl_andesite"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "mcl_core:andesite"})
|
minetest.set_node(pos, {name = "mcl_core:andesite"})
|
||||||
@ -70,7 +70,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mcl_diorite"},
|
nodenames = {"xray:mcl_diorite"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "mcl_core:diorite"})
|
minetest.set_node(pos, {name = "mcl_core:diorite"})
|
||||||
@ -78,7 +78,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mcl_sstone"},
|
nodenames = {"xray:mcl_sstone"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "mcl_core:sandstone"})
|
minetest.set_node(pos, {name = "mcl_core:sandstone"})
|
||||||
@ -86,7 +86,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mcl_rsstone"},
|
nodenames = {"xray:mcl_rsstone"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "mcl_core:redsandstone"})
|
minetest.set_node(pos, {name = "mcl_core:redsandstone"})
|
||||||
@ -96,7 +96,7 @@ minetest.register_abm({
|
|||||||
-- MCL (5 only)
|
-- MCL (5 only)
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mcl_bstone"},
|
nodenames = {"xray:mcl_bstone"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "mcl_blackstone:blackstone"})
|
minetest.set_node(pos, {name = "mcl_blackstone:blackstone"})
|
||||||
@ -104,7 +104,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mcl_basalt"},
|
nodenames = {"xray:mcl_basalt"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "mcl_blackstone:basalt"})
|
minetest.set_node(pos, {name = "mcl_blackstone:basalt"})
|
||||||
@ -112,7 +112,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mcl_netherrack"},
|
nodenames = {"xray:mcl_netherrack"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "mcl_nether:netherrack"})
|
minetest.set_node(pos, {name = "mcl_nether:netherrack"})
|
||||||
@ -120,7 +120,7 @@ minetest.register_abm({
|
|||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xray:mcl_deepslate"},
|
nodenames = {"xray:mcl_deepslate"},
|
||||||
interval = 0, -- Run every X seconds
|
interval = 1, -- Run every X seconds
|
||||||
action = function(pos, node, active_object_count,
|
action = function(pos, node, active_object_count,
|
||||||
active_object_count_wider)
|
active_object_count_wider)
|
||||||
minetest.set_node(pos, {name = "mcl_deepslate:deepslate"})
|
minetest.set_node(pos, {name = "mcl_deepslate:deepslate"})
|
||||||
|
@ -153,7 +153,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player, laston)
|
minetest.register_on_joinplayer(function(player, laston)
|
||||||
xray.p_stats[player:get_player_name()] = false
|
xray.p_stats[player:get_player_name()] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player, timeout)
|
minetest.register_on_leaveplayer(function(player, timeout)
|
||||||
@ -168,13 +168,20 @@ minetest.register_on_leaveplayer(function(player, timeout)
|
|||||||
end
|
end
|
||||||
if found then
|
if found then
|
||||||
-- Attempt to cleanup that player's invisible nodes before they log off
|
-- Attempt to cleanup that player's invisible nodes before they log off
|
||||||
xray.p_stats[player:get_player_name()] = false
|
player:hud_remove(xray.p_stats[player:get_player_name()])
|
||||||
minetest.log("action", "Cleaning up "..player:get_player_name().." as they wish to leave.")
|
|
||||||
xray.clear_pos(player:get_player_name())
|
xray.clear_pos(player:get_player_name())
|
||||||
|
xray.p_stats[player:get_player_name()] = nil
|
||||||
table.remove(xray.p_stats, indx)
|
table.remove(xray.p_stats, indx)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Attempt to cleanup xrays in a singleplayer world
|
||||||
|
minetest.register_on_shutdown(function ()
|
||||||
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
|
xray.clear_pos(player:get_player_name())
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-- A priv for players so they can't abuse this power
|
-- A priv for players so they can't abuse this power
|
||||||
minetest.register_privilege("xray", {
|
minetest.register_privilege("xray", {
|
||||||
description = "Oretracker Xray Priv",
|
description = "Oretracker Xray Priv",
|
||||||
@ -188,11 +195,24 @@ minetest.register_chatcommand("xray", {
|
|||||||
},
|
},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if xray.p_stats[name] then
|
if xray.p_stats[name] then
|
||||||
xray.p_stats[name] = false
|
local p = minetest.get_player_by_name(name)
|
||||||
minetest.chat_send_player(name, "Xray: OFF")
|
if p ~= nil then
|
||||||
|
p:hud_remove(xray.p_stats[name])
|
||||||
|
xray.p_stats[name] = nil
|
||||||
|
end
|
||||||
else
|
else
|
||||||
xray.p_stats[name] = true
|
local p = minetest.get_player_by_name(name)
|
||||||
minetest.chat_send_player(name, "Xray: ON")
|
if p ~= nil then
|
||||||
|
xray.p_stats[name] = p:hud_add({
|
||||||
|
hud_elem_type = "text",
|
||||||
|
position = {x = 0.9, y = 0.9},
|
||||||
|
offset = {x = 0.0, y = 0.0},
|
||||||
|
text = " XRAY ",
|
||||||
|
number = 0x00e100, -- 0, 225, 0 (RGB)
|
||||||
|
alignment = {x = 0.0, y = 0.0},
|
||||||
|
scale = {x = 100.0, y = 100.0}
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user