add sound jetpack
This commit is contained in:
parent
f1d8d5060c
commit
68abb4d08e
@ -19,12 +19,30 @@ industrialtest.JetpackBase=table.copy(industrialtest.GearTool)
|
|||||||
industrialtest.internal.unpackTableInto(industrialtest.JetpackBase,{
|
industrialtest.internal.unpackTableInto(industrialtest.JetpackBase,{
|
||||||
part="torso"
|
part="torso"
|
||||||
})
|
})
|
||||||
|
local sound_handles = {}
|
||||||
|
|
||||||
function industrialtest.JetpackBase.update(self,player,inv,itemstack,dtime)
|
function industrialtest.JetpackBase.update(self, player, inv, itemstack, dtime)
|
||||||
local control=player:get_player_control()
|
local playerName = player:get_player_name()
|
||||||
|
local control = player:get_player_control()
|
||||||
if control.jump and self:tryFly(itemstack) then
|
if control.jump and self:tryFly(itemstack) then
|
||||||
self.addYVelocityClamped(player,1,10)
|
self.addYVelocityClamped(player,1,10)
|
||||||
|
if not sound_handles[playerName] then
|
||||||
|
local pos = player:get_pos()
|
||||||
|
local handle = minetest.sound_play("JetpackLoop", {
|
||||||
|
pos = pos,
|
||||||
|
gain = 1.0, -- Volume of the sound
|
||||||
|
max_hear_distance = 16, -- Maximum distance to hear the sound
|
||||||
|
object = player, -- Attach the sound to the player
|
||||||
|
loop = true, -- The sound is played in a loop
|
||||||
|
})
|
||||||
|
sound_handles[playerName] = handle
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
|
else
|
||||||
|
if sound_handles[playerName] then
|
||||||
|
minetest.sound_stop(sound_handles[playerName])
|
||||||
|
sound_handles[playerName] = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user