Level: Back to Back

In this level we are exposing players to more if/else logic. We’ve had some item equipping problems which we’re love to get feedback on. We’d also like to know about the fun level on this. Is it engaging?

Not sure if this is a bug but I could not finish the level until I remove the “self.say()” command that came pre-loaded. It seems that these two commands slow down the movement of the hero allowing the orge to kill the peasant. Also, at the end it say “FIre dispatches the ogres quickly”. How do i start a fire to get the XP and bonus?

2 Likes

Would be much better if the pre-loaded code is removed, it makes it a little too easy I guess.

@Enya Good point; I’ve removed those default say messages. I will also remove that other achievement, because that’s not relevant now.

@DollarAkshay Too easy to you, but maybe not too easy to beginning players. They still need a lot of practice with if/else. Now, if they are doing it without if/else, then it’s not so useful; maybe we can think of a way that it’ll be more required to use it?

im haveing a bit of trouble whean i if not enemy self.moveXY(40, 35) and my person dose not move back

When I removed the self:say command the code would not execute. However, with it, the code was too slow. If I kept the command, but put “” without anything in between the quotes, it worked.

In Clojure, the level of fun approaches zero. Please see my posting here for more information.

I am also working with Clojure and I don’t think the fun level is zero.
However, I have the following problem with my code:
The character is attacking an ogre and moving back afterwards. The problem ist, that it is not attacking long enough to kill the ogre. That means that it will move back to the middle and attack the same ogre again and going back to the middle. For each ogre it requires too much time to safe the peasants.

(dotimes [n 1000]
         
    (let [enemy (.findNearestEnemy this)]
        (if enemy 
                (.attack this enemy)
                (.say this "bla")
            
        ))
    (.moveXY this 40 33))

I also tried to insert another (.attack this enemy) instead of (.say this “bla”) but it wouldn’t work.

Anyone has hany suggestions?

```
must be on its own line (before AND after the code)

The two statements in the if are “true” and “false” so the say happens if the if is false

to do “two” things you need some thing which allows for multiple statements such as (do ) but :frowning: do is currently broken. (I am in the process of fixing the default level code to account for that.)

if you never need the “else” then use “when” instead of “if”

so:

        (when enemy
            "attack 1"
            "attack 2"
        )

if you need the “else” then you can do

(if enemy
    (when true
        "attack 1"
        "attack 2"
    )
    ( "else clause"
    )
)

or as a tricky player did

(if enemy
    (and ("attack 1") ("attack 2"))
    ("else"))
1 Like

Thank you very much!
I was wondering why do wouldn’t work…

You got it all wrong, RipFive! Why do you even think that “say” command was important, anyway?!?!

it said if it get the middle of the x it that u would win but i didn’t

HI @A_Valenti, please could you post your code so we an seen the problem. A screenshot of the level screen would also be good. Welcome to the forum btw!
Danny

it

thanks nice to meet u

Hi A_Valenti,

Welcome to the forum!

I think you’ll complete the level if you delete all the code after line 10 (and also delete lines 2 and 3). The point of the while True statement is that it will keep repeating, so you don’t have to put in multiple lines of hero.attack(enemy). I think these being in are just confusing the programme, so it marks as incomplete even though you have the correct code at the start.

Cheers,

Jenny