This commit is contained in:
HimbeerserverDE 2021-01-28 20:16:32 +01:00
commit 8ae233ba36
18 changed files with 477 additions and 428 deletions

View File

@ -70,26 +70,18 @@ end
minetest.register_on_respawnplayer(detach_player)
function boat.on_rightclick(self, clicker)
if not clicker or not clicker:is_player() then
if self._driver or not clicker or not clicker:is_player() or clicker:get_attach() then
return
end
local name = clicker:get_player_name()
if self._driver and clicker == self._driver then
self._driver = nil
detach_player(clicker)
local pos = clicker:get_pos()
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
clicker:set_pos(pos)
elseif not self._driver then
local attach = clicker:get_attach()
if attach and attach:get_luaentity() then
--[[if attach and attach:get_luaentity() then
local luaentity = attach:get_luaentity()
if luaentity._driver then
luaentity._driver = nil
end
clicker:set_detach()
clicker:set_properties({visual_size = {x=1, y=1}})
end
end--]]
self._driver = clicker
clicker:set_attach(self.object, "",
{x = 0, y = 0.42, z = -1}, {x = 0, y = 0, z = 0})
@ -102,7 +94,7 @@ function boat.on_rightclick(self, clicker)
end
end, name)
clicker:set_look_horizontal(self.object:get_yaw())
end
mcl_tmp_message.message(clicker, S("Sneak to dismount"))
end
@ -142,7 +134,7 @@ function boat.on_death(self, killer)
self._driver = nil
end
function boat.on_step(self, dtime)
function boat.on_step(self, dtime, moveresult)
self._v = get_v(self.object:get_velocity()) * get_sign(self._v)
local on_water = true
local in_water = false
@ -160,8 +152,25 @@ function boat.on_step(self, dtime)
v_slowdown = 0.05
end
if moveresult and moveresult.collides then
for _, collision in ipairs(moveresult.collisions) do
local pos = collision.node_pos
if collision.type == "node" and minetest.get_node_group(minetest.get_node(pos).name, "dig_by_boat") > 0 then
minetest.dig_node(pos)
end
end
end
if self._driver then
local ctrl = self._driver:get_player_control()
if ctrl.sneak then
detach_player(self._driver)
local pos = self._driver:get_pos()
pos = {x = pos.x, y = pos.y + 0.2, z = pos.z}
self._driver:set_pos(pos)
self._driver = nil
return
end
local yaw = self.object:get_yaw()
if ctrl.up then
-- Forwards

View File

@ -1,4 +1,4 @@
local modpath = minetest.get_modpath("mcl_weather");
local modpath = minetest.get_modpath("mcl_weather")
mcl_weather = {}

View File

@ -24,11 +24,8 @@ end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer >= 0.7 then
if timer < 0.7 then return end
timer = 0
else
return
end
for _, player in ipairs(minetest.get_connected_players()) do
if not mcl_worlds.has_dust(player:get_pos()) then

View File

@ -92,6 +92,5 @@ if mcl_weather.reg_weathers.snow == nil then
[80] = "rain",
[100] = "thunder",
}
}
}
end

View File

@ -6,8 +6,8 @@ mcl_weather.state = "none"
-- player list for saving player meta info
mcl_weather.players = {}
-- default weather recalculation interval
mcl_weather.check_interval = 300
-- default weather check interval for global step
mcl_weather.check_interval = 5
-- weather min duration
mcl_weather.min_duration = 600
@ -47,9 +47,9 @@ minetest.register_on_shutdown(save_weather)
mcl_weather.get_rand_end_time = function(min_duration, max_duration)
local r
if min_duration ~= nil and max_duration ~= nil then
r = math.random(min_duration, max_duration);
r = math.random(min_duration, max_duration)
else
r = math.random(mcl_weather.min_duration, mcl_weather.max_duration);
r = math.random(mcl_weather.min_duration, mcl_weather.max_duration)
end
return minetest.get_gametime() + r
end
@ -121,7 +121,12 @@ mcl_weather.get_random_pos_by_player_look_dir = function(player)
return random_pos_x, random_pos_y, random_pos_z
end
local t, wci = 0, mcl_weather.check_interval
minetest.register_globalstep(function(dtime)
t = t + dtime
if t < wci then return end
t = 0
if mcl_weather.end_time == nil then
mcl_weather.end_time = mcl_weather.get_rand_end_time()
end
@ -141,7 +146,7 @@ end)
-- Sets random weather (which could be 'none' (no weather)).
mcl_weather.set_random_weather = function(weather_name, weather_meta)
if (weather_meta ~= nil) then
if weather_meta == nil then return end
local transitions = weather_meta.transitions
local random_roll = math.random(0,100)
local new_weather
@ -154,18 +159,32 @@ mcl_weather.set_random_weather = function(weather_name, weather_meta)
if new_weather then
mcl_weather.change_weather(new_weather)
end
end
end
-- Change weather to new_weather.
-- * explicit_end_time is OPTIONAL. If specified, explicitly set the
-- gametime (minetest.get_gametime) in which the weather ends.
mcl_weather.change_weather = function(new_weather, explicit_end_time)
-- * changer is OPTIONAL, for logging purposes.
mcl_weather.change_weather = function(new_weather, explicit_end_time, changer_name)
local changer_name = changer_name or debug.getinfo(2).name.."()"
if (mcl_weather.reg_weathers ~= nil and mcl_weather.reg_weathers[new_weather] ~= nil) then
if (mcl_weather.state ~= nil and mcl_weather.reg_weathers[mcl_weather.state] ~= nil) then
mcl_weather.reg_weathers[mcl_weather.state].clear()
end
local old_weather = mcl_weather.state
mcl_weather.state = new_weather
if old_weather == "none" then
old_weather = "clear"
end
if new_weather == "none" then
new_weather = "clear"
end
minetest.log("action", "[mcl_weather] " .. changer_name .. " changed the weather from " .. old_weather .. " to " .. new_weather)
local weather_meta = mcl_weather.reg_weathers[mcl_weather.state]
if explicit_end_time then
mcl_weather.end_time = explicit_end_time
@ -218,7 +237,7 @@ minetest.register_chatcommand("weather", {
end
end
local success = mcl_weather.change_weather(new_weather, end_time)
local success = mcl_weather.change_weather(new_weather, end_time, name)
if success then
return true
else
@ -234,13 +253,13 @@ minetest.register_chatcommand("toggledownfall", {
func = function(name, param)
-- Currently rain/thunder/snow: Set weather to clear
if mcl_weather.state ~= "none" then
return mcl_weather.change_weather("none")
return mcl_weather.change_weather("none", nil, name)
-- Currently clear: Set weather randomly to rain/thunder/snow
else
local new = { "rain", "thunder", "snow" }
local r = math.random(1, #new)
return mcl_weather.change_weather(new[r])
return mcl_weather.change_weather(new[r], nil, name)
end
end
})

View File

@ -0,0 +1,44 @@
mcl_tmp_message = {}
local huds = {}
local hud_hide_timeouts = {}
function mcl_tmp_message.message(player, message)
local name = player:get_player_name()
player:hud_change(huds[name], "text", message)
hud_hide_timeouts[name] = 3
end
minetest.register_on_joinplayer(function(player)
huds[player:get_player_name()] = player:hud_add({
hud_elem_type = "text",
position = {x=0.5, y=1},
offset = {x = 0, y = -210},
alignment = {x=0, y=0},
number = 0xFFFFFF ,
text = "",
z_index = 100,
})
end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
huds[name] = nil
hud_hide_timeouts[name] = nil
end)
minetest.register_globalstep(function(dtime)
local new_timeouts = {}
for name, timeout in pairs(hud_hide_timeouts) do
timeout = timeout - dtime
if timeout <= 0 then
local player = minetest.get_player_by_name(name)
if player then
player:hud_change(huds[name], "text", "")
end
else
new_timeouts[name] = timeout
end
end
hud_hide_timeouts = new_timeouts
end)

View File

@ -6,8 +6,6 @@ local player_in_bed = 0
local is_sp = minetest.is_singleplayer()
local weather_mod = minetest.get_modpath("mcl_weather") ~= nil
local explosions_mod = minetest.get_modpath("mcl_explosions") ~= nil
local huds = {}
local hud_hide_timeouts = {}
-- Helper functions
@ -326,8 +324,7 @@ function mcl_beds.on_rightclick(pos, player, is_top)
success, message = lay_down(player, ppos, other)
end
if message then
player:hud_change(huds[name], "text", message)
hud_hide_timeouts[name] = 3
mcl_tmp_message.message(player, message)
end
else
lay_down(player, nil, nil, false)
@ -355,25 +352,12 @@ minetest.register_on_joinplayer(function(player)
meta:set_string("mcl_beds:sleeping", "false")
end
huds[player:get_player_name()] = player:hud_add({
hud_elem_type = "text",
position = {x=0.5, y=1},
offset = {x = 0, y = -210},
alignment = {x=0, y=0},
number = 0xFFFFFF ,
text = "",
z_index = 100,
})
playerphysics.remove_physics_factor(player, "speed", "mcl_beds:sleeping")
playerphysics.remove_physics_factor(player, "jump", "mcl_beds:sleeping")
update_formspecs(false)
end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
huds[name] = nil
local players = minetest.get_connected_players()
for n, player in ipairs(players) do
if player:get_player_name() == name then
@ -412,19 +396,3 @@ minetest.register_on_player_hpchange(function(player, hp_change)
mcl_beds.kick_player(player)
end
end)
minetest.register_globalstep(function(dtime)
local new_timeouts = {}
for name, timeout in pairs(hud_hide_timeouts) do
timeout = timeout - dtime
if timeout <= 0 then
local player = minetest.get_player_by_name(name)
if player then
player:hud_change(huds[name], "text", "")
end
else
new_timeouts[name] = timeout
end
end
hud_hide_timeouts = new_timeouts
end)

View File

@ -390,7 +390,7 @@ minetest.register_node("mcl_flowers:waterlily", {
liquids_pointable = true,
walkable = true,
sunlight_propagates = true,
groups = {dig_immediate = 3, plant=1, dig_by_water = 1,destroy_by_lava_flow=1, dig_by_piston = 1, deco_block=1},
groups = {dig_immediate = 3, plant=1, dig_by_water = 1,destroy_by_lava_flow=1, dig_by_piston = 1, deco_block=1, dig_by_boat=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_placement_prediction = "",
node_box = {

View File

@ -54,12 +54,13 @@ schem_path = settlements.modpath.."/schematics/"
--
schematic_table = {
{name = "large_house", mts = schem_path.."large_house.mts", hwidth = 11, hdepth = 12, hheight = 9, hsize = 14, max_num = 0.08, rplc = "n"},
{name = "blacksmith", mts = schem_path.."blacksmith.mts", hwidth = 7, hdepth = 7, hheight = 13, hsize = 13, max_num = 0.050, rplc = "n"},
{name = "blacksmith", mts = schem_path.."blacksmith.mts", hwidth = 7, hdepth = 7, hheight = 13, hsize = 13, max_num = 0.055, rplc = "n"},
{name = "butcher", mts = schem_path.."butcher.mts", hwidth = 11, hdepth = 8, hheight = 10, hsize = 14, max_num = 0.03, rplc = "n"},
{name = "church", mts = schem_path.."church.mts", hwidth = 13, hdepth = 13, hheight = 14, hsize = 15, max_num = 0.04, rplc = "n"},
{name = "farm", mts = schem_path.."farm.mts", hwidth = 7, hdepth = 7, hheight = 13, hsize = 13, max_num = 0.1, rplc = "n"},
{name = "lamp", mts = schem_path.."lamp.mts", hwidth = 3, hdepth = 3, hheight = 13, hsize = 10, max_num = 0.1, rplc = "n"},
{name = "library", mts = schem_path.."library.mts", hwidth = 12, hdepth = 12, hheight = 8, hsize = 13, max_num = 0.04, rplc = "n"},
{name = "medium_house", mts = schem_path.."medium_house.mts", hwidth = 8, hdepth = 12, hheight = 8, hsize = 14, max_num = 0.09, rplc = "n"},
{name = "medium_house", mts = schem_path.."medium_house.mts", hwidth = 8, hdepth = 12, hheight = 8, hsize = 14, max_num = 0.08, rplc = "n"},
{name = "small_house", mts = schem_path.."small_house.mts", hwidth = 9, hdepth = 7, hheight = 8, hsize = 13, max_num = 0.7, rplc = "n"},
{name = "tavern", mts = schem_path.."tavern.mts", hwidth = 11, hdepth = 10, hheight = 10, hsize = 13, max_num = 0.050, rplc = "n"},
{name = "well", mts = schem_path.."well.mts", hwidth = 6, hdepth = 8, hheight = 6, hsize = 10, max_num = 0.045, rplc = "n"},

View File

@ -1,3 +1,4 @@
mcl_core
mcl_loot
mcl_farming?
mobs_mc?

View File

@ -113,6 +113,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
if maxp.y < 0 then return end
-- don't build settlements too close to each other
--[[
local center_of_chunk = {
x=maxp.x-half_map_chunk_size,
y=maxp.y-half_map_chunk_size,
@ -120,6 +121,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
}
local dist_ok = settlements.check_distance_other_settlements(center_of_chunk)
if dist_ok == false then return end
]]
-- don't build settlements on (too) uneven terrain
local height_difference = settlements.evaluate_heightmap(minp, maxp)
@ -162,7 +164,7 @@ minetest.register_craftitem("mcl_villages:tool", {
-- build ssettlement
--
on_place = function(itemstack, placer, pointed_thing)
local pr = PseudoRandom(math.rand(0,32767))
local pr = PseudoRandom(math.random(0,32767))
-- enable debug routines
local center_surface = pointed_thing.under
if center_surface then
@ -213,10 +215,10 @@ minetest.register_craftitem("mcl_villages:tool", {
--
if settlements.lvm == true then
vm:set_data(data)
settlements.place_schematics_lvm(pr)
settlements.place_schematics_lvm(settlement_info, pr)
vm:write_to_map(true)
else
settlements.place_schematics()
settlements.place_schematics(settlement_info, pr)
end
--

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

View File

@ -1,3 +1,5 @@
mcl_villages = {}
local c_dirt_with_grass = minetest.get_content_id("mcl_core:dirt_with_grass")
local c_dirt_with_snow = minetest.get_content_id("mcl_core:dirt_with_grass_snow")
--local c_dirt_with_dry_grass = minetest.get_content_id("mcl_core:dirt_with_dry_grass")
@ -206,17 +208,19 @@ end
-------------------------------------------------------------------------------
-- check distance to other settlements
-------------------------------------------------------------------------------
--[[
function settlements.check_distance_other_settlements(center_new_chunk)
-- local min_dist_settlements = 300
-- local min_dist_settlements = 300
for i, pos in ipairs(settlements_in_world) do
local distance = vector.distance(center_new_chunk, pos)
-- minetest.chat_send_all("dist ".. distance)
-- minetest.chat_send_all("dist ".. distance)
if distance < settlements.min_dist_settlements then
return false
end
end
return true
end
]]
-------------------------------------------------------------------------------
-- fill chests
-------------------------------------------------------------------------------
@ -235,33 +239,38 @@ function settlements.fill_chest(pos, pr)
end
-- fill chest
local inv = minetest.get_inventory( {type="node", pos=chestpos} )
-- always
inv:add_item("main", "mcl_core:apple "..pr:next(1,3))
-- low value items
if pr:next(0,1) < 1 then
inv:add_item("main", "mcl_farming:bread "..pr:next(0,3))
inv:add_item("main", "mcl_core:iron_ingot "..pr:next(0,3))
inv:add_item("main", "mcl_farming:melon_item "..pr:next(0,3))
inv:add_item("main", "mcl_farming:carrot_item "..pr:next(0,3))
--[[
-- additional fillings when farmin mod enabled
if minetest.get_modpath("farming") ~= nil and farming.mod == "redo" then
if pr:next(0,1) < 1 then
inv:add_item("main", "mcl_farming:melon_item "..pr:next(0,3))
inv:add_item("main", "mcl_farming:carrot_item "..pr:next(0,3))
inv:add_item("main", "farming:corn "..pr:next(0,3))
end
end
--]]
end
-- medium value items
if pr:next(0,3) < 1 then
inv:add_item("main", "mcl_tools:pick_iron "..pr:next(0,1))
inv:add_item("main", "mcl_tools:pick_stone "..pr:next(0,1))
inv:add_item("main", "mcl_fire:flint_and_steel "..pr:next(0,1))
inv:add_item("main", "mcl_buckets:bucket_empty "..pr:next(0,1))
inv:add_item("main", "mcl_tools:sword_iron "..pr:next(0,1))
function mcl_villages.get_treasures(pr)
local loottable = {
{
stacks_min = 3,
stacks_max = 8,
items = {
{ itemstring = "mcl_core:diamond", weight = 3, amount_min = 1, amount_max = 3 },
{ itemstring = "mcl_core:iron_ingot", weight = 10, amount_min = 1, amount_max = 5 },
{ itemstring = "mcl_core:gold_ingot", weight = 5, amount_min = 1, amount_max = 3 },
{ itemstring = "mcl_farming:bread", weight = 15, amount_min = 1, amount_max = 3 },
{ itemstring = "mcl_core:apple", weight = 15, amount_min = 1, amount_max = 3 },
{ itemstring = "mcl_tools:pick_iron", weight = 5 },
{ itemstring = "mcl_tools:sword_iron", weight = 5 },
{ itemstring = "mcl_armor:chestplate_iron", weight = 5 },
{ itemstring = "mcl_armor:helmet_iron", weight = 5 },
{ itemstring = "mcl_armor:leggings_iron", weight = 5 },
{ itemstring = "mcl_armor:boots_iron", weight = 5 },
{ itemstring = "mcl_core:obsidian", weight = 5, amount_min = 3, amount_max = 7 },
{ itemstring = "mcl_core:sapling", weight = 5, amount_min = 3, amount_max = 7 },
{ itemstring = "mcl_mobitems:saddle", weight = 3 },
{ itemstring = "mobs_mc:iron_horse_armor", weight = 1 },
{ itemstring = "mobs_mc:gold_horse_armor", weight = 1 },
{ itemstring = "mobs_mc:diamond_horse_armor", weight = 1 },
}
},
}
local items = mcl_loot.get_multi_loot(loottable, pr)
return items
end
local items = mcl_villages.get_treasures(pr)
mcl_loot.fill_inventory(inv, "main", items)
end
-------------------------------------------------------------------------------