# I stuck in the wild horse ,plz h

#1
``````loop
-- 你怎么寻找最近的友好单位？
-- 马=？
horse = this.self:findNearest(this.findFriends())
if horse then
x1 = horse.pos.x - 7
x2 = horse.pos.x + 7
y = horse.pos.y
if x1 >= 1 then
self:moveXY(x1, y)
-- 移动到马的y坐标，但使用x1作为x坐标。
elseif x2 <= 79 then
self:moveXY(x2, y)
-- 移动到马的y坐标，但使用x2作为x坐标。
local distance = self:distanceTo(horse)
if distance <= 10 then
self:say("Whoa")
-- 移到到红色的x来使马返回农场。
self:moveXY(27, 54)
-- 移回牧场开始寻找下一匹马。
self:moveXY(43, 21)
end
end
end
end
``````

this is my code.but it always break some mistake.

Uppercase or lowercase problem.Try this.

I have used this, why it show me this again…

#2

I tried your 4 line: horse = this.self:findNearest(this.findFriends())
and it didn’t run.
I changed it to: horse = self.findNearest(self.findFriends())
and I managed the level.
Hope this helps!

#3

It depends. @WatchAndLearn are you using Python?

#4

yes (was allready wondering) Sorry my mistake!

#5

Sorry ,I don’t use Python,I am just using LUA.

#6

if you find some clues plz tell me then.

#7
``````horse = self:findNearest(self:findFriends())
``````

Lua uses `self:methodName()` to call methods, whereas it is just `self.property` to access non-method properties. It doesn’t use `this`, which is a JavaScript thing.

Also, you don’t put an `end` after the `elseif x2 <= 79 then` if-statement.

#9

@WatchAndLearn Thank you for wanting to help, but please don’t post correct code. It makes it too easy for others and really takes away the whole point of the game.

#10

OK WILL delete it.sorry .

#11

Thanks very much, WatchAndLearn. Few people do that.