findNearestFriend function not noticed?

First, I’d like to ask if I’m using the correct term by calling “findNearestFriend” a “function” - I feel as if I’m using it wrongly.

Secondly, for my main issue, please have a look below

I’m programming in LUA btw.

it says I I don’t have the “findFriends” skill, but when I look at my list of skill, I’ve found I already have the skill granted by my hero himself. This is the first time I’ve come across “findNearestFriend” - it didn’t as ask me to buy any specific item before I went to this level either. Is there a bug to this?

It’s only for this level.

About your error:
local friend = self:findNearestFriend()

I don’t think there is a findNearestFriend function. You will need to use
two functions, findNearest and findFriends.

This function exist for the current level. Because players (usually) don’t have “findFriends” yet.

1 Like

Well that’s strange because the “findNearestFriend()” function was already written down by the computer itself not me. Hence the code should have existed

may someone help me it still does not work regardless

what’s the difference? That’s not even my question!

I answered you. Please, look my previous answers.

it still does not work, it just returns a nul

Could you post your actual code?

Ah nevermind, the one that you see on the picture was my actual code except more organized. After hours of fiddling around, I manage to find the cause of the problem.

It was no more then a bug, I had to exit the level, de-equip my new pair of glass and equip them again before entering the level. The code that I remains unchanged and yet works. This is something the developer of codecombat should take a look into as it is really frustrating.

just in case you are wondering here is my code:

while true do
local friend = self:findNearestFriend()
local enemy = self:findNearestEnemy()
if friend and enemy then
self.say("To battle, " + friend.id + “!”)
self.say(“Go Away,” + enemy.id + “!”)
–# Now find the nearest enemy and tell them to go away.
end
end

the use of “else” doesn’t work because I don’t have a for loop equipped yet

If you are still having problems with that code, please format it according to the FAQ. It helps us be able to understand your code as we try to help you.
https://discourse.codecombat.com/faq