# Level Hit and freeze introduction to bloonean (Lua)

#1

Blooneans sound simple enough from my understanding they are your true and false questions.

however I am having a problem with level/hit-and-freeze

``````local see = function()
local enemy = hero:findNearestEnemy()
local distance = hero:distanceTo(enemy)
if distance <3 then
return true
else
return false
end
end

loop
local enemy = hero:findNearestEnemy()
if see = true then
hero:attack(enemy)
else
hero:shield()

end
end
``````

I dont know why but it keeps attacking even if see returns false

#2

use == for equality testing

#3

I am not sure what you mean when I add =

``````if see == true then
``````

it still downâ€™t work

I can pass the level with

``````local see = function()
local enemy = hero:findNearestEnemy()
local distance = hero:distanceTo(enemy)
if distance < 2 then
hero:attack(enemy)
else
return false
end
end

loop
see()

end
``````

however I am certain thatâ€™s not how they wanted me to do it.

#4

ah! good point.

Do remember our discussion on functions?

``````if <boolean-logic-statement> then
...
end
``````

wants a value of true or false to be substituted for the `<boolean-logic-statement>`

`see()` is a function correct? It returns a true or a false value right? So we want to use it as a verb for the `<boolean-logic-statement>` in the if-then-else code block.

You remember how to do that correct?

#5

Ah I see that worked

I dint realize it was a verb thought it should remain a non when referred to.

on a side note
whats the if not prompt for Lua the level/useful-competitors instructions is written in python and

`````` if enemy:
if not enemy.type is "peon":
``````

is not any near right

I am taking two to four times as long on thees levels because almost every one of the instructions is written in another code lang.

#6

The following code should work

``````if enemy then
if not enemy.type == "peon" then

end
end
``````

Also use `~=` for A is not equal to B.

``````local a = 4
local b = 5
if a ~= b then
hero:say("The variable a is not equal to the variable b")
end
``````

#7

I just finished up converting over Hit and Freeze

#8

Follow this link for the starting code and hints for Useful Competitors

Let me know if that helps a little. This can be a rather tough level though.

-HW

#9

dose nothing it has to be ~=

``````if enemy.type ~= "peon" then
``````

thank you by the way I would have never gotten that one

ps
when you say your are updating them your not actually updating the game are you because mine donâ€™t.

#10

@LordMaddog Anyone in the community can submit patches for the levels. That is what I have been doing. Once the dev team has time to look, they can be added to the levels and updated. That is why I have also posted the content for the levels.