1
0
mirror of https://github.com/tacigar/maidroid.git synced 2025-07-05 09:10:22 +02:00

Brush up code

This commit is contained in:
tacigar
2016-12-24 09:23:31 +09:00
parent 0da2c5c9a9
commit ff5aa10c4d
3 changed files with 15 additions and 15 deletions

View File

@ -113,8 +113,11 @@ walk_randomly = function(self, dtime)
local velocity = self.object:getvelocity()
if velocity.y == 0 then
local front_node = self:get_front_node()
if front_node.name ~= "air" and minetest.registered_nodes[front_node.name].walkable
and not (minetest.get_item_group(front_node.name, "fence") > 0) then
if minetest.get_item_group(front_node.name, "fence") > 0 then
self:change_direction_randomly()
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}
end
end
@ -224,7 +227,8 @@ walk_to_plant_and_mow_common = function(self, dtime)
local velocity = self.object:getvelocity()
if velocity.y == 0 then
local front_node = self:get_front_node()
if front_node.name ~= "air" and minetest.registered_nodes[front_node.name].walkable
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}
end