mirror of
https://github.com/minetest-mods/magma_conduits.git
synced 2025-01-19 19:01:28 +01:00
improve findvolcano command
This commit is contained in:
parent
f300d97686
commit
5f216d59ac
@ -42,13 +42,13 @@ setting("int", "volcano_min_height", 20, "Minimum volcano peak")
|
||||
setting("int", "volcano_max_height", 200, "Maximum volcano peak")
|
||||
setting("float", "volcano_min_slope", 0.75, "Minimum volcano slope")
|
||||
setting("float", "volcano_max_slope", 1.5, "Maximum volcano slope")
|
||||
setting("int", "volcano_region_mapblocks", 15, "Map blocks per chunk")
|
||||
setting("int", "volcano_region_mapblocks", 16, "Map blocks per chunk")
|
||||
|
||||
setting("int", "volcano_min_depth", -3000, "Lowest point the magma pipe goes to")
|
||||
setting("bool", "volcano_magma_chambers", true, "Enable magma chambers at the base of the magma pipe")
|
||||
setting("float", "volcano_magma_chamber_radius_multiplier", 0.5, "Magma chamber radius multiplier")
|
||||
|
||||
setting("float", "volcano_probability_active", 0.4, "Probability that there's an active volcano in each region")
|
||||
setting("float", "volcano_probability_dormant", 0.2, "Probability that there's a dormant volcano in each region")
|
||||
setting("float", "volcano_probability_extinct", 0.2, "Probability that there's an extinct volcano in each region")
|
||||
setting("float", "volcano_probability_active", 0.3, "Probability that there's an active volcano in each region")
|
||||
setting("float", "volcano_probability_dormant", 0.15, "Probability that there's a dormant volcano in each region")
|
||||
setting("float", "volcano_probability_extinct", 0.15, "Probability that there's an extinct volcano in each region")
|
||||
|
||||
|
@ -29,15 +29,15 @@ magma_conduits_volcano_min_slope (Minimum volcano slope) float 0.75
|
||||
magma_conduits_volcano_max_slope (Maximum volcano slope) float 1.5
|
||||
#The size of the region within which each volcano is randomly placed
|
||||
#measured in mapblocks, which is usually 80 nodes on a side.
|
||||
#Eg, the default of 15 means that one volcano is placed in each
|
||||
#1200x1200 node region.
|
||||
magma_conduits_volcano_region_mapblocks (Region mapblocks) int 15
|
||||
#Eg, the default of 16 means that one volcano is placed in each
|
||||
#1280x1280 node region.
|
||||
magma_conduits_volcano_region_mapblocks (Region mapblocks) int 16
|
||||
|
||||
magma_conduits_volcano_min_depth (Lowest depth magma pipes extend to) int -3000
|
||||
magma_conduits_volcano_magma_chambers (Enables magma chambers at base of pipes) bool true
|
||||
#With a multiplier of 1, magma chambers are the same size as the mountain above them.
|
||||
magma_conduits_volcano_magma_chamber_radius_multiplier (Magma chamber radius multiplier) float 0.5
|
||||
|
||||
magma_conduits_volcano_probability_active (Probability of active volcano in region) float 0.4
|
||||
magma_conduits_volcano_probability_dormant (Probability of dormant volcano in region) float 0.2
|
||||
magma_conduits_volcano_probability_extinct (Probability of extinct volcano in region) float 0.2
|
||||
magma_conduits_volcano_probability_active (Probability of active volcano in region) float 0.3
|
||||
magma_conduits_volcano_probability_dormant (Probability of dormant volcano in region) float 0.15
|
||||
magma_conduits_volcano_probability_extinct (Probability of extinct volcano in region) float 0.15
|
@ -39,12 +39,12 @@ minetest.register_lbm({
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "convert magma_conduits lava",
|
||||
nodenames = {"magma_conduits:lava_source"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
minetest.set_node(pos, {name="default:lava_source"})
|
||||
minetest.register_lbm({
|
||||
label = "convert magma_conduits flowing lava",
|
||||
name = "magma_conduits:convert_flowing_lava",
|
||||
nodenames = {"magma_conduits:lava_flowing"},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
minetest.set_node(pos, {name="default:lava_flowing"})
|
||||
end,
|
||||
})
|
@ -396,21 +396,24 @@ end)
|
||||
|
||||
minetest.register_privilege("findvolcano", { description = "Allows players to use a console command to find volcanoes", give_to_singleplayer = false})
|
||||
|
||||
function round(val, decimal)
|
||||
if (decimal) then
|
||||
return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
|
||||
else
|
||||
return math.floor(val+0.5)
|
||||
end
|
||||
end
|
||||
|
||||
local send_volcano_state = function(pos, name)
|
||||
|
||||
local corner_xz = get_corner(pos)
|
||||
|
||||
local text = "In region (" .. tostring(corner_xz.x) .. ", 0, " .. tostring(corner_xz.z) ..") to ("
|
||||
.. tostring(corner_xz.x+volcano_region_size) .. ", 0, " .. tostring(corner_xz.z+volcano_region_size) ..")\n"
|
||||
|
||||
local volcano = get_volcano(pos)
|
||||
if volcano == nil then
|
||||
minetest.chat_send_player(name, text.."No volcano present")
|
||||
return
|
||||
end
|
||||
text = text .. "Nearest volcano is at " .. minetest.pos_to_string(volcano.location, 0)
|
||||
.. "\nHeight: " .. tostring(volcano.depth_peak) .. " Slope: " .. tostring(volcano.slope)
|
||||
.. "\nState: "
|
||||
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)
|
||||
.. ", Slope: " .. tostring(round(volcano.slope, 2))
|
||||
.. ", State: "
|
||||
if volcano.state < state_extinct then
|
||||
text = text .. "Extinct"
|
||||
elseif volcano.state < state_dormant then
|
||||
@ -422,9 +425,21 @@ local send_volcano_state = function(pos, name)
|
||||
minetest.chat_send_player(name, text)
|
||||
end
|
||||
|
||||
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)
|
||||
send_volcano_state({x=pos.x, y=0, z=pos.z+volcano_region_size}, name)
|
||||
send_volcano_state({x=pos.x+volcano_region_size, y=0, z=pos.z+volcano_region_size}, name)
|
||||
send_volcano_state({x=pos.x-volcano_region_size, y=0, z=pos.z}, name)
|
||||
send_volcano_state(pos, name)
|
||||
send_volcano_state({x=pos.x+volcano_region_size, y=0, z=pos.z}, name)
|
||||
send_volcano_state({x=pos.x-volcano_region_size, y=0, z=pos.z-volcano_region_size}, name)
|
||||
send_volcano_state({x=pos.x, y=0, z=pos.z-volcano_region_size}, name)
|
||||
send_volcano_state({x=pos.x+volcano_region_size, y=0, z=pos.z-volcano_region_size}, name)
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("findvolcano", {
|
||||
params = "pos", -- Short parameter description
|
||||
description = "find the volcano in the player's map region, or in the map region containing pos if provided",
|
||||
description = "find the volcanoes near the player's map region, or in the map region containing pos if provided",
|
||||
func = function(name, param)
|
||||
if minetest.check_player_privs(name, {findvolcano = true}) then
|
||||
local pos = {}
|
||||
@ -433,11 +448,11 @@ minetest.register_chatcommand("findvolcano", {
|
||||
pos.y = tonumber(pos.y)
|
||||
pos.z = tonumber(pos.z)
|
||||
if pos.x and pos.y and pos.z then
|
||||
send_volcano_state(pos, name)
|
||||
send_nearby_states(pos, name)
|
||||
return true
|
||||
else
|
||||
local playerobj = minetest.get_player_by_name(name)
|
||||
send_volcano_state(playerobj:get_pos(), name)
|
||||
send_nearby_states(playerobj:get_pos(), name)
|
||||
return true
|
||||
end
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user