Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Bug? Help Please!

This may or may not be a bug as i am a noob :stuck_out_tongue: but i am on the level named lowly kithmen on world one and i go ahead make a 2nd variable for the level and i do it corretly BUT when i attack it goes expected , and other stuff? Any idea? Im pretty sure i made the variable because i did local enemy2 = self:findNearestEnemy for the 2nd enemy so any idea why or how , or even if this is a bug?

For A Snap Shot of this with details pointed out here

:wink: :smile: :wink:

The correct code is:
enemy1 = self.findNearestEnemy()
self.attack (enemy1)
self.attack (enemy1)

Its self. not self:

Use a dot instead of a colon

Actually @Mining_Magic is using Lua.

Though self:findNearestEnemy is a method, so it should be used like in the first example (enemy1).

(Error handling apparently isnโ€™t too human friendly for languages not JavaScript or Python.)

I believe youโ€™re missing the () to call the function:

local enemy2 = self:findNearestEnemy()
#                           here ---^^

Check again how it is done in the enemy1 assignment. :wink:

2 Likes

Thx that was the problem , again thx very much , didnt realize that was the problem :stuck_out_tongue: