mirror of
https://github.com/APercy/airutils.git
synced 2025-03-15 08:01:22 +00:00
added full support to water splash
This commit is contained in:
parent
6e8f961714
commit
572133b4c1
4 changed files with 28 additions and 7 deletions
8
init.lua
8
init.lua
|
@ -60,6 +60,12 @@ if not minetest.settings:get_bool('airutils_disable_repair') then
|
||||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_repair.lua")
|
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_repair.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
airutils.splash_texture = "airutils_splash.png"
|
||||||
|
airutils.use_water_particles = false
|
||||||
|
if minetest.settings:get_bool('airutils_enable_water_particles', false) then
|
||||||
|
airutils.use_water_particles = true
|
||||||
|
end
|
||||||
|
|
||||||
airutils._use_signs_api = true
|
airutils._use_signs_api = true
|
||||||
if not minetest.get_modpath("signs_lib") then airutils._use_signs_api = false end
|
if not minetest.get_modpath("signs_lib") then airutils._use_signs_api = false end
|
||||||
if minetest.settings:get_bool('airutils_disable_signs_api') then airutils._use_signs_api = false end
|
if minetest.settings:get_bool('airutils_disable_signs_api') then airutils._use_signs_api = false end
|
||||||
|
@ -78,8 +84,6 @@ dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "texture_management.lua"
|
||||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "attach_extern_ent.lua")
|
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "attach_extern_ent.lua")
|
||||||
if airutils._use_signs_api then dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "text.lua") end
|
if airutils._use_signs_api then dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "text.lua") end
|
||||||
|
|
||||||
airutils.splash_texture = "airutils_splash.png"
|
|
||||||
|
|
||||||
local is_biofuel_installed = false
|
local is_biofuel_installed = false
|
||||||
if biomass then
|
if biomass then
|
||||||
if biomass.convertible_groups then is_biofuel_installed = true end
|
if biomass.convertible_groups then is_biofuel_installed = true end
|
||||||
|
|
|
@ -535,6 +535,19 @@ function airutils.logic(self)
|
||||||
if h_vel_compensation > max_pitch then h_vel_compensation = max_pitch end
|
if h_vel_compensation > max_pitch then h_vel_compensation = max_pitch end
|
||||||
--minetest.chat_send_all(h_vel_compensation)
|
--minetest.chat_send_all(h_vel_compensation)
|
||||||
newpitch = newpitch + (velocity.y * math.rad(max_pitch - h_vel_compensation))
|
newpitch = newpitch + (velocity.y * math.rad(max_pitch - h_vel_compensation))
|
||||||
|
|
||||||
|
if airutils.use_water_particles == true and airutils.add_splash and self._splash_x_position and self.buoyancy then
|
||||||
|
local splash_frequency = 0.15
|
||||||
|
if self._last_splash == nil then self._last_splash = 0.5 else self._last_splash = self._last_splash + self.dtime end
|
||||||
|
if longit_speed >= 2.0 and self._last_vel and self._last_splash >= splash_frequency then
|
||||||
|
self._last_splash = 0
|
||||||
|
local splash_pos = vector.new(curr_pos)
|
||||||
|
local bellow_position = self.initial_properties.collisionbox[2]
|
||||||
|
local collision_height = self.initial_properties.collisionbox[5] - bellow_position
|
||||||
|
splash_pos.y = splash_pos.y + (bellow_position + (collision_height * self.buoyancy)) - (collision_height/10)
|
||||||
|
airutils.add_splash(splash_pos, newyaw, self._splash_x_position)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local new_accel = accel
|
local new_accel = accel
|
||||||
|
|
|
@ -18,3 +18,7 @@ airutils_debug_log (log of entity activation) bool false
|
||||||
|
|
||||||
# disable the usage of signs_api by the vehicles
|
# disable the usage of signs_api by the vehicles
|
||||||
airutils_disable_signs_api (no names writen on vehicles surface) bool false
|
airutils_disable_signs_api (no names writen on vehicles surface) bool false
|
||||||
|
|
||||||
|
# enable water particles effect
|
||||||
|
airutils_enable_water_particles (enable particles on water) bool false
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@ local function calculateVelocity(magnitude, angle)
|
||||||
return velocity
|
return velocity
|
||||||
end
|
end
|
||||||
|
|
||||||
local function water_particle(pos, vel)
|
local function water_particle(pos, accell)
|
||||||
if airutils.splash_texture == nil then return end
|
if airutils.splash_texture == nil then return end
|
||||||
if airutils.splash_texture == "" then return end
|
if airutils.splash_texture == "" then return end
|
||||||
|
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
pos = pos,
|
pos = pos,
|
||||||
velocity = vel, --{x = 0, y = 0, z = 0},
|
velocity = {x = 0, y = 0, z = 0},
|
||||||
acceleration = {x = 0, y = 0, z = 0},
|
acceleration = accell, --{x = 0, y = 0, z = 0},
|
||||||
expirationtime = 2.0,
|
expirationtime = 2.0,
|
||||||
size = 4.8,
|
size = 4.8,
|
||||||
collisiondetection = false,
|
collisiondetection = false,
|
||||||
|
@ -38,7 +38,7 @@ function airutils.add_splash(pos, yaw, x_pos)
|
||||||
spl_pos.x = spl_pos.x + move * math.cos(direction)
|
spl_pos.x = spl_pos.x + move * math.cos(direction)
|
||||||
spl_pos.z = spl_pos.z + move * math.sin(direction)
|
spl_pos.z = spl_pos.z + move * math.sin(direction)
|
||||||
|
|
||||||
local velocity = calculateVelocity(1.0, yaw)
|
local velocity = calculateVelocity(0.2, yaw)
|
||||||
water_particle(spl_pos, velocity)
|
water_particle(spl_pos, velocity)
|
||||||
|
|
||||||
--left
|
--left
|
||||||
|
@ -47,6 +47,6 @@ function airutils.add_splash(pos, yaw, x_pos)
|
||||||
spl_pos.x = spl_pos.x + move * math.cos(direction)
|
spl_pos.x = spl_pos.x + move * math.cos(direction)
|
||||||
spl_pos.z = spl_pos.z + move * math.sin(direction)
|
spl_pos.z = spl_pos.z + move * math.sin(direction)
|
||||||
|
|
||||||
velocity = calculateVelocity(1.0, yaw - math.rad(180))
|
velocity = calculateVelocity(0.2, yaw - math.rad(180))
|
||||||
water_particle(spl_pos, velocity)
|
water_particle(spl_pos, velocity)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue