Fix farming module

This commit is contained in:
tacigar 2016-06-09 15:08:16 +09:00
parent 38d2d6cc96
commit 7775940177

View File

@ -11,9 +11,11 @@ local state = {
plant = 2,
walk_to_plant = 3,
walk_to_soil = 4,
walk_avoid = 5,
}
local max_punch_time = 20
local max_plant_time = 15
local max_avoid_time = 15
local search_lenvec = {x = 3, y = 0, z = 3}
@ -75,6 +77,12 @@ local function to_walk(self)
end
local function to_walk_avoid(self)
to_walk(self)
self.state = state.walk_avoid
end
maidroid.register_module("maidroid:farming_module", {
description = "Maidroid Module : Farming",
inventory_image = "maidroid_farming_module.png",
@ -169,7 +177,7 @@ maidroid.register_module("maidroid:farming_module", {
else to_walk(self) end
else
if pos.x == self.preposition.x or pos.z == self.preposition.z then
to_walk(self)
to_walk_avoid(self)
end
end
@ -183,9 +191,17 @@ maidroid.register_module("maidroid:farming_module", {
else to_walk(self) end
else
if pos.x == self.preposition.x or pos.z == self.preposition.z then
to_walk(self)
to_walk_avoid(self)
end
end
elseif self.state == state.walk_avoid then
if self.time_count > max_avoid_time then
self.state = state.walk
self.time_count = 0
else
self.time_count = self.time_count + 1
end
end
self.preposition = pos
return