Merge branch 'master' of https://git.minetest.land/Wuzzy/MineClone2
This commit is contained in:
commit
8ae233ba36
18 changed files with 477 additions and 428 deletions
|
@ -70,39 +70,31 @@ 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
|
local luaentity = attach:get_luaentity()
|
||||||
detach_player(clicker)
|
if luaentity._driver then
|
||||||
local pos = clicker:get_pos()
|
luaentity._driver = nil
|
||||||
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()
|
|
||||||
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_detach()
|
||||||
clicker:set_attach(self.object, "",
|
clicker:set_properties({visual_size = {x=1, y=1}})
|
||||||
{x = 0, y = 0.42, z = -1}, {x = 0, y = 0, z = 0})
|
end--]]
|
||||||
clicker:set_properties({ visual_size = driver_visual_size })
|
self._driver = clicker
|
||||||
mcl_player.player_attached[name] = true
|
clicker:set_attach(self.object, "",
|
||||||
minetest.after(0.2, function(name)
|
{x = 0, y = 0.42, z = -1}, {x = 0, y = 0, z = 0})
|
||||||
local player = minetest.get_player_by_name(name)
|
clicker:set_properties({ visual_size = driver_visual_size })
|
||||||
if player then
|
mcl_player.player_attached[name] = true
|
||||||
mcl_player.player_set_animation(player, "sit" , 30)
|
minetest.after(0.2, function(name)
|
||||||
end
|
local player = minetest.get_player_by_name(name)
|
||||||
end, name)
|
if player then
|
||||||
clicker:set_look_horizontal(self.object:get_yaw())
|
mcl_player.player_set_animation(player, "sit" , 30)
|
||||||
end
|
end
|
||||||
|
end, name)
|
||||||
|
clicker:set_look_horizontal(self.object:get_yaw())
|
||||||
|
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,10 +1,10 @@
|
||||||
local modpath = minetest.get_modpath("mcl_weather");
|
local modpath = minetest.get_modpath("mcl_weather")
|
||||||
|
|
||||||
mcl_weather = {}
|
mcl_weather = {}
|
||||||
|
|
||||||
-- If not located then embeded skycolor mod version will be loaded.
|
-- If not located then embeded skycolor mod version will be loaded.
|
||||||
if minetest.get_modpath("skycolor") == nil then
|
if minetest.get_modpath("skycolor") == nil then
|
||||||
dofile(modpath.."/skycolor.lua")
|
dofile(modpath.."/skycolor.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
dofile(modpath.."/weather_core.lua")
|
dofile(modpath.."/weather_core.lua")
|
||||||
|
@ -13,5 +13,5 @@ dofile(modpath.."/rain.lua")
|
||||||
dofile(modpath.."/nether_dust.lua")
|
dofile(modpath.."/nether_dust.lua")
|
||||||
|
|
||||||
if minetest.get_modpath("lightning") ~= nil then
|
if minetest.get_modpath("lightning") ~= nil then
|
||||||
dofile(modpath.."/thunder.lua")
|
dofile(modpath.."/thunder.lua")
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -2,198 +2,198 @@ local PARTICLES_COUNT_RAIN = 30
|
||||||
local PARTICLES_COUNT_THUNDER = 45
|
local PARTICLES_COUNT_THUNDER = 45
|
||||||
|
|
||||||
mcl_weather.rain = {
|
mcl_weather.rain = {
|
||||||
-- max rain particles created at time
|
-- max rain particles created at time
|
||||||
particles_count = PARTICLES_COUNT_RAIN,
|
particles_count = PARTICLES_COUNT_RAIN,
|
||||||
|
|
||||||
-- flag to turn on/off extinguish fire for rain
|
-- flag to turn on/off extinguish fire for rain
|
||||||
extinguish_fire = true,
|
extinguish_fire = true,
|
||||||
|
|
||||||
-- flag useful when mixing weathers
|
-- flag useful when mixing weathers
|
||||||
raining = false,
|
raining = false,
|
||||||
|
|
||||||
-- keeping last timeofday value (rounded).
|
-- keeping last timeofday value (rounded).
|
||||||
-- Defaulted to non-existing value for initial comparing.
|
-- Defaulted to non-existing value for initial comparing.
|
||||||
sky_last_update = -1,
|
sky_last_update = -1,
|
||||||
|
|
||||||
init_done = false,
|
init_done = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
mcl_weather.rain.sound_handler = function(player)
|
mcl_weather.rain.sound_handler = function(player)
|
||||||
return minetest.sound_play("weather_rain", {
|
return minetest.sound_play("weather_rain", {
|
||||||
to_player = player:get_player_name(),
|
to_player = player:get_player_name(),
|
||||||
loop = true,
|
loop = true,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set skybox based on time (uses skycolor api)
|
-- set skybox based on time (uses skycolor api)
|
||||||
mcl_weather.rain.set_sky_box = function()
|
mcl_weather.rain.set_sky_box = function()
|
||||||
if mcl_weather.state == "rain" then
|
if mcl_weather.state == "rain" then
|
||||||
mcl_weather.skycolor.add_layer(
|
mcl_weather.skycolor.add_layer(
|
||||||
"weather-pack-rain-sky",
|
"weather-pack-rain-sky",
|
||||||
{{r=0, g=0, b=0},
|
{{r=0, g=0, b=0},
|
||||||
{r=85, g=86, b=98},
|
{r=85, g=86, b=98},
|
||||||
{r=135, g=135, b=151},
|
{r=135, g=135, b=151},
|
||||||
{r=85, g=86, b=98},
|
{r=85, g=86, b=98},
|
||||||
{r=0, g=0, b=0}})
|
{r=0, g=0, b=0}})
|
||||||
mcl_weather.skycolor.active = true
|
mcl_weather.skycolor.active = true
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
player:set_clouds({color="#5D5D5FE8"})
|
player:set_clouds({color="#5D5D5FE8"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- creating manually parctiles instead of particles spawner because of easier to control
|
-- creating manually parctiles instead of particles spawner because of easier to control
|
||||||
-- spawn position.
|
-- spawn position.
|
||||||
mcl_weather.rain.add_rain_particles = function(player)
|
mcl_weather.rain.add_rain_particles = function(player)
|
||||||
|
|
||||||
mcl_weather.rain.last_rp_count = 0
|
mcl_weather.rain.last_rp_count = 0
|
||||||
for i=mcl_weather.rain.particles_count, 1,-1 do
|
for i=mcl_weather.rain.particles_count, 1,-1 do
|
||||||
local random_pos_x, random_pos_y, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player)
|
local random_pos_x, random_pos_y, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player)
|
||||||
if mcl_weather.is_outdoor({x=random_pos_x, y=random_pos_y, z=random_pos_z}) then
|
if mcl_weather.is_outdoor({x=random_pos_x, y=random_pos_y, z=random_pos_z}) then
|
||||||
mcl_weather.rain.last_rp_count = mcl_weather.rain.last_rp_count + 1
|
mcl_weather.rain.last_rp_count = mcl_weather.rain.last_rp_count + 1
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z},
|
pos = {x=random_pos_x, y=random_pos_y, z=random_pos_z},
|
||||||
velocity = {x=0, y=-10, z=0},
|
velocity = {x=0, y=-10, z=0},
|
||||||
acceleration = {x=0, y=-30, z=0},
|
acceleration = {x=0, y=-30, z=0},
|
||||||
expirationtime = 1.0,
|
expirationtime = 1.0,
|
||||||
size = math.random(0.5, 3),
|
size = math.random(0.5, 3),
|
||||||
collisiondetection = true,
|
collisiondetection = true,
|
||||||
collision_removal = true,
|
collision_removal = true,
|
||||||
vertical = true,
|
vertical = true,
|
||||||
texture = mcl_weather.rain.get_texture(),
|
texture = mcl_weather.rain.get_texture(),
|
||||||
playername = player:get_player_name()
|
playername = player:get_player_name()
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Simple random texture getter
|
-- Simple random texture getter
|
||||||
mcl_weather.rain.get_texture = function()
|
mcl_weather.rain.get_texture = function()
|
||||||
local texture_name
|
local texture_name
|
||||||
local random_number = math.random()
|
local random_number = math.random()
|
||||||
if random_number > 0.33 then
|
if random_number > 0.33 then
|
||||||
texture_name = "weather_pack_rain_raindrop_1.png"
|
texture_name = "weather_pack_rain_raindrop_1.png"
|
||||||
elseif random_number > 0.66 then
|
elseif random_number > 0.66 then
|
||||||
texture_name = "weather_pack_rain_raindrop_2.png"
|
texture_name = "weather_pack_rain_raindrop_2.png"
|
||||||
else
|
else
|
||||||
texture_name = "weather_pack_rain_raindrop_3.png"
|
texture_name = "weather_pack_rain_raindrop_3.png"
|
||||||
end
|
end
|
||||||
return texture_name;
|
return texture_name;
|
||||||
end
|
end
|
||||||
|
|
||||||
-- register player for rain weather.
|
-- register player for rain weather.
|
||||||
-- basically needs for origin sky reference and rain sound controls.
|
-- basically needs for origin sky reference and rain sound controls.
|
||||||
mcl_weather.rain.add_player = function(player)
|
mcl_weather.rain.add_player = function(player)
|
||||||
if mcl_weather.players[player:get_player_name()] == nil then
|
if mcl_weather.players[player:get_player_name()] == nil then
|
||||||
local player_meta = {}
|
local player_meta = {}
|
||||||
player_meta.origin_sky = {player:get_sky()}
|
player_meta.origin_sky = {player:get_sky()}
|
||||||
mcl_weather.players[player:get_player_name()] = player_meta
|
mcl_weather.players[player:get_player_name()] = player_meta
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- remove player from player list effected by rain.
|
-- remove player from player list effected by rain.
|
||||||
-- be sure to remove sound before removing player otherwise soundhandler reference will be lost.
|
-- be sure to remove sound before removing player otherwise soundhandler reference will be lost.
|
||||||
mcl_weather.rain.remove_player = function(player)
|
mcl_weather.rain.remove_player = function(player)
|
||||||
local player_meta = mcl_weather.players[player:get_player_name()]
|
local player_meta = mcl_weather.players[player:get_player_name()]
|
||||||
if player_meta ~= nil and player_meta.origin_sky ~= nil then
|
if player_meta ~= nil and player_meta.origin_sky ~= nil then
|
||||||
player:set_clouds({color="#FFF0F0E5"})
|
player:set_clouds({color="#FFF0F0E5"})
|
||||||
mcl_weather.players[player:get_player_name()] = nil
|
mcl_weather.players[player:get_player_name()] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_worlds.register_on_dimension_change(function(player, dimension)
|
mcl_worlds.register_on_dimension_change(function(player, dimension)
|
||||||
if dimension ~= "overworld" and dimension ~= "void" then
|
if dimension ~= "overworld" and dimension ~= "void" then
|
||||||
mcl_weather.rain.remove_sound(player)
|
mcl_weather.rain.remove_sound(player)
|
||||||
mcl_weather.rain.remove_player(player)
|
mcl_weather.rain.remove_player(player)
|
||||||
elseif dimension == "overworld" then
|
elseif dimension == "overworld" then
|
||||||
mcl_weather.rain.update_sound(player)
|
mcl_weather.rain.update_sound(player)
|
||||||
if mcl_weather.rain.raining then
|
if mcl_weather.rain.raining then
|
||||||
mcl_weather.rain.add_rain_particles(player)
|
mcl_weather.rain.add_rain_particles(player)
|
||||||
mcl_weather.rain.add_player(player)
|
mcl_weather.rain.add_player(player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- adds and removes rain sound depending how much rain particles around player currently exist.
|
-- adds and removes rain sound depending how much rain particles around player currently exist.
|
||||||
-- have few seconds delay before each check to avoid on/off sound too often
|
-- have few seconds delay before each check to avoid on/off sound too often
|
||||||
-- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance.
|
-- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance.
|
||||||
mcl_weather.rain.update_sound = function(player)
|
mcl_weather.rain.update_sound = function(player)
|
||||||
local player_meta = mcl_weather.players[player:get_player_name()]
|
local player_meta = mcl_weather.players[player:get_player_name()]
|
||||||
if player_meta ~= nil then
|
if player_meta ~= nil then
|
||||||
if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > minetest.get_gametime() then
|
if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > minetest.get_gametime() then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if player_meta.sound_handler ~= nil then
|
if player_meta.sound_handler ~= nil then
|
||||||
if mcl_weather.rain.last_rp_count == 0 then
|
if mcl_weather.rain.last_rp_count == 0 then
|
||||||
minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0)
|
minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0)
|
||||||
player_meta.sound_handler = nil
|
player_meta.sound_handler = nil
|
||||||
end
|
end
|
||||||
elseif mcl_weather.rain.last_rp_count > 0 then
|
elseif mcl_weather.rain.last_rp_count > 0 then
|
||||||
player_meta.sound_handler = mcl_weather.rain.sound_handler(player)
|
player_meta.sound_handler = mcl_weather.rain.sound_handler(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
player_meta.sound_updated = minetest.get_gametime()
|
player_meta.sound_updated = minetest.get_gametime()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- rain sound removed from player.
|
-- rain sound removed from player.
|
||||||
mcl_weather.rain.remove_sound = function(player)
|
mcl_weather.rain.remove_sound = function(player)
|
||||||
local player_meta = mcl_weather.players[player:get_player_name()]
|
local player_meta = mcl_weather.players[player:get_player_name()]
|
||||||
if player_meta ~= nil and player_meta.sound_handler ~= nil then
|
if player_meta ~= nil and player_meta.sound_handler ~= nil then
|
||||||
minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0)
|
minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0)
|
||||||
player_meta.sound_handler = nil
|
player_meta.sound_handler = nil
|
||||||
player_meta.sound_updated = nil
|
player_meta.sound_updated = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- callback function for removing rain
|
-- callback function for removing rain
|
||||||
mcl_weather.rain.clear = function()
|
mcl_weather.rain.clear = function()
|
||||||
mcl_weather.rain.raining = false
|
mcl_weather.rain.raining = false
|
||||||
mcl_weather.rain.sky_last_update = -1
|
mcl_weather.rain.sky_last_update = -1
|
||||||
mcl_weather.rain.init_done = false
|
mcl_weather.rain.init_done = false
|
||||||
mcl_weather.rain.set_particles_mode("rain")
|
mcl_weather.rain.set_particles_mode("rain")
|
||||||
mcl_weather.skycolor.remove_layer("weather-pack-rain-sky")
|
mcl_weather.skycolor.remove_layer("weather-pack-rain-sky")
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
mcl_weather.rain.remove_sound(player)
|
mcl_weather.rain.remove_sound(player)
|
||||||
mcl_weather.rain.remove_player(player)
|
mcl_weather.rain.remove_player(player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
if mcl_weather.state ~= "rain" then
|
if mcl_weather.state ~= "rain" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_weather.rain.make_weather()
|
mcl_weather.rain.make_weather()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
mcl_weather.rain.make_weather = function()
|
mcl_weather.rain.make_weather = function()
|
||||||
if mcl_weather.rain.init_done == false then
|
if mcl_weather.rain.init_done == false then
|
||||||
mcl_weather.rain.raining = true
|
mcl_weather.rain.raining = true
|
||||||
mcl_weather.rain.set_sky_box()
|
mcl_weather.rain.set_sky_box()
|
||||||
mcl_weather.rain.set_particles_mode(mcl_weather.mode)
|
mcl_weather.rain.set_particles_mode(mcl_weather.mode)
|
||||||
mcl_weather.rain.init_done = true
|
mcl_weather.rain.init_done = true
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then
|
if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then
|
||||||
mcl_weather.rain.remove_sound(player)
|
mcl_weather.rain.remove_sound(player)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
mcl_weather.rain.add_player(player)
|
mcl_weather.rain.add_player(player)
|
||||||
mcl_weather.rain.add_rain_particles(player)
|
mcl_weather.rain.add_rain_particles(player)
|
||||||
mcl_weather.rain.update_sound(player)
|
mcl_weather.rain.update_sound(player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Switch the number of raindrops: "thunder" for many raindrops, otherwise for normal raindrops
|
-- Switch the number of raindrops: "thunder" for many raindrops, otherwise for normal raindrops
|
||||||
mcl_weather.rain.set_particles_mode = function(mode)
|
mcl_weather.rain.set_particles_mode = function(mode)
|
||||||
if mode == "thunder" then
|
if mode == "thunder" then
|
||||||
mcl_weather.rain.particles_count = PARTICLES_COUNT_THUNDER
|
mcl_weather.rain.particles_count = PARTICLES_COUNT_THUNDER
|
||||||
else
|
else
|
||||||
mcl_weather.rain.particles_count = PARTICLES_COUNT_RAIN
|
mcl_weather.rain.particles_count = PARTICLES_COUNT_RAIN
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if mcl_weather.allow_abm then
|
if mcl_weather.allow_abm then
|
||||||
|
@ -266,16 +266,16 @@ if mcl_weather.allow_abm then
|
||||||
end
|
end
|
||||||
|
|
||||||
if mcl_weather.reg_weathers.rain == nil then
|
if mcl_weather.reg_weathers.rain == nil then
|
||||||
mcl_weather.reg_weathers.rain = {
|
mcl_weather.reg_weathers.rain = {
|
||||||
clear = mcl_weather.rain.clear,
|
clear = mcl_weather.rain.clear,
|
||||||
light_factor = 0.6,
|
light_factor = 0.6,
|
||||||
-- 10min - 20min
|
-- 10min - 20min
|
||||||
min_duration = 600,
|
min_duration = 600,
|
||||||
max_duration = 1200,
|
max_duration = 1200,
|
||||||
transitions = {
|
transitions = {
|
||||||
[65] = "none",
|
[65] = "none",
|
||||||
[70] = "snow",
|
[70] = "snow",
|
||||||
[100] = "thunder",
|
[100] = "thunder",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -81,17 +81,16 @@ end)
|
||||||
|
|
||||||
-- register snow weather
|
-- register snow weather
|
||||||
if mcl_weather.reg_weathers.snow == nil then
|
if mcl_weather.reg_weathers.snow == nil then
|
||||||
mcl_weather.reg_weathers.snow = {
|
mcl_weather.reg_weathers.snow = {
|
||||||
clear = mcl_weather.snow.clear,
|
clear = mcl_weather.snow.clear,
|
||||||
light_factor = 0.6,
|
light_factor = 0.6,
|
||||||
-- 10min - 20min
|
-- 10min - 20min
|
||||||
min_duration = 600,
|
min_duration = 600,
|
||||||
max_duration = 1200,
|
max_duration = 1200,
|
||||||
transitions = {
|
transitions = {
|
||||||
[65] = "none",
|
[65] = "none",
|
||||||
[80] = "rain",
|
[80] = "rain",
|
||||||
[100] = "thunder",
|
[100] = "thunder",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
||||||
|
@ -25,14 +25,14 @@ mcl_weather.reg_weathers = {}
|
||||||
mcl_weather.allow_abm = true
|
mcl_weather.allow_abm = true
|
||||||
|
|
||||||
mcl_weather.reg_weathers["none"] = {
|
mcl_weather.reg_weathers["none"] = {
|
||||||
min_duration = mcl_weather.min_duration,
|
min_duration = mcl_weather.min_duration,
|
||||||
max_duration = mcl_weather.max_duration,
|
max_duration = mcl_weather.max_duration,
|
||||||
light_factor = nil,
|
light_factor = nil,
|
||||||
transitions = {
|
transitions = {
|
||||||
[50] = "rain",
|
[50] = "rain",
|
||||||
[100] = "snow",
|
[100] = "snow",
|
||||||
},
|
},
|
||||||
clear = function() end,
|
clear = function() end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local storage = minetest.get_mod_storage()
|
local storage = minetest.get_mod_storage()
|
||||||
|
@ -45,211 +45,230 @@ end
|
||||||
minetest.register_on_shutdown(save_weather)
|
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
|
||||||
|
|
||||||
mcl_weather.get_current_light_factor = function()
|
mcl_weather.get_current_light_factor = function()
|
||||||
if mcl_weather.state == "none" then
|
if mcl_weather.state == "none" then
|
||||||
return nil
|
return nil
|
||||||
else
|
else
|
||||||
return mcl_weather.reg_weathers[mcl_weather.state].light_factor
|
return mcl_weather.reg_weathers[mcl_weather.state].light_factor
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns true if pos is outdoor.
|
-- Returns true if pos is outdoor.
|
||||||
-- Outdoor is defined as any node in the Overworld under open sky.
|
-- Outdoor is defined as any node in the Overworld under open sky.
|
||||||
-- FIXME: Nodes below glass also count as “outdoor”, this should not be the case.
|
-- FIXME: Nodes below glass also count as “outdoor”, this should not be the case.
|
||||||
mcl_weather.is_outdoor = function(pos)
|
mcl_weather.is_outdoor = function(pos)
|
||||||
local cpos = {x=pos.x, y=pos.y+1, z=pos.z}
|
local cpos = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
local dim = mcl_worlds.pos_to_dimension(cpos)
|
local dim = mcl_worlds.pos_to_dimension(cpos)
|
||||||
if minetest.get_node_light(cpos, 0.5) == 15 and dim == "overworld" then
|
if minetest.get_node_light(cpos, 0.5) == 15 and dim == "overworld" then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- checks if player is undewater. This is needed in order to
|
-- checks if player is undewater. This is needed in order to
|
||||||
-- turn off weather particles generation.
|
-- turn off weather particles generation.
|
||||||
mcl_weather.is_underwater = function(player)
|
mcl_weather.is_underwater = function(player)
|
||||||
local ppos = player:get_pos()
|
local ppos = player:get_pos()
|
||||||
local offset = player:get_eye_offset()
|
local offset = player:get_eye_offset()
|
||||||
local player_eye_pos = {x = ppos.x + offset.x,
|
local player_eye_pos = {x = ppos.x + offset.x,
|
||||||
y = ppos.y + offset.y + 1.5,
|
y = ppos.y + offset.y + 1.5,
|
||||||
z = ppos.z + offset.z}
|
z = ppos.z + offset.z}
|
||||||
local node_level = minetest.get_node_level(player_eye_pos)
|
local node_level = minetest.get_node_level(player_eye_pos)
|
||||||
if node_level == 8 or node_level == 7 then
|
if node_level == 8 or node_level == 7 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- trying to locate position for particles by player look direction for performance reason.
|
-- trying to locate position for particles by player look direction for performance reason.
|
||||||
-- it is costly to generate many particles around player so goal is focus mainly on front view.
|
-- it is costly to generate many particles around player so goal is focus mainly on front view.
|
||||||
mcl_weather.get_random_pos_by_player_look_dir = function(player)
|
mcl_weather.get_random_pos_by_player_look_dir = function(player)
|
||||||
local look_dir = player:get_look_dir()
|
local look_dir = player:get_look_dir()
|
||||||
local player_pos = player:get_pos()
|
local player_pos = player:get_pos()
|
||||||
|
|
||||||
local random_pos_x = 0
|
local random_pos_x = 0
|
||||||
local random_pos_y = 0
|
local random_pos_y = 0
|
||||||
local random_pos_z = 0
|
local random_pos_z = 0
|
||||||
|
|
||||||
if look_dir.x > 0 then
|
if look_dir.x > 0 then
|
||||||
if look_dir.z > 0 then
|
if look_dir.z > 0 then
|
||||||
random_pos_x = math.random() + math.random(player_pos.x - 2.5, player_pos.x + 5)
|
random_pos_x = math.random() + math.random(player_pos.x - 2.5, player_pos.x + 5)
|
||||||
random_pos_z = math.random() + math.random(player_pos.z - 2.5, player_pos.z + 5)
|
random_pos_z = math.random() + math.random(player_pos.z - 2.5, player_pos.z + 5)
|
||||||
else
|
else
|
||||||
random_pos_x = math.random() + math.random(player_pos.x - 2.5, player_pos.x + 5)
|
random_pos_x = math.random() + math.random(player_pos.x - 2.5, player_pos.x + 5)
|
||||||
random_pos_z = math.random() + math.random(player_pos.z - 5, player_pos.z + 2.5)
|
random_pos_z = math.random() + math.random(player_pos.z - 5, player_pos.z + 2.5)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if look_dir.z > 0 then
|
if look_dir.z > 0 then
|
||||||
random_pos_x = math.random() + math.random(player_pos.x - 5, player_pos.x + 2.5)
|
random_pos_x = math.random() + math.random(player_pos.x - 5, player_pos.x + 2.5)
|
||||||
random_pos_z = math.random() + math.random(player_pos.z - 2.5, player_pos.z + 5)
|
random_pos_z = math.random() + math.random(player_pos.z - 2.5, player_pos.z + 5)
|
||||||
else
|
else
|
||||||
random_pos_x = math.random() + math.random(player_pos.x - 5, player_pos.x + 2.5)
|
random_pos_x = math.random() + math.random(player_pos.x - 5, player_pos.x + 2.5)
|
||||||
random_pos_z = math.random() + math.random(player_pos.z - 5, player_pos.z + 2.5)
|
random_pos_z = math.random() + math.random(player_pos.z - 5, player_pos.z + 2.5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
random_pos_y = math.random() + math.random(player_pos.y + 10, player_pos.y + 15)
|
random_pos_y = math.random() + math.random(player_pos.y + 10, player_pos.y + 15)
|
||||||
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)
|
||||||
if mcl_weather.end_time == nil then
|
t = t + dtime
|
||||||
mcl_weather.end_time = mcl_weather.get_rand_end_time()
|
if t < wci then return end
|
||||||
end
|
t = 0
|
||||||
-- recalculate weather
|
|
||||||
if mcl_weather.end_time <= minetest.get_gametime() then
|
if mcl_weather.end_time == nil then
|
||||||
local changeWeather = minetest.settings:get_bool("mcl_doWeatherCycle")
|
mcl_weather.end_time = mcl_weather.get_rand_end_time()
|
||||||
if changeWeather == nil then
|
end
|
||||||
changeWeather = true
|
-- recalculate weather
|
||||||
end
|
if mcl_weather.end_time <= minetest.get_gametime() then
|
||||||
if changeWeather then
|
local changeWeather = minetest.settings:get_bool("mcl_doWeatherCycle")
|
||||||
mcl_weather.set_random_weather(mcl_weather.state, mcl_weather.reg_weathers[mcl_weather.state])
|
if changeWeather == nil then
|
||||||
else
|
changeWeather = true
|
||||||
mcl_weather.end_time = mcl_weather.get_rand_end_time()
|
end
|
||||||
end
|
if changeWeather then
|
||||||
end
|
mcl_weather.set_random_weather(mcl_weather.state, mcl_weather.reg_weathers[mcl_weather.state])
|
||||||
|
else
|
||||||
|
mcl_weather.end_time = mcl_weather.get_rand_end_time()
|
||||||
|
end
|
||||||
|
end
|
||||||
end)
|
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
|
||||||
for v, weather in pairs(transitions) do
|
for v, weather in pairs(transitions) do
|
||||||
if random_roll < v then
|
if random_roll < v then
|
||||||
new_weather = weather
|
new_weather = weather
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if new_weather then
|
if new_weather then
|
||||||
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.
|
||||||
if (mcl_weather.reg_weathers ~= nil and mcl_weather.reg_weathers[new_weather] ~= nil) then
|
mcl_weather.change_weather = function(new_weather, explicit_end_time, changer_name)
|
||||||
if (mcl_weather.state ~= nil and mcl_weather.reg_weathers[mcl_weather.state] ~= nil) then
|
local changer_name = changer_name or debug.getinfo(2).name.."()"
|
||||||
mcl_weather.reg_weathers[mcl_weather.state].clear()
|
|
||||||
end
|
if (mcl_weather.reg_weathers ~= nil and mcl_weather.reg_weathers[new_weather] ~= nil) then
|
||||||
mcl_weather.state = new_weather
|
if (mcl_weather.state ~= nil and mcl_weather.reg_weathers[mcl_weather.state] ~= nil) then
|
||||||
local weather_meta = mcl_weather.reg_weathers[mcl_weather.state]
|
mcl_weather.reg_weathers[mcl_weather.state].clear()
|
||||||
if explicit_end_time then
|
end
|
||||||
mcl_weather.end_time = explicit_end_time
|
|
||||||
else
|
local old_weather = mcl_weather.state
|
||||||
mcl_weather.end_time = mcl_weather.get_rand_end_time(weather_meta.min_duration, weather_meta.max_duration)
|
|
||||||
end
|
mcl_weather.state = new_weather
|
||||||
mcl_weather.skycolor.update_sky_color()
|
|
||||||
save_weather()
|
if old_weather == "none" then
|
||||||
return true
|
old_weather = "clear"
|
||||||
end
|
end
|
||||||
return false
|
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
|
||||||
|
else
|
||||||
|
mcl_weather.end_time = mcl_weather.get_rand_end_time(weather_meta.min_duration, weather_meta.max_duration)
|
||||||
|
end
|
||||||
|
mcl_weather.skycolor.update_sky_color()
|
||||||
|
save_weather()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_weather.get_weather = function()
|
mcl_weather.get_weather = function()
|
||||||
return mcl_weather.state
|
return mcl_weather.state
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_privilege("weather_manager", {
|
minetest.register_privilege("weather_manager", {
|
||||||
description = S("Gives ability to control weather"),
|
description = S("Gives ability to control weather"),
|
||||||
give_to_singleplayer = false
|
give_to_singleplayer = false
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Weather command definition. Set
|
-- Weather command definition. Set
|
||||||
minetest.register_chatcommand("weather", {
|
minetest.register_chatcommand("weather", {
|
||||||
params = "(clear | rain | snow | thunder) [<duration>]",
|
params = "(clear | rain | snow | thunder) [<duration>]",
|
||||||
description = S("Changes the weather to the specified parameter."),
|
description = S("Changes the weather to the specified parameter."),
|
||||||
privs = {weather_manager = true},
|
privs = {weather_manager = true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if (param == "") then
|
if (param == "") then
|
||||||
return false, S("Error: No weather specified.")
|
return false, S("Error: No weather specified.")
|
||||||
end
|
end
|
||||||
local new_weather, end_time
|
local new_weather, end_time
|
||||||
local parse1, parse2 = string.match(param, "(%w+) ?(%d*)")
|
local parse1, parse2 = string.match(param, "(%w+) ?(%d*)")
|
||||||
if parse1 then
|
if parse1 then
|
||||||
if parse1 == "clear" then
|
if parse1 == "clear" then
|
||||||
new_weather = "none"
|
new_weather = "none"
|
||||||
else
|
else
|
||||||
new_weather = parse1
|
new_weather = parse1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return false, S("Error: Invalid parameters.")
|
return false, S("Error: Invalid parameters.")
|
||||||
end
|
end
|
||||||
if parse2 then
|
if parse2 then
|
||||||
if type(tonumber(parse2)) == "number" then
|
if type(tonumber(parse2)) == "number" then
|
||||||
local duration = tonumber(parse2)
|
local duration = tonumber(parse2)
|
||||||
if duration < 1 then
|
if duration < 1 then
|
||||||
return false, S("Error: Duration can't be less than 1 second.")
|
return false, S("Error: Duration can't be less than 1 second.")
|
||||||
end
|
end
|
||||||
end_time = minetest.get_gametime() + duration
|
end_time = minetest.get_gametime() + duration
|
||||||
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
|
||||||
return false, S("Error: Invalid weather specified. Use “clear”, “rain”, “snow” or “thunder”.")
|
return false, S("Error: Invalid weather specified. Use “clear”, “rain”, “snow” or “thunder”.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("toggledownfall", {
|
minetest.register_chatcommand("toggledownfall", {
|
||||||
params = "",
|
params = "",
|
||||||
description = S("Toggles between clear weather and weather with downfall (randomly rain, thunderstorm or snow)"),
|
description = S("Toggles between clear weather and weather with downfall (randomly rain, thunderstorm or snow)"),
|
||||||
privs = {weather_manager = true},
|
privs = {weather_manager = true},
|
||||||
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
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Configuration setting which allows user to disable ABM for weathers (if they use it).
|
-- Configuration setting which allows user to disable ABM for weathers (if they use it).
|
||||||
-- Weather mods expected to be use this flag before registering ABM.
|
-- Weather mods expected to be use this flag before registering ABM.
|
||||||
local weather_allow_abm = minetest.settings:get_bool("weather_allow_abm")
|
local weather_allow_abm = minetest.settings:get_bool("weather_allow_abm")
|
||||||
if weather_allow_abm ~= nil and weather_allow_abm == false then
|
if weather_allow_abm ~= nil and weather_allow_abm == false then
|
||||||
mcl_weather.allow_abm = false
|
mcl_weather.allow_abm = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
44
mods/HUD/mcl_tmp_message/init.lua
Normal file
44
mods/HUD/mcl_tmp_message/init.lua
Normal 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)
|
|
@ -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.
BIN
mods/MAPGEN/mcl_villages/schematics/butcher.mts
Normal file
BIN
mods/MAPGEN/mcl_villages/schematics/butcher.mts
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 2 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,17 +208,19 @@ 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
|
||||||
local distance = vector.distance(center_new_chunk, pos)
|
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
|
if distance < settlements.min_dist_settlements then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
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))
|
}
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
Reference in a new issue