add basic sounds
parent
39d2b13760
commit
3f7b6f5011
|
@ -0,0 +1,3 @@
|
||||||
|
.settings/*
|
||||||
|
.project
|
||||||
|
.buildpath
|
14
init.lua
14
init.lua
|
@ -18,6 +18,7 @@ local cart = {
|
||||||
old_pos = nil,
|
old_pos = nil,
|
||||||
old_velocity = nil,
|
old_velocity = nil,
|
||||||
pre_stop_dir = nil,
|
pre_stop_dir = nil,
|
||||||
|
sound_handle = nil,
|
||||||
MAX_V = 6, -- Limit of the velocity
|
MAX_V = 6, -- Limit of the velocity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,6 +235,19 @@ function cart:on_step(dtime)
|
||||||
if not cart_func.v3:equal(self.velocity, {x=0,y=0,z=0}) then
|
if not cart_func.v3:equal(self.velocity, {x=0,y=0,z=0}) then
|
||||||
self.pre_stop_dir = cart_func:velocity_to_dir(self.velocity)
|
self.pre_stop_dir = cart_func:velocity_to_dir(self.velocity)
|
||||||
|
|
||||||
|
if self.sound_handle == nil then
|
||||||
|
self.sound_handle = minetest.sound_play("vcarts_cart_sound", {
|
||||||
|
object = self.object,
|
||||||
|
max_hear_distance = 2,
|
||||||
|
loop = true,
|
||||||
|
gain = 0.4,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif self.sound_handle ~= nil then
|
||||||
|
minetest.sound_stop(self.sound_handle)
|
||||||
|
self.sound_handle = nil
|
||||||
|
|
||||||
-- drop cart if its position is incorrect (e.g. floating in air)
|
-- drop cart if its position is incorrect (e.g. floating in air)
|
||||||
elseif cart_func:is_rail(pos) == false then
|
elseif cart_func:is_rail(pos) == false then
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue