forked from mtcontrib/mobs_redo
added dtime to drive function
This commit is contained in:
parent
ef3217d77f
commit
f7798e1b29
5
api.txt
5
api.txt
@ -281,7 +281,7 @@ This function will detach the player currently riding a mob to an offset positio
|
||||
'offset' position table containing offset values
|
||||
|
||||
|
||||
mobs:drive(self, move_animation, stand_animation, can_fly)
|
||||
mobs:drive(self, move_animation, stand_animation, can_fly, dtime)
|
||||
|
||||
This function allows an attached player to move the mob around and animate it at same time.
|
||||
|
||||
@ -289,6 +289,7 @@ This function allows an attached player to move the mob around and animate it at
|
||||
'move_animation' string containing movement animation e.g. "walk"
|
||||
'stand_animation' string containing standing animation e.g. "stand"
|
||||
'can_fly' if true then jump and sneak controls will allow mob to fly up and down
|
||||
'dtime' tick time used inside drive function
|
||||
|
||||
|
||||
Certain variables need to be set before using the above functions:
|
||||
@ -356,7 +357,7 @@ mobs:register_mob("mob_horse:horse", {
|
||||
|
||||
-- when riding mob call drive function to control
|
||||
if self.driver then
|
||||
mobs.drive(self, "walk", "stand", false)
|
||||
mobs.drive(self, "walk", "stand", false, dtime)
|
||||
return false -- skip rest of mob functions
|
||||
end
|
||||
|
||||
|
30
mount.lua
30
mount.lua
@ -18,6 +18,10 @@ local function node_is(pos)
|
||||
return "air"
|
||||
end
|
||||
|
||||
if minetest.get_item_group(node.name, "lava") ~= 0 then
|
||||
return "lava"
|
||||
end
|
||||
|
||||
if minetest.get_item_group(node.name, "liquid") ~= 0 then
|
||||
return "liquid"
|
||||
end
|
||||
@ -155,7 +159,7 @@ function mobs.detach(player, offset)
|
||||
end
|
||||
|
||||
|
||||
function mobs.drive(entity, moving_anim, stand_anim, can_fly)
|
||||
function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||
|
||||
local rot_steer, rot_view = math.pi/2, 0
|
||||
|
||||
@ -283,7 +287,27 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly)
|
||||
new_acce.y = 0
|
||||
end
|
||||
|
||||
elseif ni == "liquid" then
|
||||
elseif ni == "liquid" or ni == "lava" then
|
||||
|
||||
if ni == "lava" and entity.lava_damage ~= 0 then
|
||||
|
||||
entity.lava_counter = (entity.lava_counter or 0) + dtime
|
||||
|
||||
if entity.lava_counter > 1 then
|
||||
|
||||
minetest.sound_play("default_punch", {
|
||||
object = entity.object,
|
||||
max_hear_distance = 5
|
||||
})
|
||||
|
||||
entity.object:punch(entity.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = entity.lava_damage}
|
||||
}, nil)
|
||||
|
||||
entity.lava_counter = 0
|
||||
end
|
||||
end
|
||||
|
||||
if entity.terrain_type == 2
|
||||
or entity.terrain_type == 3 then
|
||||
@ -309,7 +333,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly)
|
||||
end
|
||||
end
|
||||
else
|
||||
v = v*0.25
|
||||
v = v * 0.25
|
||||
end
|
||||
-- elseif ni == "walkable" then
|
||||
-- v = 0
|
||||
|
Loading…
Reference in New Issue
Block a user