mirror of
https://github.com/minetest-mods/magma_conduits.git
synced 2025-01-05 03:57:34 +01:00
let player know explicitly if there's no nearby volcanoes
This commit is contained in:
parent
665dbe2636
commit
9a21f59d29
@ -345,7 +345,7 @@ local send_volcano_state = function(pos, name)
|
|||||||
local corner_xz = get_corner(pos)
|
local corner_xz = get_corner(pos)
|
||||||
local volcano = get_volcano(pos)
|
local volcano = get_volcano(pos)
|
||||||
if volcano == nil then
|
if volcano == nil then
|
||||||
return
|
return false
|
||||||
end
|
end
|
||||||
local location = {x=math.floor(volcano.location.x), y=volcano.depth_peak, z=math.floor(volcano.location.z)}
|
local location = {x=math.floor(volcano.location.x), y=volcano.depth_peak, z=math.floor(volcano.location.z)}
|
||||||
local text = "Peak at " .. minetest.pos_to_string(location)
|
local text = "Peak at " .. minetest.pos_to_string(location)
|
||||||
@ -360,18 +360,21 @@ local send_volcano_state = function(pos, name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
minetest.chat_send_player(name, text)
|
minetest.chat_send_player(name, text)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local send_nearby_states = function(pos, name)
|
local send_nearby_states = function(pos, name)
|
||||||
send_volcano_state({x=pos.x-volcano_region_size, y=0, z=pos.z+volcano_region_size}, name)
|
local retval = false
|
||||||
send_volcano_state({x=pos.x, y=0, z=pos.z+volcano_region_size}, name)
|
retval = send_volcano_state({x=pos.x-volcano_region_size, y=0, z=pos.z+volcano_region_size}, name) or retval
|
||||||
send_volcano_state({x=pos.x+volcano_region_size, y=0, z=pos.z+volcano_region_size}, name)
|
retval = send_volcano_state({x=pos.x, y=0, z=pos.z+volcano_region_size}, name) or retval
|
||||||
send_volcano_state({x=pos.x-volcano_region_size, y=0, z=pos.z}, name)
|
retval = send_volcano_state({x=pos.x+volcano_region_size, y=0, z=pos.z+volcano_region_size}, name) or retval
|
||||||
send_volcano_state(pos, name)
|
retval = send_volcano_state({x=pos.x-volcano_region_size, y=0, z=pos.z}, name) or retval
|
||||||
send_volcano_state({x=pos.x+volcano_region_size, y=0, z=pos.z}, name)
|
retval = send_volcano_state(pos, name) or retval
|
||||||
send_volcano_state({x=pos.x-volcano_region_size, y=0, z=pos.z-volcano_region_size}, name)
|
retval = send_volcano_state({x=pos.x+volcano_region_size, y=0, z=pos.z}, name) or retval
|
||||||
send_volcano_state({x=pos.x, y=0, z=pos.z-volcano_region_size}, name)
|
retval = send_volcano_state({x=pos.x-volcano_region_size, y=0, z=pos.z-volcano_region_size}, name) or retval
|
||||||
send_volcano_state({x=pos.x+volcano_region_size, y=0, z=pos.z-volcano_region_size}, name)
|
retval = send_volcano_state({x=pos.x, y=0, z=pos.z-volcano_region_size}, name) or retval
|
||||||
|
retval = send_volcano_state({x=pos.x+volcano_region_size, y=0, z=pos.z-volcano_region_size}, name) or retval
|
||||||
|
return retval
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("findvolcano", {
|
minetest.register_chatcommand("findvolcano", {
|
||||||
@ -385,11 +388,19 @@ minetest.register_chatcommand("findvolcano", {
|
|||||||
pos.y = tonumber(pos.y)
|
pos.y = tonumber(pos.y)
|
||||||
pos.z = tonumber(pos.z)
|
pos.z = tonumber(pos.z)
|
||||||
if pos.x and pos.y and pos.z then
|
if pos.x and pos.y and pos.z then
|
||||||
send_nearby_states(pos, name)
|
if not send_nearby_states(pos, name) then
|
||||||
|
minetest.chat_send_player(name, "No volcanoes near " .. minetest.pos_to_string(pos))
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
local playerobj = minetest.get_player_by_name(name)
|
local playerobj = minetest.get_player_by_name(name)
|
||||||
send_nearby_states(playerobj:get_pos(), name)
|
pos = playerobj:get_pos()
|
||||||
|
if not send_nearby_states(pos, name) then
|
||||||
|
pos.x = math.floor(pos.x)
|
||||||
|
pos.y = math.floor(pos.y)
|
||||||
|
pos.z = math.floor(pos.z)
|
||||||
|
minetest.chat_send_player(name, "No volcanoes near " .. minetest.pos_to_string(pos))
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user