flyc0r 2551ddbf1d Add changes from waspsaliva initial commit
This commit contains changes best credited to flyc0r
<flyc0r@localhost.localdomain>, although the changes were separated
out from waspsaliva's original initial commit rev. 0e9e1f352, which
added the files from DFC work tree, and squashed in numerous additions
by flyc0r and collaborators.  That commit log:

    commit 0e9e1f3528c3d2fa1f1e9a79d4a00576be8552f5
    Author: flyc0r <flyc0r@localhost.localdomain>
    Date:   Sun Oct 4 03:37:08 2020 +0200

        init

This rebase had the effect of griefing the git history xD, so
for example `git blame` of DFC and even upstream Minetest sources
appear to be originally authored by `flyc0r` in that commit.

To fix this, I will recommit only the changes onto the appropriate
commit in DFC, and recreate the following git history (incl. merges).
After this, the git history will be at least visually the same as the
original Waspsaliva, even if commit sha1sums have changed.

AFAICT, the closest commit from DFC was af085acbd.  That commit was
found simply by running `git diff wsc-master <some_DFC_rev>`, and
locating the commit with the smallest number of differences.

This commit was then created as follows:

    # Check out the DFC base commit
    git checkout af085acbd
    # Check out the *files* from WSC's initial commit
    git checkout 0e9e1f352 -- .
    # Make sure everything is added and commit the changes
    git add -A
    git commit
2021-08-28 21:58:59 -05:00

93 lines
3.3 KiB
Lua

---
-- coras esp .. indev
esp = {}
local radius=79 -- limit is 4,096,000 nodes (i.e. 160^3 -> a number > 79 won't work)
local esplimit=30; -- display at most this many waypoints
local espinterval=1 --number of seconds to wait between scans (a lower number can induce clientside lag)
--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={'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 hud2=nil
local hud;
local lastch=0
minetest.register_globalstep(function()
if not minetest.settings:get_bool("espactive") then
if hud2 then minetest.localplayer:hud_remove(hud2) hud2=nil end
for k,v in pairs(wps) do
minetest.localplayer:hud_remove(v)
table.remove(wps,k)
end
return
end
if os.time() < lastch + espinterval then return end
lastch=os.time()
local pos = minetest.localplayer:get_pos()
local pos1 = vector.add(pos,{x=radius,y=radius,z=radius})
local pos2 = vector.add(pos,{x=-radius,y=-radius,z=-radius})
local fpos,cnt=minetest.find_nodes_in_area(pos1, pos2, nodes, false)
local epos=minetest.find_nodes_in_area(pos1, pos2, nodes, true)
for k,v in pairs(wps) do --clear waypoints out of range
local hd=minetest.localplayer:hud_get(v)
local dst=vector.distance(pos,hd.world_pos)
if (dst > radius + 50 ) then
minetest.localplayer:hud_remove(v)
table.remove(wps,k)
end
end
if epos then
if(hud2) then minetest.localplayer:hud_remove(hud2) end
local infotxt=""
for k,v in pairs(cnt) do -- display a summary
if not ( v == 0 ) then
if minetest.settings:get_bool("espautostop") then minetest.settings:set("continuous_forward", "false") end
infotxt=infotxt.."\n"..k..":"..v
end
end
if infotxt ~= "" then
hud2=minetest.localplayer:hud_add({
hud_elem_type = 'text',
name = "ESP info",
text = "NOIs in range ("..radius..")\n"..infotxt,
number = 0x00ff00,
direction = 0,
position = {x=0.75,y=0.4},
alignment ={x=1,y=1},
offset = {x=0, y=0}
})
end
local ii=0;
for m,xx in pairs(epos) do -- display found nodes as WPs
for kk,vv in pairs(xx) do
if ( ii > esplimit ) then break end
ii=ii+1
table.insert(wps,minetest.localplayer:hud_add({
hud_elem_type = 'waypoint',
name = m,
text = "m",
number = 0x00ff00,
world_pos = vv
})
)
end
end
end
end)
if (_G["minetest"]["register_cheat"] ~= nil) then
minetest.register_cheat("ESP active", "ESP", "espactive")
minetest.register_cheat("autostop", "ESP", "espautostop")
else
minetest.settings:set_bool('espactive',true)
end