so I can’t seem to beat this level when most others seemed to be relatively easy. I simply get an error every time that says “function cleaveWhenClose() not defined”. The point of the level is to define a function and I feel as if I’ve put in all the code it requires as well as tried to play with it for hours to no avail.
`-- This shows how to define a function called cleaveWhenClose
– The function defines a parameter called target
if hero:distanceTo(target) < 5 then -- Put your attack code here -- If cleave is ready, then cleave target if hero:isReady("cleave") then hero:cleave(target) -- else, just attack target! else hero:attack(target) end end
– This code is not part of the function.
while true do
local enemy = hero:findNearestEnemy()
if enemy then
– Note that inside cleaveWhenClose, we refer to the enemy as target.
This is my code. Idk if it formatted correctly.