forked from VoxeLibre/VoxeLibre
Merge branch 'master' of https://git.minetest.land/Wuzzy/MineClone2
This commit is contained in:
commit
8ae233ba36
|
@ -70,26 +70,18 @@ end
|
||||||
minetest.register_on_respawnplayer(detach_player)
|
minetest.register_on_respawnplayer(detach_player)
|
||||||
|
|
||||||
function boat.on_rightclick(self, clicker)
|
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
|
return
|
||||||
end
|
end
|
||||||
local name = clicker:get_player_name()
|
local name = clicker:get_player_name()
|
||||||
if self._driver and clicker == self._driver then
|
--[[if attach and attach:get_luaentity() 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
|
|
||||||
local luaentity = attach:get_luaentity()
|
local luaentity = attach:get_luaentity()
|
||||||
if luaentity._driver then
|
if luaentity._driver then
|
||||||
luaentity._driver = nil
|
luaentity._driver = nil
|
||||||
end
|
end
|
||||||
clicker:set_detach()
|
clicker:set_detach()
|
||||||
clicker:set_properties({visual_size = {x=1, y=1}})
|
clicker:set_properties({visual_size = {x=1, y=1}})
|
||||||
end
|
end--]]
|
||||||
self._driver = clicker
|
self._driver = clicker
|
||||||
clicker:set_attach(self.object, "",
|
clicker:set_attach(self.object, "",
|
||||||
{x = 0, y = 0.42, z = -1}, {x = 0, y = 0, z = 0})
|
{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
|
||||||
end, name)
|
end, name)
|
||||||
clicker:set_look_horizontal(self.object:get_yaw())
|
clicker:set_look_horizontal(self.object:get_yaw())
|
||||||
end
|
mcl_tmp_message.message(clicker, S("Sneak to dismount"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,7 +134,7 @@ function boat.on_death(self, killer)
|
||||||
self._driver = nil
|
self._driver = nil
|
||||||
end
|
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)
|
self._v = get_v(self.object:get_velocity()) * get_sign(self._v)
|
||||||
local on_water = true
|
local on_water = true
|
||||||
local in_water = false
|
local in_water = false
|
||||||
|
@ -160,8 +152,25 @@ function boat.on_step(self, dtime)
|
||||||
v_slowdown = 0.05
|
v_slowdown = 0.05
|
||||||
end
|
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
|
if self._driver then
|
||||||
local ctrl = self._driver:get_player_control()
|
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()
|
local yaw = self.object:get_yaw()
|
||||||
if ctrl.up then
|
if ctrl.up then
|
||||||
-- Forwards
|
-- Forwards
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local modpath = minetest.get_modpath("mcl_weather");
|
local modpath = minetest.get_modpath("mcl_weather")
|
||||||
|
|
||||||
mcl_weather = {}
|
mcl_weather = {}
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,8 @@ end
|
||||||
local timer = 0
|
local timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
timer = timer + dtime
|
timer = timer + dtime
|
||||||
if timer >= 0.7 then
|
if timer < 0.7 then return end
|
||||||
timer = 0
|
timer = 0
|
||||||
else
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
if not mcl_worlds.has_dust(player:get_pos()) then
|
if not mcl_worlds.has_dust(player:get_pos()) then
|
||||||
|
|
|
@ -94,4 +94,3 @@ if mcl_weather.reg_weathers.snow == nil then
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ mcl_weather.state = "none"
|
||||||
-- player list for saving player meta info
|
-- player list for saving player meta info
|
||||||
mcl_weather.players = {}
|
mcl_weather.players = {}
|
||||||
|
|
||||||
-- default weather recalculation interval
|
-- default weather check interval for global step
|
||||||
mcl_weather.check_interval = 300
|
mcl_weather.check_interval = 5
|
||||||
|
|
||||||
-- weather min duration
|
-- weather min duration
|
||||||
mcl_weather.min_duration = 600
|
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)
|
mcl_weather.get_rand_end_time = function(min_duration, max_duration)
|
||||||
local r
|
local r
|
||||||
if min_duration ~= nil and max_duration ~= nil then
|
if min_duration ~= nil and max_duration ~= nil then
|
||||||
r = math.random(min_duration, max_duration);
|
r = math.random(min_duration, max_duration)
|
||||||
else
|
else
|
||||||
r = math.random(mcl_weather.min_duration, mcl_weather.max_duration);
|
r = math.random(mcl_weather.min_duration, mcl_weather.max_duration)
|
||||||
end
|
end
|
||||||
return minetest.get_gametime() + r
|
return minetest.get_gametime() + r
|
||||||
end
|
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
|
return random_pos_x, random_pos_y, random_pos_z
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local t, wci = 0, mcl_weather.check_interval
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
t = t + dtime
|
||||||
|
if t < wci then return end
|
||||||
|
t = 0
|
||||||
|
|
||||||
if mcl_weather.end_time == nil then
|
if mcl_weather.end_time == nil then
|
||||||
mcl_weather.end_time = mcl_weather.get_rand_end_time()
|
mcl_weather.end_time = mcl_weather.get_rand_end_time()
|
||||||
end
|
end
|
||||||
|
@ -141,7 +146,7 @@ end)
|
||||||
|
|
||||||
-- Sets random weather (which could be 'none' (no weather)).
|
-- Sets random weather (which could be 'none' (no weather)).
|
||||||
mcl_weather.set_random_weather = function(weather_name, weather_meta)
|
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 transitions = weather_meta.transitions
|
||||||
local random_roll = math.random(0,100)
|
local random_roll = math.random(0,100)
|
||||||
local new_weather
|
local new_weather
|
||||||
|
@ -155,17 +160,31 @@ mcl_weather.set_random_weather = function(weather_name, weather_meta)
|
||||||
mcl_weather.change_weather(new_weather)
|
mcl_weather.change_weather(new_weather)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- Change weather to new_weather.
|
-- Change weather to new_weather.
|
||||||
-- * explicit_end_time is OPTIONAL. If specified, explicitly set the
|
-- * explicit_end_time is OPTIONAL. If specified, explicitly set the
|
||||||
-- gametime (minetest.get_gametime) in which the weather ends.
|
-- 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.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
|
if (mcl_weather.state ~= nil and mcl_weather.reg_weathers[mcl_weather.state] ~= nil) then
|
||||||
mcl_weather.reg_weathers[mcl_weather.state].clear()
|
mcl_weather.reg_weathers[mcl_weather.state].clear()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local old_weather = mcl_weather.state
|
||||||
|
|
||||||
mcl_weather.state = new_weather
|
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]
|
local weather_meta = mcl_weather.reg_weathers[mcl_weather.state]
|
||||||
if explicit_end_time then
|
if explicit_end_time then
|
||||||
mcl_weather.end_time = explicit_end_time
|
mcl_weather.end_time = explicit_end_time
|
||||||
|
@ -218,7 +237,7 @@ minetest.register_chatcommand("weather", {
|
||||||
end
|
end
|
||||||
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
|
if success then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
|
@ -234,13 +253,13 @@ minetest.register_chatcommand("toggledownfall", {
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
-- Currently rain/thunder/snow: Set weather to clear
|
-- Currently rain/thunder/snow: Set weather to clear
|
||||||
if mcl_weather.state ~= "none" then
|
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
|
-- Currently clear: Set weather randomly to rain/thunder/snow
|
||||||
else
|
else
|
||||||
local new = { "rain", "thunder", "snow" }
|
local new = { "rain", "thunder", "snow" }
|
||||||
local r = math.random(1, #new)
|
local r = math.random(1, #new)
|
||||||
return mcl_weather.change_weather(new[r])
|
return mcl_weather.change_weather(new[r], nil, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -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)
|
|
@ -6,8 +6,6 @@ local player_in_bed = 0
|
||||||
local is_sp = minetest.is_singleplayer()
|
local is_sp = minetest.is_singleplayer()
|
||||||
local weather_mod = minetest.get_modpath("mcl_weather") ~= nil
|
local weather_mod = minetest.get_modpath("mcl_weather") ~= nil
|
||||||
local explosions_mod = minetest.get_modpath("mcl_explosions") ~= nil
|
local explosions_mod = minetest.get_modpath("mcl_explosions") ~= nil
|
||||||
local huds = {}
|
|
||||||
local hud_hide_timeouts = {}
|
|
||||||
|
|
||||||
-- Helper functions
|
-- Helper functions
|
||||||
|
|
||||||
|
@ -326,8 +324,7 @@ function mcl_beds.on_rightclick(pos, player, is_top)
|
||||||
success, message = lay_down(player, ppos, other)
|
success, message = lay_down(player, ppos, other)
|
||||||
end
|
end
|
||||||
if message then
|
if message then
|
||||||
player:hud_change(huds[name], "text", message)
|
mcl_tmp_message.message(player, message)
|
||||||
hud_hide_timeouts[name] = 3
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lay_down(player, nil, nil, false)
|
lay_down(player, nil, nil, false)
|
||||||
|
@ -355,25 +352,12 @@ minetest.register_on_joinplayer(function(player)
|
||||||
meta:set_string("mcl_beds:sleeping", "false")
|
meta:set_string("mcl_beds:sleeping", "false")
|
||||||
end
|
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, "speed", "mcl_beds:sleeping")
|
||||||
playerphysics.remove_physics_factor(player, "jump", "mcl_beds:sleeping")
|
playerphysics.remove_physics_factor(player, "jump", "mcl_beds:sleeping")
|
||||||
update_formspecs(false)
|
update_formspecs(false)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
local name = player:get_player_name()
|
|
||||||
huds[name] = nil
|
|
||||||
|
|
||||||
local players = minetest.get_connected_players()
|
local players = minetest.get_connected_players()
|
||||||
for n, player in ipairs(players) do
|
for n, player in ipairs(players) do
|
||||||
if player:get_player_name() == name then
|
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)
|
mcl_beds.kick_player(player)
|
||||||
end
|
end
|
||||||
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)
|
|
||||||
|
|
|
@ -390,7 +390,7 @@ minetest.register_node("mcl_flowers:waterlily", {
|
||||||
liquids_pointable = true,
|
liquids_pointable = true,
|
||||||
walkable = true,
|
walkable = true,
|
||||||
sunlight_propagates = 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(),
|
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||||
node_placement_prediction = "",
|
node_placement_prediction = "",
|
||||||
node_box = {
|
node_box = {
|
||||||
|
|
|
@ -54,12 +54,13 @@ schem_path = settlements.modpath.."/schematics/"
|
||||||
--
|
--
|
||||||
schematic_table = {
|
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 = "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 = "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 = "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 = "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 = "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 = "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 = "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"},
|
{name = "well", mts = schem_path.."well.mts", hwidth = 6, hdepth = 8, hheight = 6, hsize = 10, max_num = 0.045, rplc = "n"},
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
mcl_core
|
mcl_core
|
||||||
|
mcl_loot
|
||||||
mcl_farming?
|
mcl_farming?
|
||||||
mobs_mc?
|
mobs_mc?
|
||||||
|
|
|
@ -113,6 +113,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||||
if maxp.y < 0 then return end
|
if maxp.y < 0 then return end
|
||||||
|
|
||||||
-- don't build settlements too close to each other
|
-- don't build settlements too close to each other
|
||||||
|
--[[
|
||||||
local center_of_chunk = {
|
local center_of_chunk = {
|
||||||
x=maxp.x-half_map_chunk_size,
|
x=maxp.x-half_map_chunk_size,
|
||||||
y=maxp.y-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)
|
local dist_ok = settlements.check_distance_other_settlements(center_of_chunk)
|
||||||
if dist_ok == false then return end
|
if dist_ok == false then return end
|
||||||
|
]]
|
||||||
|
|
||||||
-- don't build settlements on (too) uneven terrain
|
-- don't build settlements on (too) uneven terrain
|
||||||
local height_difference = settlements.evaluate_heightmap(minp, maxp)
|
local height_difference = settlements.evaluate_heightmap(minp, maxp)
|
||||||
|
@ -162,7 +164,7 @@ minetest.register_craftitem("mcl_villages:tool", {
|
||||||
-- build ssettlement
|
-- build ssettlement
|
||||||
--
|
--
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local pr = PseudoRandom(math.rand(0,32767))
|
local pr = PseudoRandom(math.random(0,32767))
|
||||||
-- enable debug routines
|
-- enable debug routines
|
||||||
local center_surface = pointed_thing.under
|
local center_surface = pointed_thing.under
|
||||||
if center_surface then
|
if center_surface then
|
||||||
|
@ -213,10 +215,10 @@ minetest.register_craftitem("mcl_villages:tool", {
|
||||||
--
|
--
|
||||||
if settlements.lvm == true then
|
if settlements.lvm == true then
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
settlements.place_schematics_lvm(pr)
|
settlements.place_schematics_lvm(settlement_info, pr)
|
||||||
vm:write_to_map(true)
|
vm:write_to_map(true)
|
||||||
else
|
else
|
||||||
settlements.place_schematics()
|
settlements.place_schematics(settlement_info, pr)
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
Binary file not shown.
Binary file not shown.
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 |
|
@ -1,3 +1,5 @@
|
||||||
|
mcl_villages = {}
|
||||||
|
|
||||||
local c_dirt_with_grass = minetest.get_content_id("mcl_core:dirt_with_grass")
|
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_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")
|
--local c_dirt_with_dry_grass = minetest.get_content_id("mcl_core:dirt_with_dry_grass")
|
||||||
|
@ -206,6 +208,7 @@ end
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- check distance to other settlements
|
-- check distance to other settlements
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
--[[
|
||||||
function settlements.check_distance_other_settlements(center_new_chunk)
|
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
|
for i, pos in ipairs(settlements_in_world) do
|
||||||
|
@ -217,6 +220,7 @@ function settlements.check_distance_other_settlements(center_new_chunk)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- fill chests
|
-- fill chests
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
@ -235,33 +239,38 @@ function settlements.fill_chest(pos, pr)
|
||||||
end
|
end
|
||||||
-- fill chest
|
-- fill chest
|
||||||
local inv = minetest.get_inventory( {type="node", pos=chestpos} )
|
local inv = minetest.get_inventory( {type="node", pos=chestpos} )
|
||||||
-- always
|
function mcl_villages.get_treasures(pr)
|
||||||
inv:add_item("main", "mcl_core:apple "..pr:next(1,3))
|
local loottable = {
|
||||||
-- low value items
|
{
|
||||||
if pr:next(0,1) < 1 then
|
stacks_min = 3,
|
||||||
inv:add_item("main", "mcl_farming:bread "..pr:next(0,3))
|
stacks_max = 8,
|
||||||
inv:add_item("main", "mcl_core:iron_ingot "..pr:next(0,3))
|
items = {
|
||||||
inv:add_item("main", "mcl_farming:melon_item "..pr:next(0,3))
|
{ itemstring = "mcl_core:diamond", weight = 3, amount_min = 1, amount_max = 3 },
|
||||||
inv:add_item("main", "mcl_farming:carrot_item "..pr:next(0,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 },
|
||||||
-- additional fillings when farmin mod enabled
|
{ itemstring = "mcl_farming:bread", weight = 15, amount_min = 1, amount_max = 3 },
|
||||||
if minetest.get_modpath("farming") ~= nil and farming.mod == "redo" then
|
{ itemstring = "mcl_core:apple", weight = 15, amount_min = 1, amount_max = 3 },
|
||||||
if pr:next(0,1) < 1 then
|
{ itemstring = "mcl_tools:pick_iron", weight = 5 },
|
||||||
inv:add_item("main", "mcl_farming:melon_item "..pr:next(0,3))
|
{ itemstring = "mcl_tools:sword_iron", weight = 5 },
|
||||||
inv:add_item("main", "mcl_farming:carrot_item "..pr:next(0,3))
|
{ itemstring = "mcl_armor:chestplate_iron", weight = 5 },
|
||||||
inv:add_item("main", "farming:corn "..pr:next(0,3))
|
{ itemstring = "mcl_armor:helmet_iron", weight = 5 },
|
||||||
end
|
{ itemstring = "mcl_armor:leggings_iron", weight = 5 },
|
||||||
end
|
{ itemstring = "mcl_armor:boots_iron", weight = 5 },
|
||||||
--]]
|
{ itemstring = "mcl_core:obsidian", weight = 5, amount_min = 3, amount_max = 7 },
|
||||||
end
|
{ itemstring = "mcl_core:sapling", weight = 5, amount_min = 3, amount_max = 7 },
|
||||||
-- medium value items
|
{ itemstring = "mcl_mobitems:saddle", weight = 3 },
|
||||||
if pr:next(0,3) < 1 then
|
{ itemstring = "mobs_mc:iron_horse_armor", weight = 1 },
|
||||||
inv:add_item("main", "mcl_tools:pick_iron "..pr:next(0,1))
|
{ itemstring = "mobs_mc:gold_horse_armor", weight = 1 },
|
||||||
inv:add_item("main", "mcl_tools:pick_stone "..pr:next(0,1))
|
{ itemstring = "mobs_mc:diamond_horse_armor", weight = 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))
|
}
|
||||||
|
local items = mcl_loot.get_multi_loot(loottable, pr)
|
||||||
|
return items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local items = mcl_villages.get_treasures(pr)
|
||||||
|
mcl_loot.fill_inventory(inv, "main", items)
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue