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
|
||||
end
|
||||
|
||||
-- maidroid.maidroid.get_front_node returns a node that exists in front of the maidroid.
|
||||
function maidroid.maidroid.get_front_node(self)
|
||||
-- maidroid.maidroid.get_front returns a position in front of the maidroid.
|
||||
function maidroid.maidroid.get_front(self)
|
||||
local direction = self:get_look_direction()
|
||||
if math.abs(direction.x) >= 0.5 then
|
||||
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
|
||||
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)
|
||||
end
|
||||
|
||||
@ -624,6 +629,7 @@ function maidroid.register_maidroid(product_name, def)
|
||||
get_core = maidroid.maidroid.get_core,
|
||||
get_core_name = maidroid.maidroid.get_core_name,
|
||||
get_nearest_player = maidroid.maidroid.get_nearest_player,
|
||||
get_front = maidroid.maidroid.get_front,
|
||||
get_front_node = maidroid.maidroid.get_front_node,
|
||||
get_look_direction = maidroid.maidroid.get_look_direction,
|
||||
set_animation = maidroid.maidroid.set_animation,
|
||||
|
Loading…
Reference in New Issue
Block a user