esp: add nodelist
This commit is contained in:
parent
f956ff8566
commit
435d82cc57
@ -9,26 +9,30 @@ local esplimit=30; -- display at most this many waypoints
|
|||||||
local espinterval=4 --number of seconds to wait between scans (a lower number can induce clientside lag)
|
local espinterval=4 --number of seconds to wait between scans (a lower number can induce clientside lag)
|
||||||
local stpos={x=0,y=0,z=0}
|
local stpos={x=0,y=0,z=0}
|
||||||
|
|
||||||
--nodes={"group:chest",'mcl_chests:chest','mcl_chests:chest_left','mcl_chests:ender_chest','group:shulker_box','mcl_crafting_table:crafting_table','mcl_furnaces:furnace'}
|
nodes=nlist.get("esp")
|
||||||
nodes={'mcl_chests:chest','mcl_chests:chest_left','mcl_chests:ender_chest','group:shulker_box','mcl_furnaces:furnace','mcl_chests:violet_shulker_box'}
|
|
||||||
|
|
||||||
local wps={}
|
local wps={}
|
||||||
local hud2=nil
|
local hud2=nil
|
||||||
local hud;
|
local hud;
|
||||||
local lastch=0
|
local lastch=0
|
||||||
|
local wason=false
|
||||||
|
|
||||||
minetest.register_globalstep(function()
|
minetest.register_globalstep(function()
|
||||||
if not minetest.settings:get_bool("espactive") then
|
if not minetest.settings:get_bool("espactive") then
|
||||||
|
if wason then
|
||||||
for k,v in pairs(wps) do
|
for k,v in pairs(wps) do
|
||||||
minetest.localplayer:hud_remove(v)
|
minetest.localplayer:hud_remove(v)
|
||||||
table.remove(wps,k)
|
table.remove(wps,k)
|
||||||
end
|
end
|
||||||
|
nlist.hide()
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if not minetest.localplayer then return end
|
||||||
|
|
||||||
if os.time() < lastch + espinterval then return end
|
if os.time() < lastch + espinterval then return end
|
||||||
lastch=os.time()
|
lastch=os.time()
|
||||||
|
if not minetest.settings:get_bool('nlist_edmode') then nlist.show_list("esp") end
|
||||||
local pos = minetest.localplayer:get_pos()
|
local pos = minetest.localplayer:get_pos()
|
||||||
local pos1 = vector.add(pos,{x=radius,y=radius,z=radius})
|
local pos1 = vector.add(pos,{x=radius,y=radius,z=radius})
|
||||||
local pos2 = vector.add(pos,{x=-radius,y=-radius,z=-radius})
|
local pos2 = vector.add(pos,{x=-radius,y=-radius,z=-radius})
|
||||||
@ -36,8 +40,7 @@ minetest.register_globalstep(function()
|
|||||||
|
|
||||||
for k,v in pairs(wps) do --clear waypoints out of range
|
for k,v in pairs(wps) do --clear waypoints out of range
|
||||||
local hd=minetest.localplayer:hud_get(v)
|
local hd=minetest.localplayer:hud_get(v)
|
||||||
local dst=vector.distance(pos,hd.world_pos)
|
if not hd or vector.distance(pos,hd.world_pos) > radius + 50 then
|
||||||
if (dst > radius + 50 ) then
|
|
||||||
minetest.localplayer:hud_remove(v)
|
minetest.localplayer:hud_remove(v)
|
||||||
table.remove(wps,k)
|
table.remove(wps,k)
|
||||||
end
|
end
|
||||||
|
@ -3,11 +3,16 @@ local storage=minetest.get_mod_storage()
|
|||||||
local sl="default"
|
local sl="default"
|
||||||
local mode=1 --1:add, 2:remove
|
local mode=1 --1:add, 2:remove
|
||||||
local nled_hud
|
local nled_hud
|
||||||
|
local edmode_wason=false
|
||||||
minetest.register_globalstep(function()
|
minetest.register_globalstep(function()
|
||||||
if not minetest.settings:get_bool('nlist_edmode') then
|
if not minetest.settings:get_bool('nlist_edmode') then
|
||||||
|
if edmode_wason then
|
||||||
if nled_hud then minetest.localplayer:hud_remove(nled_hud) end
|
if nled_hud then minetest.localplayer:hud_remove(nled_hud) end
|
||||||
|
edmode_wason=false
|
||||||
|
end
|
||||||
return end
|
return end
|
||||||
nlist.show_list(sl)
|
edmode_wason=true
|
||||||
|
nlist.show_list(sl,true)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_punchnode(function(p, n)
|
minetest.register_on_punchnode(function(p, n)
|
||||||
@ -61,6 +66,10 @@ function nlist.show_list(list)
|
|||||||
set_nled_hud(txt)
|
set_nled_hud(txt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function nlist.hide()
|
||||||
|
if nled_hud then minetest.localplayer:hud_remove(nled_hud) end
|
||||||
|
end
|
||||||
|
|
||||||
function nlist.random(list)
|
function nlist.random(list)
|
||||||
local str=storage:get(list)
|
local str=storage:get(list)
|
||||||
local tb=str:split(',')
|
local tb=str:split(',')
|
||||||
@ -72,12 +81,14 @@ function nlist.random(list)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function set_nled_hud(ttext)
|
function set_nled_hud(ttext,help)
|
||||||
if not minetest.localplayer then return end
|
if not minetest.localplayer then return end
|
||||||
if type(ttext) ~= "string" then return end
|
if type(ttext) ~= "string" then return end
|
||||||
local act="add"
|
local act="add"
|
||||||
if mode == 2 then act="remove" end
|
if mode == 2 then act="remove" end
|
||||||
local text="Nodelist edit mode\n .nla/.nlr to switch\n punch node to ".. act .. "\n.nlc to clear\n List:" .. ttext
|
local htext="Nodelist edit mode\n .nla/.nlr to switch\n punch node to ".. act .. "\n.nlc to clear\n"
|
||||||
|
local text ="List: ".. ttext
|
||||||
|
if help then text=htext..text end
|
||||||
if nled_hud then
|
if nled_hud then
|
||||||
minetest.localplayer:hud_change(nled_hud,'text',text)
|
minetest.localplayer:hud_change(nled_hud,'text',text)
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user