forked from mtcontrib/regional_weather
Update to new wind system, make puddles rotational, change hail conditions
This commit is contained in:
parent
e874daa894
commit
2d289abbd1
@ -2,6 +2,16 @@ local BLOCK_PREFIX = "regional_weather:puddle_"
|
|||||||
local VARIANT_COUNT = 39
|
local VARIANT_COUNT = 39
|
||||||
local MIN_DISTANCE = 4
|
local MIN_DISTANCE = 4
|
||||||
|
|
||||||
|
local GROUND_COVERS = {
|
||||||
|
"group:soil",
|
||||||
|
"group:stone",
|
||||||
|
"group:sand",
|
||||||
|
"group:wood",
|
||||||
|
"default:permafrost",
|
||||||
|
"default:permafrost_with_moss",
|
||||||
|
"default:permafrost_with_stones"
|
||||||
|
}
|
||||||
|
|
||||||
if not regional_weather.settings.puddles then
|
if not regional_weather.settings.puddles then
|
||||||
for i=1,VARIANT_COUNT do
|
for i=1,VARIANT_COUNT do
|
||||||
for r=0,270,90 do
|
for r=0,270,90 do
|
||||||
@ -17,21 +27,14 @@ local node_box = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i = 1,VARIANT_COUNT do
|
for i = 1,VARIANT_COUNT do
|
||||||
for rotation = 0,270,90 do
|
|
||||||
for flip = 0,1 do
|
for flip = 0,1 do
|
||||||
local name = BLOCK_PREFIX .. i .. "_" .. rotation
|
local name = BLOCK_PREFIX .. i
|
||||||
local index = i
|
local index = i
|
||||||
if i < 10 then index = "0" .. i end
|
if i < 10 then index = "0" .. i end
|
||||||
local texture = "weather_puddle_" .. index .. ".png^[opacity:128"
|
local texture = "weather_puddle_" .. index .. ".png^[opacity:128"
|
||||||
if flip == 1 or rotation > 0 then
|
|
||||||
texture = texture .. "^[transform"
|
|
||||||
end
|
|
||||||
if flip == 1 then
|
if flip == 1 then
|
||||||
name = name .. "_flipped"
|
name = name .. "_flipped"
|
||||||
texture = texture .. "FX"
|
texture = texture .. "^[transformFX"
|
||||||
end
|
|
||||||
if rotation > 0 then
|
|
||||||
texture = texture .. "R" .. rotation
|
|
||||||
end
|
end
|
||||||
minetest.register_node(name, {
|
minetest.register_node(name, {
|
||||||
tiles = { texture },
|
tiles = { texture },
|
||||||
@ -42,6 +45,7 @@ for i = 1,VARIANT_COUNT do
|
|||||||
walkable = false,
|
walkable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = true,
|
||||||
node_box = node_box,
|
node_box = node_box,
|
||||||
groups = {
|
groups = {
|
||||||
@ -51,7 +55,7 @@ for i = 1,VARIANT_COUNT do
|
|||||||
slippery = 1,
|
slippery = 1,
|
||||||
flora = 1,
|
flora = 1,
|
||||||
water = 1,
|
water = 1,
|
||||||
regional_weather_puddle = 1
|
weather_puddle = 1
|
||||||
},
|
},
|
||||||
drop = "",
|
drop = "",
|
||||||
sounds = {
|
sounds = {
|
||||||
@ -62,29 +66,29 @@ for i = 1,VARIANT_COUNT do
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_alias("regional_weather:puddle", BLOCK_PREFIX .. "14_0")
|
minetest.register_alias("regional_weather:puddle", BLOCK_PREFIX .. "14")
|
||||||
|
|
||||||
local function get_random_puddle()
|
local function get_random_puddle()
|
||||||
local index = math.random(1, VARIANT_COUNT)
|
local index = math.random(1, VARIANT_COUNT)
|
||||||
local rotation = math.random(0, 3) * 90
|
local rotation = math.random(0, 3) * 90
|
||||||
local flip = math.random(0, 1)
|
local flip = math.random(0, 1)
|
||||||
local name = BLOCK_PREFIX .. index .. "_" .. rotation
|
local name = BLOCK_PREFIX .. index
|
||||||
if flip == 1 then
|
if flip == 1 then
|
||||||
name = name .. "_flipped"
|
name = name .. "_flipped"
|
||||||
end
|
end
|
||||||
return name
|
local param2 = minetest.dir_to_facedir(minetest.yaw_to_dir(rotation))
|
||||||
|
return { name = name, param2 = param2 }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Makes Puddles when raining
|
-- Makes Puddles when raining
|
||||||
climate_api.register_abm({
|
climate_api.register_abm({
|
||||||
label = "create rain puddles",
|
label = "create rain puddles",
|
||||||
nodenames = { "group:soil", "group:stone" },
|
nodenames = GROUND_COVERS,
|
||||||
neighbors = { "air" },
|
neighbors = { "air" },
|
||||||
interval = 15,
|
interval = 8,
|
||||||
chance = 50,
|
chance = 150,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
|
|
||||||
conditions = {
|
conditions = {
|
||||||
@ -101,9 +105,8 @@ climate_api.register_abm({
|
|||||||
|
|
||||||
action = function (pos, node, env)
|
action = function (pos, node, env)
|
||||||
if minetest.get_node(pos).name ~= "air" then return end
|
if minetest.get_node(pos).name ~= "air" then return end
|
||||||
if minetest.find_node_near(pos, MIN_DISTANCE, "group:regional_weather_puddle") then return end
|
if minetest.find_node_near(pos, MIN_DISTANCE, "group:weather_puddle") then return end
|
||||||
local puddle_name = get_random_puddle()
|
minetest.set_node(pos, get_random_puddle())
|
||||||
minetest.set_node(pos, {name = puddle_name})
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local name = "regional_weather:ambient"
|
local name = "regional_weather:ambient"
|
||||||
local CLOUD_SPEED = 1.8
|
|
||||||
|
|
||||||
local conditions = {}
|
local conditions = {}
|
||||||
|
|
||||||
@ -15,14 +14,16 @@ end
|
|||||||
|
|
||||||
local function generate_effects(params)
|
local function generate_effects(params)
|
||||||
local override = {}
|
local override = {}
|
||||||
local wind = climate_api.environment.get_wind()
|
|
||||||
|
local cloud_height = calc_cloud_height(params.heat, params.humidity, params.dewpoint)
|
||||||
|
local wind = climate_api.environment.get_wind({ x = 0, y = cloud_height, z = 0 })
|
||||||
|
|
||||||
local skybox = {priority = 10}
|
local skybox = {priority = 10}
|
||||||
skybox.cloud_data = {
|
skybox.cloud_data = {
|
||||||
density = climate_api.utility.rangelim(params.humidity / 100, 0.15, 0.65),
|
density = climate_api.utility.rangelim(params.humidity / 100, 0.15, 0.65),
|
||||||
speed = vector.multiply(wind, CLOUD_SPEED),
|
speed = wind,
|
||||||
thickness = climate_api.utility.rangelim(params.base_humidity * 0.2, 1, 18),
|
thickness = climate_api.utility.rangelim(params.base_humidity * 0.2, 1, 18),
|
||||||
height = calc_cloud_height(params.heat, params.humidity, params.dewpoint),
|
height = cloud_height,
|
||||||
ambient = "#0f0f1050"
|
ambient = "#0f0f1050"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ local name = "regional_weather:hail"
|
|||||||
local conditions = {
|
local conditions = {
|
||||||
min_height = regional_weather.settings.min_height,
|
min_height = regional_weather.settings.min_height,
|
||||||
max_height = regional_weather.settings.max_height,
|
max_height = regional_weather.settings.max_height,
|
||||||
|
min_heat = 30,
|
||||||
max_heat = 45,
|
max_heat = 45,
|
||||||
min_humidity = 65,
|
min_humidity = 65,
|
||||||
min_windspeed = 2.5,
|
min_windspeed = 2.5,
|
||||||
@ -12,7 +13,7 @@ local conditions = {
|
|||||||
local effects = {}
|
local effects = {}
|
||||||
|
|
||||||
effects["climate_api:damage"] = {
|
effects["climate_api:damage"] = {
|
||||||
chance = 15,
|
rarity = 15,
|
||||||
value = 3,
|
value = 3,
|
||||||
check = {
|
check = {
|
||||||
type = "raycast",
|
type = "raycast",
|
||||||
|
@ -25,7 +25,7 @@ effects["climate_api:hud_overlay"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
effects["climate_api:damage"] = {
|
effects["climate_api:damage"] = {
|
||||||
chance = 3,
|
rarity = 3,
|
||||||
value = 1,
|
value = 1,
|
||||||
check = {
|
check = {
|
||||||
type = "raycast",
|
type = "raycast",
|
||||||
|
Loading…
Reference in New Issue
Block a user