mirror of
https://github.com/tacigar/maidroid.git
synced 2025-01-10 16:20:19 +01:00
Fix farming module
This commit is contained in:
parent
38d2d6cc96
commit
7775940177
@ -11,9 +11,11 @@ local state = {
|
|||||||
plant = 2,
|
plant = 2,
|
||||||
walk_to_plant = 3,
|
walk_to_plant = 3,
|
||||||
walk_to_soil = 4,
|
walk_to_soil = 4,
|
||||||
|
walk_avoid = 5,
|
||||||
}
|
}
|
||||||
local max_punch_time = 20
|
local max_punch_time = 20
|
||||||
local max_plant_time = 15
|
local max_plant_time = 15
|
||||||
|
local max_avoid_time = 15
|
||||||
local search_lenvec = {x = 3, y = 0, z = 3}
|
local search_lenvec = {x = 3, y = 0, z = 3}
|
||||||
|
|
||||||
|
|
||||||
@ -75,6 +77,12 @@ local function to_walk(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function to_walk_avoid(self)
|
||||||
|
to_walk(self)
|
||||||
|
self.state = state.walk_avoid
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
maidroid.register_module("maidroid:farming_module", {
|
maidroid.register_module("maidroid:farming_module", {
|
||||||
description = "Maidroid Module : Farming",
|
description = "Maidroid Module : Farming",
|
||||||
inventory_image = "maidroid_farming_module.png",
|
inventory_image = "maidroid_farming_module.png",
|
||||||
@ -169,7 +177,7 @@ maidroid.register_module("maidroid:farming_module", {
|
|||||||
else to_walk(self) end
|
else to_walk(self) end
|
||||||
else
|
else
|
||||||
if pos.x == self.preposition.x or pos.z == self.preposition.z then
|
if pos.x == self.preposition.x or pos.z == self.preposition.z then
|
||||||
to_walk(self)
|
to_walk_avoid(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -183,9 +191,17 @@ maidroid.register_module("maidroid:farming_module", {
|
|||||||
else to_walk(self) end
|
else to_walk(self) end
|
||||||
else
|
else
|
||||||
if pos.x == self.preposition.x or pos.z == self.preposition.z then
|
if pos.x == self.preposition.x or pos.z == self.preposition.z then
|
||||||
to_walk(self)
|
to_walk_avoid(self)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
self.preposition = pos
|
self.preposition = pos
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user