Compare commits

...

5 Commits

Author SHA1 Message Date
5898cc4e1c Merge pull request 'add sound at jetpack' (#29) from Kindaglia/industrialtest:sound into master 2025-04-25 10:48:46 +02:00
Kindaglia
f651e407f7 fix naming 2025-04-25 10:12:45 +02:00
Kindaglia
f5f27ef999 rename and fix sound jetpack 2025-04-25 00:14:45 +02:00
Kindaglia
68abb4d08e add sound jetpack 2025-04-24 21:12:15 +02:00
Kindaglia
f1d8d5060c add sound jetpack ogg 2025-04-24 20:52:55 +02:00
2 changed files with 20 additions and 2 deletions

Binary file not shown.

View File

@ -19,12 +19,30 @@ industrialtest.JetpackBase=table.copy(industrialtest.GearTool)
industrialtest.internal.unpackTableInto(industrialtest.JetpackBase,{
part="torso"
})
local soundHandles = {}
function industrialtest.JetpackBase.update(self,player,inv,itemstack,dtime)
local control=player:get_player_control()
function industrialtest.JetpackBase.update(self, player, inv, itemstack, dtime)
local playerName = player:get_player_name()
local control = player:get_player_control()
if control.jump and self:tryFly(itemstack) then
self.addYVelocityClamped(player,1,10)
if not soundHandles[playerName] then
local pos = player:get_pos()
local handle = minetest.sound_play("industrialtest_jetpack_loop", {
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
})
soundHandles[playerName] = handle
end
return true
else
if soundHandles[playerName] then
minetest.sound_stop(soundHandles[playerName])
soundHandles[playerName] = nil
end
end
return false
end