LUA Hunter Valley help needed

Failing in all aspects of this level.
For starters, the sample script is not in Lua, so the confusion begins immediately. This isn’t a new problem for me since a good amount of Lua levels have this problem, but it’s still frustrating when I rely on the samples for guidance…
Here is the start (and restart) script:
HunterValleyOther

And here is my attempt:
HunterValleyLua

As you can see, I’m stuck and not sure how to fix it.

I think I found the issue here:

Line 21
JavaScript (working):

var direction = route[routeIndex];

Lua (not working):

local direction = route(routeIndex)

Find the difference and correct as needed :wink:

(Hint: square brackets are used for indexing in both languages, as well as Python)

Thanks for the reply but I think my problem goes a little deeper than that.
After switching the (routeIndex) to […] I received this:
HunterValley20

Noticing that there was originally a [0] at the end of line 16 I replaced it and then received:
HunterValley17

Changing the value to [1] only stops the code at line 20 without error but the hero didn’t move and was killed as:
HunterValley20again

What do you think?

Any luck with this? I’m stuck in the same place. When I swap over to python, everything works fine. When I’m in lua, it’s throwing errors about the “hunter” variable. Either hunter doesn’t exist because it’s not finding a nearest friend OR hunter.route doesn’t exist (I can’t figure out which, and can’t figure out how to tell.)

As you said, this is not unusual for the lua levels, but definitely getting frustrating.

route.length is the JavaScript way to find array length.
For Lua, #route gives the length of the route.

Lua arrays usually start with index 1. (Check the line, local routeIndex = 0)

You can read this thread for more info:

1 Like

Thanks, that was exactly what I needed!