Code: Select all
if self.work == 3 then
for i, v in pairs(listOfBuildings) do
if self.carry == 6 then
if listOfBuildings[i].id == 17 and listOfBuildings[i].mortarl > 0 then
self. = listOfBuildings[i].x self.target2Y = listOfBuildings[i].y self.target2 = listOfBuildings[i]
end
end
end
end
Code: Select all
if self.work == 3 then
if self.carry == 6 then lookingForMortar() end
end
Code: Select all
function lookingForMortar()
for i, v in pairs(listOfBuildings) do
if listOfBuildings[i].id == 17 and listOfBuildings[i].mortar > 0 then
self.target2X = listOfBuildings[i].x self.target2Y = listOfBuildings[i].y self.target2 = listOfBuildings[i]
end
end
return self.target2X, self.target2Y, self.target2
end
The next thing is that I not only have to look for mortar, but also for wood and stone. So I have to copy and paste most of the lookingForMortar function, only changing the index .. right? But is there not a better way???