Improve placement handling & audio bugfix

This commit is contained in:
stujones11 2013-07-28 17:08:45 +01:00
parent 0282f6cb91
commit 5179779f49
2 changed files with 20 additions and 4 deletions

View File

@ -12,6 +12,7 @@ function hover:register_hovercraft(name, def)
deceleration = def.deceleration,
jump_velocity = def.jump_velocity,
fall_velocity = def.fall_velocity,
bounce = def.bounce,
player = nil,
sound = nil,
thrust = 0,
@ -19,8 +20,21 @@ function hover:register_hovercraft(name, def)
last_pos = {x=0, y=0, z=0},
timer = 0,
on_activate = function(self, staticdata, dtime_s)
self.object:set_armor_groups({immortal=1})
self.object:set_animation({x=0, y=24}, 30)
end,
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
if self.player then
return
end
if self.sound then
minetest.sound_stop(self.sound)
end
self.object:remove()
if puncher and puncher:is_player() then
puncher:get_inventory():add_item("main", name)
end
end,
on_rightclick = function(self, clicker)
if not clicker or not clicker:is_player() then
return
@ -115,12 +129,12 @@ function hover:register_hovercraft(name, def)
self.timer = 0
end
if self.last_pos.x == pos.x and math.abs(self.velocity.x) > 0.5 then
self.velocity.x = self.velocity.x * -0.8
self.velocity.x = self.velocity.x * (0 - self.bounce)
self.thrust = 0
minetest.sound_play("hovercraft_bounce", {object = self.object})
end
if self.last_pos.z == pos.z and math.abs(self.velocity.z) > 0.5 then
self.velocity.z = self.velocity.z * -0.8
self.velocity.z = self.velocity.z * (0 - self.bounce)
self.thrust = 0
minetest.sound_play("hovercraft_bounce", {object = self.object})
end

View File

@ -9,6 +9,7 @@ hover:register_hovercraft("hovercraft:hover_red" ,{
deceleration = 0.025,
jump_velocity = 4.0,
fall_velocity = 1.0,
bounce = 0.5,
})
hover:register_hovercraft("hovercraft:hover_blue" ,{
@ -20,5 +21,6 @@ hover:register_hovercraft("hovercraft:hover_blue" ,{
deceleration = 0.05,
jump_velocity = 4,
fall_velocity = 1,
bounce = 0.8,
})