Demo code for Reward and Ruination (Lua) seems to be written in another language

This is what pre-populates the code pane when I load into the above level under Lua mode. Unless I’m mistaken it is JavaScript (at least it doesn’t look like any Lua I’ve encountered so far).

// It seems like the Ogre Chieftain is stealing your gems!
// Use the two artillery cannons to defeat your enemies and gather the gems.

while(true) {
    var enemy = hero.findNearestEnemy();
    if(enemy) {
        var enemyPos = enemy.pos.x + " " + enemy.pos.y;
        hero.say("Enemy at " + enemyPos);
    }
    // Now that you have sweet revenge, why not have your cake and eat it, too?
    // Find the item's position and say it for your artillery to target.
    
}
1 Like

It is. Did you make sure you reset the level? If you did and this is consistent, please contact one of the level coders

1 Like

By resetting the level do you mean using that reload icon in the top right corner of the code pane? Because if so then yes I did do that. I also logged in again today from a completely different computer and the problem is still there.

1 Like

Yes the reload icon is basically the reload button. Now since you tried it on another computer and the problem still was there, unless the reload icon works, its a bug. You should post it on our GitHub issues page.

1 Like

I don’t have an account for GitHub but please feel free to log it on my behalf. Thanks.

1 Like

The Blind Distance level seems to have the exact same problem as well.

// Tell the wizard the distance to the coming ogres.

// This function finds the nearest enemy and returns the distance to it.
function nearestEnemyDistance() {
    var enemy = hero.findNearestEnemy();
    // If there is no enemy, the function returns 0.
    var result = 0;
    if (enemy) {
        result = hero.distanceTo(enemy);
    }
    return result;
}

while (true) {
    // Call nearestEnemyDistance() and
    // save the result in the variable enemyDistance.
    var enemyDistance = nearestEnemyDistance();
    // If the enemyDistance is greater than 0: 
    
        // Say the value of enemyDistance variable.
        
}
1 Like

I also do not have an account on GitHub because I haven’t encountered any bugs. @nick, do you have any suggestions?

1 Like

We just don’t have Lua sample code for all the levels yet, so when it doesn’t exist, you see the JavaScript instead. Lua patches from the level editor are welcome!

1 Like

Don’t mean to revive this thread if its not wanted…

Here is the what possibly should be the start code for Lua in Reward and Ruination

However in Lua if the code is changed near exact the hero will add the pos values together and say the total value… ie the x pos value 43 and y 57 will be added together and the hero will say 100

Here is that bit of code…

        local enemyPos = enemy.pos.x + enemy.pos.y
        hero:say("Enemy at " + enemyPos)

Here is how it should look to my guessing I had to use two separate local’s to solve the problem above

-- It seems like the Ogre Chieftain is stealing your gems!
-- Use the two artillery cannons for your goals.

while true do
    local enemy = hero:findNearestEnemy()
    if enemy then
        local x = enemy.pos.x
         -- Get the enemy's y position!
        local y = enemy.pos.y
         -- say the x and y position separated by a comma
         hero:say("Enemy at " + x + "," + y)
    end
    end
   
    -- Now that you have sweet revenge,
    -- why not have your cake and eat it, too?
    -- Find the item's position and 
    -- say it for your artillery to target.
    
end