mirror of
https://github.com/minetest-mods/magma_conduits.git
synced 2025-01-19 19:01:28 +01:00
pull in some chat commands from settlements too
This commit is contained in:
parent
624a8d17fc
commit
e0b97b0f3c
109
hud.lua
109
hud.lua
@ -120,18 +120,18 @@ minetest.register_globalstep(function(dtime)
|
||||
local min_visual_edge = vector.subtract(player_pos, visual_range)
|
||||
local max_visual_edge = vector.add(player_pos, visual_range)
|
||||
local visual_volcanos = areastore:get_areas_in_area(min_visual_edge, max_visual_edge, true, true, true)
|
||||
for id, settlement in pairs(visual_volcanos) do
|
||||
for id, volcano in pairs(visual_volcanos) do
|
||||
|
||||
local data = minetest.deserialize(settlement.data)
|
||||
local distance = vector.distance(player_pos, settlement.min)
|
||||
local data = minetest.deserialize(volcano.data)
|
||||
local distance = vector.distance(player_pos, volcano.min)
|
||||
local discovered_by = data.discovered_by
|
||||
local settlement_pos = vector.add(settlement.min, {x=0, y=2, z=0})
|
||||
local volcano_pos = vector.add(volcano.min, {x=0, y=2, z=0})
|
||||
|
||||
if distance < discovery_range and not discovered_by[player_name] then
|
||||
-- Update areastore
|
||||
data.discovered_by[player_name] = true
|
||||
areastore:remove_area(id)
|
||||
areastore:insert_area(settlement.min, settlement.min, minetest.serialize(data), id)
|
||||
areastore:insert_area(volcano.min, volcano.min, minetest.serialize(data), id)
|
||||
|
||||
-- Mark that we'll need to save volcanoes
|
||||
new_discovery = true
|
||||
@ -146,13 +146,13 @@ minetest.register_globalstep(function(dtime)
|
||||
formspec)
|
||||
minetest.chat_send_player(player_name, discovery_note)
|
||||
minetest.log("action", "[magma_conduits] " .. player_name .. " discovered " .. note_name)
|
||||
--minetest.sound_play({name = "settlements_chime01", gain = 0.25}, {to_player=player_name})
|
||||
minetest.sound_play({name = "magma_conduits_chime01", gain = 0.25}, {to_player=player_name})
|
||||
end
|
||||
|
||||
local has_map = (not requires_mappingkit) or (player:get_inventory():contains_item("main", "map:mapping_kit"))
|
||||
if has_map and distance < visual_range and discovered_by[player_name] then
|
||||
local settlement_name = data.name or "Volcano"
|
||||
add_hud_marker(player, player_name, settlement_pos, settlement_name)
|
||||
local volcano_name = data.name or "Volcano"
|
||||
add_hud_marker(player, player_name, volcano_pos, volcano_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -162,3 +162,96 @@ minetest.register_globalstep(function(dtime)
|
||||
volcano_save()
|
||||
end
|
||||
end)
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- Chatcommands
|
||||
|
||||
local function get_nearest_volcano_within_range(pos, range, name)
|
||||
local min_edge = vector.subtract(pos, range)
|
||||
local max_edge = vector.add(pos, range)
|
||||
local volcano_list = areastore:get_areas_in_area(min_edge, max_edge, true, true, true)
|
||||
|
||||
local min_dist = range + 1 -- start with number beyond range
|
||||
local min_id = nil
|
||||
local min_data = nil
|
||||
local min_pos = nil
|
||||
for id, volcano in pairs(volcano_list) do
|
||||
local data = minetest.deserialize(volcano.data)
|
||||
local distance = vector.distance(pos, volcano.min)
|
||||
if distance < min_dist and data.discovered_by[name] then
|
||||
min_dist = distance
|
||||
min_id = id
|
||||
min_data = data
|
||||
min_pos = volcano.min
|
||||
end
|
||||
end
|
||||
|
||||
return min_pos, min_id, min_data
|
||||
end
|
||||
|
||||
|
||||
minetest.register_chatcommand("volcano_rename_nearest", {
|
||||
description = S("Change the name of the nearest volcano within visible range"),
|
||||
param = S("The new name for this volcano"),
|
||||
privs = {["server"]=true},
|
||||
func = function(name, param)
|
||||
if param == "" then
|
||||
minetest.chat_send_player(name, S("Please enter a new name"))
|
||||
return
|
||||
end
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local player_pos = player:get_pos()
|
||||
|
||||
local min_pos, min_id, min_data = get_nearest_volcano_within_range(player_pos, visual_range, name)
|
||||
|
||||
if min_id ~= nil then
|
||||
local oldname = min_data.name
|
||||
min_data.name = param
|
||||
areastore:remove_area(min_id)
|
||||
areastore:insert_area(min_pos, min_pos, minetest.serialize(min_data), min_id)
|
||||
volcano_save()
|
||||
minetest.log("action", "[magma_conduits] Renamed " .. oldname .. " to " .. param)
|
||||
minetest.chat_send_player(name, S("Volcano successfully renamed from @1 to @2.", oldname, param))
|
||||
remove_all_hud_markers()
|
||||
return
|
||||
end
|
||||
|
||||
minetest.chat_send_player(name, S("No known volcanoes within @1m found.", visual_range))
|
||||
end,
|
||||
})
|
||||
|
||||
local function set_all_discovered(player_name, state)
|
||||
local volcano_list = areastore:get_areas_in_area(
|
||||
{x=-32000, y=-32000, z=-32000}, {x=32000, y=32000, z=32000}, true, true, true)
|
||||
for id, volcano in pairs(volcano_list) do
|
||||
local data = minetest.deserialize(volcano.data)
|
||||
data.discovered_by[player_name] = state
|
||||
areastore:remove_area(id)
|
||||
areastore:insert_area(volcano.min, volcano.min, minetest.serialize(data), id)
|
||||
end
|
||||
volcano_save()
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("volcano_discover_all", {
|
||||
description = S("Set all volcanoes as known to you or another player"),
|
||||
param = S("player_name, or nothing for yourself"),
|
||||
privs = {["server"]=true},
|
||||
func = function(name, param)
|
||||
if param ~= "" then
|
||||
name = param
|
||||
end
|
||||
set_all_discovered(name, true)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("volcano_undiscover_all", {
|
||||
description = S("Set all volcanoes as unknown to you or another player"),
|
||||
param = S("player_name, or nothing for yourself"),
|
||||
privs = {["server"]=true},
|
||||
func = function(name, param)
|
||||
if param ~= "" then
|
||||
name = param
|
||||
end
|
||||
set_all_discovered(name, nil)
|
||||
end,
|
||||
})
|
||||
|
@ -40,4 +40,10 @@ magma_conduits_volcano_magma_chamber_radius_multiplier (Magma chamber radius mul
|
||||
|
||||
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
|
||||
magma_conduits_volcano_probability_extinct (Probability of extinct volcano in region) float 0.15
|
||||
|
||||
[Volcano HUD waypoints]
|
||||
magma_conduits_show_volcanoes_in_hud (Show volcanoes in HUD) bool true
|
||||
magma_conduits_hud_requires_mapping_kit (Require mapping kit to show in HUD) bool true
|
||||
magma_conduits_volcano_discovery_range (Volcano discovery range) int 60
|
||||
magma_conduits_volcano_visibility_range (Volcano HUD visibility range) int 1200
|
1
sounds/license.txt
Normal file
1
sounds/license.txt
Normal file
@ -0,0 +1 @@
|
||||
magma_conduits_chime01.ogg is from https://freesound.org/people/Andromadax24/sounds/186719/ by Andromadax24 under the CC-BY-3.0 license
|
BIN
sounds/magma_conduits_chime01.ogg
Normal file
BIN
sounds/magma_conduits_chime01.ogg
Normal file
Binary file not shown.
@ -1,9 +1,19 @@
|
||||
name "active_volcano" {
|
||||
syllablesStart = "Fire, Smoulder, Grey, Ash, Pyre, Ember, Forge, Crack, Earth, Stone, Boulder"
|
||||
syllablesStart = "Fire, Smoulder, Grey, Ash, Pyre, Ember, Forge, Crack, Earth, Stone, Boulder, Sulphur, Mist, Cloud, Tomb,"
|
||||
|
||||
syllablesEnd = "forge, mouth, heap, cone, pit, vent"
|
||||
syllablesEnd = "forge, mouth, heap, cone, pit, vent, horn"
|
||||
|
||||
syllablesPost = "Peak, Crag, Spire"
|
||||
syllablesPost = "Peak, Crag, Spire, Mountain, Tor, Ridge, Dome, Mound, Palisade, Volcano"
|
||||
|
||||
rules = "Mount_$s$e, $s$e_$80p"
|
||||
rules = "Mount_$s$e, $s$e_$90p"
|
||||
}
|
||||
|
||||
name "inactive_volcano" {
|
||||
syllablesStart = "Bird, Baker, Ball, Aurora, Bishop, Block, Blue, Grey, Cave, Caribou, Cole, Cirrus, Copper, Cougar, Crow, Eagle, Fable, Fiddle, Finger, Fox, Gloria, Gold, Gordon, Heart, Goat, Kent, Red, Ring, Rose, Rundle, Shark, Scarab, Smut, Snow, South, North, East, West, Stone, Storm, Sulphur, Cloud, Temple, Tomb, Terra, Tower, Tunnel, Twin, Turtle, Trap, War, Wedge, Wind, Wonder"
|
||||
|
||||
syllablesEnd = "wood, ston, ton, land, lets, wall, well, foot, nest, en, view, hood, arch, met, horn"
|
||||
|
||||
syllablesPost = "Peak, Crag, Spire, Mountain, Tor, Ridge, Dome, Mound, Palisade"
|
||||
|
||||
rules = "Mount_$s$80e, $s$e_$90p, $s_$p"
|
||||
}
|
@ -128,12 +128,12 @@ local get_volcano = function(pos)
|
||||
elseif state < state_dormant then
|
||||
depth_lava = depth_peak - math.random(5, 50) -- dormant
|
||||
if namegen_path then
|
||||
name = namegen.generate("active_volcano")
|
||||
name = namegen.generate("inactive_volcano")
|
||||
end
|
||||
else
|
||||
depth_lava = depth_peak - math.random(1, 25) -- active, put the lava near the top
|
||||
if namegen_path then
|
||||
name = namegen.generate("active_volcano")
|
||||
name = namegen.generate("inactive_volcano")
|
||||
end
|
||||
end
|
||||
local slope = math.random() * (slope_max - slope_min) + slope_min
|
||||
|
Loading…
Reference in New Issue
Block a user