forked from mtcontrib/maidroid
Add maidroid#get_front method
This commit is contained in:
parent
0664cb9050
commit
fbf93ecf2d
@ -95,8 +95,8 @@ function maidroid.maidroid.get_nearest_player(self, range_distance)
|
|||||||
return player
|
return player
|
||||||
end
|
end
|
||||||
|
|
||||||
-- maidroid.maidroid.get_front_node returns a node that exists in front of the maidroid.
|
-- maidroid.maidroid.get_front returns a position in front of the maidroid.
|
||||||
function maidroid.maidroid.get_front_node(self)
|
function maidroid.maidroid.get_front(self)
|
||||||
local direction = self:get_look_direction()
|
local direction = self:get_look_direction()
|
||||||
if math.abs(direction.x) >= 0.5 then
|
if math.abs(direction.x) >= 0.5 then
|
||||||
if direction.x > 0 then direction.x = 1 else direction.x = -1 end
|
if direction.x > 0 then direction.x = 1 else direction.x = -1 end
|
||||||
@ -110,7 +110,12 @@ function maidroid.maidroid.get_front_node(self)
|
|||||||
direction.z = 0
|
direction.z = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local front = vector.add(vector.round(self.object:getpos()), direction)
|
return vector.add(vector.round(self.object:getpos()), direction)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- maidroid.maidroid.get_front_node returns a node that exists in front of the maidroid.
|
||||||
|
function maidroid.maidroid.get_front_node(self)
|
||||||
|
local front = self:get_front()
|
||||||
return minetest.get_node(front)
|
return minetest.get_node(front)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -624,6 +629,7 @@ function maidroid.register_maidroid(product_name, def)
|
|||||||
get_core = maidroid.maidroid.get_core,
|
get_core = maidroid.maidroid.get_core,
|
||||||
get_core_name = maidroid.maidroid.get_core_name,
|
get_core_name = maidroid.maidroid.get_core_name,
|
||||||
get_nearest_player = maidroid.maidroid.get_nearest_player,
|
get_nearest_player = maidroid.maidroid.get_nearest_player,
|
||||||
|
get_front = maidroid.maidroid.get_front,
|
||||||
get_front_node = maidroid.maidroid.get_front_node,
|
get_front_node = maidroid.maidroid.get_front_node,
|
||||||
get_look_direction = maidroid.maidroid.get_look_direction,
|
get_look_direction = maidroid.maidroid.get_look_direction,
|
||||||
set_animation = maidroid.maidroid.set_animation,
|
set_animation = maidroid.maidroid.set_animation,
|
||||||
|
Loading…
Reference in New Issue
Block a user