Greed freezes with code but no error

The code I wrote for the Greed challenge shows no errors, and casts within a short amount of time (allowing me to believe I’m well within 4,000 statement limit) but after it casts, nothing happens. My peasant doesn’t move, and neither does the enemy peon.

I also have nothing from the Just In Time Debugger. It shows me some values if I hover over them, and those values seem to represent end of loop values, telling me that the peasant should have received the move command properly.

I’m using Google Chrome Version 34.0.1847.137 m.

My in game username is NovaHorizon

Any assistance would be appreciated. Thank you.

Took a look just now. I think you need to add return item to your assignItem function, and also use the return value: var item = assignItem(peasant, peasantIndex);. The item variable in your assignItem function is not visible in the outer scope, so it’s not defined when you go to tell the peasant to get it.

Oh, hah. That’s what I get for trying to copy and paste lines into a new function xD. I did totally mis-read that scope. Thanks for the help! It is working now.

(I’m unsure why the debugger didn’t give me an error for using an undefined variable though, and why the enemy peon didn’t move, but it’s not vital.)

Ah yeah, our transpiler differs from JavaScript a bit in that it won’t throw an error when you try to reference a variable that doesn’t exist. I have it on my list to fix that, but it may be a while before I feel wise enough to dig into it!

The debugger also isn’t smart about scopes, so it thought the item inside the function was the same as the item outside. Getting proper scope support there will be a fun time; also on my list. Sorry about those bugs.