Replace deprecated methods
This commit is contained in:
parent
ca936605b3
commit
f815b53101
@ -134,8 +134,8 @@ local walk_randomly, walk_to_plant_and_mow_common, plant, mow
|
||||
local to_walk_randomly, to_walk_to_plant, to_walk_to_mow, to_plant, to_mow
|
||||
|
||||
local function on_start(self)
|
||||
self.object:setacceleration{x = 0, y = -10, z = 0}
|
||||
self.object:setvelocity{x = 0, y = 0, z = 0}
|
||||
self.object:set_acceleration{x = 0, y = -10, z = 0}
|
||||
self.object:set_velocity{x = 0, y = 0, z = 0}
|
||||
self.state = state.WALK_RANDOMLY
|
||||
self.time_counters = {}
|
||||
self.path = nil
|
||||
@ -143,7 +143,7 @@ local function on_start(self)
|
||||
end
|
||||
|
||||
local function on_stop(self)
|
||||
self.object:setvelocity{x = 0, y = 0, z = 0}
|
||||
self.object:set_velocity{x = 0, y = 0, z = 0}
|
||||
self.state = nil
|
||||
self.time_counters = nil
|
||||
self.path = nil
|
||||
@ -151,7 +151,7 @@ local function on_stop(self)
|
||||
end
|
||||
|
||||
local function is_near(self, pos, distance)
|
||||
local p = self.object:getpos()
|
||||
local p = self.object:get_pos()
|
||||
-- p.y = p.y + 0.5
|
||||
return vector.distance(p, pos) < distance
|
||||
end
|
||||
@ -166,9 +166,9 @@ walk_randomly = function(self, dtime)
|
||||
local wield_stack = self:get_wield_item_stack()
|
||||
if minetest.get_item_group(wield_stack:get_name(), "seed") > 0
|
||||
or self:has_item_in_main(function(itemname) return (minetest.get_item_group(itemname, "seed") > 0) end) then
|
||||
local destination = _aux.search_surrounding(self.object:getpos(), is_plantable_place, searching_range)
|
||||
local destination = _aux.search_surrounding(self.object:get_pos(), is_plantable_place, searching_range)
|
||||
if destination ~= nil then
|
||||
local path = minetest.find_path(self.object:getpos(), destination, 10, 1, 1, "A*")
|
||||
local path = minetest.find_path(self.object:get_pos(), destination, 10, 1, 1, "A*")
|
||||
|
||||
if path ~= nil then -- to walk to plant state.
|
||||
to_walk_to_plant(self, path, destination)
|
||||
@ -177,9 +177,9 @@ walk_randomly = function(self, dtime)
|
||||
end
|
||||
end
|
||||
-- if couldn't find path to plant, try to mow.
|
||||
local destination = _aux.search_surrounding(self.object:getpos(), is_mowable_place, searching_range)
|
||||
local destination = _aux.search_surrounding(self.object:get_pos(), is_mowable_place, searching_range)
|
||||
if destination ~= nil then
|
||||
local path = minetest.find_path(self.object:getpos(), destination, 10, 1, 1, "A*")
|
||||
local path = minetest.find_path(self.object:get_pos(), destination, 10, 1, 1, "A*")
|
||||
if path ~= nil then -- to walk to mow state.
|
||||
to_walk_to_mow(self, path, destination)
|
||||
return
|
||||
@ -197,7 +197,7 @@ walk_randomly = function(self, dtime)
|
||||
self.time_counters[1] = self.time_counters[1] + 1
|
||||
self.time_counters[2] = self.time_counters[2] + 1
|
||||
|
||||
local velocity = self.object:getvelocity()
|
||||
local velocity = self.object:get_velocity()
|
||||
if velocity.y == 0 then
|
||||
local front_node = self:get_front_node()
|
||||
|
||||
@ -207,7 +207,7 @@ walk_randomly = function(self, dtime)
|
||||
|
||||
-- elseif front_node.name ~= "air" and minetest.registered_nodes[front_node.name] ~= nil
|
||||
-- and minetest.registered_nodes[front_node.name].walkable then
|
||||
-- self.object:setvelocity{x = velocity.x, y = 6, z = velocity.z}
|
||||
-- self.object:set_velocity{x = velocity.x, y = 6, z = velocity.z}
|
||||
end
|
||||
end
|
||||
return
|
||||
@ -248,9 +248,9 @@ to_plant = function(self)
|
||||
or self:move_main_to_wield(function(itemname) return (minetest.get_item_group(itemname, "seed") > 0) end) then
|
||||
self.state = state.PLANT
|
||||
self.time_counters[1] = 0
|
||||
self.object:setvelocity{x = 0, y = 0, z = 0}
|
||||
self.object:set_velocity{x = 0, y = 0, z = 0}
|
||||
self:set_animation(maidroid.animation_frames.MINE)
|
||||
self:set_yaw_by_direction(vector.subtract(self.destination, self.object:getpos()))
|
||||
self:set_yaw_by_direction(vector.subtract(self.destination, self.object:get_pos()))
|
||||
return
|
||||
else
|
||||
to_walk_randomly(self)
|
||||
@ -261,9 +261,9 @@ end
|
||||
to_mow = function(self)
|
||||
self.state = state.MOW
|
||||
self.time_counters[1] = 0
|
||||
self.object:setvelocity{x = 0, y = 0, z = 0}
|
||||
self.object:set_velocity{x = 0, y = 0, z = 0}
|
||||
self:set_animation(maidroid.animation_frames.MINE)
|
||||
self:set_yaw_by_direction(vector.subtract(self.destination, self.object:getpos()))
|
||||
self:set_yaw_by_direction(vector.subtract(self.destination, self.object:get_pos()))
|
||||
end
|
||||
|
||||
walk_to_plant_and_mow_common = function(self, dtime)
|
||||
@ -287,7 +287,7 @@ walk_to_plant_and_mow_common = function(self, dtime)
|
||||
|
||||
if self.time_counters[1] >= FIND_PATH_TIME_INTERVAL then
|
||||
self.time_counters[1] = 0
|
||||
local path = minetest.find_path(self.object:getpos(), self.destination, 10, 1, 1, "A*")
|
||||
local path = minetest.find_path(self.object:get_pos(), self.destination, 10, 1, 1, "A*")
|
||||
if path == nil then
|
||||
to_walk_randomly(self)
|
||||
return
|
||||
@ -313,13 +313,13 @@ walk_to_plant_and_mow_common = function(self, dtime)
|
||||
|
||||
-- else
|
||||
-- -- if maidroid is stopped by obstacles, the maidroid must jump.
|
||||
-- local velocity = self.object:getvelocity()
|
||||
-- local velocity = self.object:get_velocity()
|
||||
-- if velocity.y == 0 then
|
||||
-- local front_node = self:get_front_node()
|
||||
-- if front_node.name ~= "air" and minetest.registered_nodes[front_node.name] ~= nil
|
||||
-- and minetest.registered_nodes[front_node.name].walkable
|
||||
-- and not (minetest.get_item_group(front_node.name, "fence") > 0) then
|
||||
-- self.object:setvelocity{x = velocity.x, y = 6, z = velocity.z}
|
||||
-- self.object:set_velocity{x = velocity.x, y = 6, z = velocity.z}
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user