-- =================================================================== minetest.register_privilege ("findbones", { description = "Person can find bones" }) -- =================================================================== local function ocfp_to_int (x) local sgn = 1 if x < 0 then sgn = -1 end return sgn * math.floor (0.5 + math.abs (x)) end -- =================================================================== local param_findbones = { description = "Find bones in a radius up to 1024" , params = "radius (optional)" , privs = {} , privs = { findbones=true } , func = function (plname, params) local radius = tonumber (params) if radius == nil then radius = 64 end if radius < 128 then radius = 128 end if radius > 1024 then radius = 1024 end local player = minetest.env:get_player_by_name (plname) local pos = player:getpos() for xpass = -1, 1, 2 do for zpass = -1, 1, 2 do for xd = 0, 1024 * xpass, 100 * xpass do if xpass > 0 and xd > radius then break end if xpass < 0 and xd < -radius then break end for zd = 0, 1024 * zpass, 100 * zpass do if zpass > 0 and zd > radius then break end if zpass < 0 and zd < -radius then break end local sx = ocfp_to_int (pos.x+xd) local sy = ocfp_to_int (pos.y ) local sz = ocfp_to_int (pos.z+zd) if (sx < -31000) or (sx > 31000) then break end if (sy < -31000) or (sy > 31000) then break end if (sz < -31000) or (sz > 31000) then break end local spos = { x=sx, y=sy, z=sz } local bpos = minetest.find_node_near (spos, 110, { "bones:bones" }) if bpos == nil then minetest.chat_send_player (plname, spos.x .. "," .. spos.y .. "," .. spos.z) else minetest.chat_send_player (plname, "Dem bones dem bones " .. bpos.x .. "," .. bpos.y .. "," .. bpos.z) player:setpos (bpos) codersky.update_skybox (player) return end end end end end minetest.chat_send_player (plname, "No bones found") end } minetest.register_chatcommand ("findbones", param_findbones) -- =================================================================== -- End of file.