Useful Competitors
```lua -- The coin field has been seeded with vials of deadly poison. -- Ogres are attacking, while their peons are trying to steal your coins! -- Attack the enemy only if the type is NOT equal to "peon".
while true do
local enemy = hero.findNearestEnemy()
if enemy then
if not enemy.type == “peon” then
hero:attack(enemy)
end
end
local item = hero:findNearestItem()
if item then
– Gather the item only if the type is NOT equal to “poison”.
end
end
<hr>
Overview::
In this level you'll need to use the `not` operator to filter your enemies and items!
`not` takes the logical inverse of a value and returns it:
```lua
-- Not in LUA is written as: "not".
hero:say(not false) # The hero says 'true'
hero:say(not true) # The hero says 'false'
To use in a conditional statement:
if not hero.isReady('cleave') then
-- Do something while cleave is on cooldown!
else
-- Cleave is ready.
end
Hints:
Use an if-statement
and not
to find items that are not type "poison"
.
if item.type ~= "poison" then
end
Additional hint
When the items are all gone on the game screen item
will equal nil
meaning nothing.