Enable more options for particles, fix skybox reset, add new debug command, fix daylight influence

This commit is contained in:
Till Affeldt 2020-04-22 00:56:34 +02:00
parent d1bdf92937
commit c9d0cfca21
9 changed files with 57 additions and 23 deletions

View File

@ -1,24 +1,25 @@
# TODO # TODO
## Required for MVP ## Required for Beta
- Find good values for weather conditions - Write helpful README
- Make sure all weather presets are working - Refactor skybox effect and implement ranking system
- Rework Moon Phases mod to be compatible and to include varying sky brightness
## Planned for first release ## Planned for first release
- Write helpful README
- Set effects on player join - Set effects on player join
- Improve value structures of particle and skybox effects - Improve value structures of particle effects
- Make sounds adjust to changes by weather presets - Make sounds adjust to changes by weather presets
- Find good values for weather conditions
- Write documentation on how to add weathers and effects
- Ability to register global influences that are the same for any position
## Nice to have ## Nice to have
- Write documentation on how to add weathers and effects
- Assign meta data (like "downfall", "wind", etc.) to weather presets - Assign meta data (like "downfall", "wind", etc.) to weather presets
- Fog effects
- Optimize performance by replacing some particles with animated texture planes - Optimize performance by replacing some particles with animated texture planes
- Make switches between effects more smooth - Make switches between effects more smooth
- Adjust size of particle boxes based on player speed - Adjust size of particle boxes based on player speed
- Create conditions for time of day, annual progression, biome filters
- Generate wind based on speed and yaw instead of x and z values - Generate wind based on speed and yaw instead of x and z values
- A flag indicating wind direction
## Future Plans & Ideas ## Future Plans & Ideas
- Complete season system - Complete season system

View File

@ -21,7 +21,10 @@ local function spawn_particles(player, particles)
y = -particles.falling_speed, y = -particles.falling_speed,
z = wind.z z = wind.z
}) })
local acc = vector.new({x=0, y=0, z=0})
if particles.acceleration == nil then
particles.acceleration = vector.new({x=0, y=0, z=0})
end
local wind_pos = vector.multiply( local wind_pos = vector.multiply(
vector.normalize(vel), vector.normalize(vel),
@ -31,25 +34,35 @@ local function spawn_particles(player, particles)
local minp = vector.add(vector.add(ppos, particles.min_pos), wind_pos) local minp = vector.add(vector.add(ppos, particles.min_pos), wind_pos)
local maxp = vector.add(vector.add(ppos, particles.max_pos), wind_pos) local maxp = vector.add(vector.add(ppos, particles.max_pos), wind_pos)
local exp = particles.exptime if particles.time == nil then
local vertical = math.abs(vector.normalize(vel).y) >= 0.6 particles.time = 0.5
end
if particles.vertical == nil then
particles.vertical = math.abs(vector.normalize(vel).y) >= 0.6
end
if particles.size ~= nil then
particles.min_size = particles.size
particles.max_size = particles.size
end
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = amount, amount = amount,
time = 0.5, time = particles.time,
minpos = minp, minpos = minp,
maxpos = maxp, maxpos = maxp,
minvel = vel, minvel = vel,
maxvel = vel, maxvel = vel,
minacc = acc, minacc = particles.acceleration,
maxacc = acc, maxacc = particles.acceleration,
minexptime = exp, minexptime = particles.exptime,
maxexptime = exp, maxexptime = particles.exptime,
minsize = particles.size, minsize = particles.min_size,
maxsize = particles.size, maxsize = particles.max_size,
collisiondetection = true, collisiondetection = true,
collision_removal = true, collision_removal = true,
vertical = vertical, vertical = particles.vertical,
texture = texture, texture = texture,
player = player:get_player_name() player = player:get_player_name()
}) })

View File

@ -15,7 +15,11 @@ end
local function remove_skybox(player) local function remove_skybox(player)
if not player.get_stars then return end if not player.get_stars then return end
player:set_sky({ type = "regular", clouds = true }) player:set_sky(sky_defaults.sky_data)
player:set_clouds(sky_defaults.cloud_data)
player:set_moon(sky_defaults.moon_data)
player:set_sun(sky_defaults.sun_data)
player:set_stars(sky_defaults.star_data)
end end
local function handle_effect(player_data) local function handle_effect(player_data)

View File

@ -41,7 +41,6 @@ local function handle_effect(player_data, prev_data)
end end
local function stop_effect(prev_data) local function stop_effect(prev_data)
minetest.log(dump2(prev_data, "stop_effect"))
for playername, data in pairs(prev_data) do for playername, data in pairs(prev_data) do
for weather, value in pairs(data) do for weather, value in pairs(data) do
stop_sound(playername, value) stop_sound(playername, value)

View File

@ -17,7 +17,7 @@ end
function api.register_effect(name, handler, htype) function api.register_effect(name, handler, htype)
-- check for valid handler types -- check for valid handler types
if htype ~= "start" and htype ~= "tick" and htype ~= "stop" then if htype ~= "start" and htype ~= "tick" and htype ~= "stop" then
minetest.log("warning", "[Climate API] Invalid effect handler type: " .. htype) minetest.log("warning", "[Climate API] Effect " .. dump(name) .. " uses invalid callback type: " .. dump(htype))
return return
end end
-- create effect handler registry if not existent yet -- create effect handler registry if not existent yet

View File

@ -156,3 +156,15 @@ minetest.register_chatcommand("weather_status", {
end end
end end
}) })
minetest.register_chatcommand("weather_influences", {
description = "Prints which weather influences cause your current weather",
func = function(playername)
minetest.chat_send_player(playername, "Current influences rules:\n================")
local player = minetest.get_player_by_name(playername)
local influences = climate_mod.trigger.get_player_environment(player)
for influence, value in pairs(influences) do
minetest.chat_send_player(playername, dump2(value, influence))
end
end
})

View File

@ -36,13 +36,19 @@ climate_api.register_influence("height", function(pos)
end) end)
climate_api.register_influence("light", function(pos) climate_api.register_influence("light", function(pos)
pos = vector.add(pos, {x = 0, y = 1, z = 0})
return minetest.env:get_node_light(pos) return minetest.env:get_node_light(pos)
end) end)
climate_api.register_influence("daylight", function(pos) climate_api.register_influence("daylight", function(pos)
pos = vector.add(pos, {x = 0, y = 1, z = 0})
return minetest.env:get_node_light(pos, 0.5) return minetest.env:get_node_light(pos, 0.5)
end) end)
climate_api.register_influence("time", function(_) climate_api.register_influence("time", function(_)
return minetest.get_timeofday() return minetest.get_timeofday()
end)
climate_api.register_influence("day_count", function(_)
return minetest.get_day_count()
end) end)

View File

@ -155,7 +155,6 @@ function trigger.call_handlers(name, effect, prev_effect)
-- remaining table lists ending effects -- remaining table lists ending effects
if has_stops then if has_stops then
minetest.log(dump2(name, "AAAAAAAAAAA"))
for _, handler in ipairs(climate_mod.effects[name]["stop"]) do for _, handler in ipairs(climate_mod.effects[name]["stop"]) do
handler(stops) handler(stops)
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB