Back to General discussions forum
Q: Do we choose the position of the hurkle ourselves, or is it stored in some global variables?
I get the error attempt to perform arithmetic on a nil value (global 'x') and thus wondering ...
Thanks for hint, I emphasized the words implement playable version of the game and added pick random coordinates for Hurkle to the step 2.
As a side note, I wanted to publish both problems (this and its opposite) simultaneously, but noticed yesterday at night you have logged into the site and suspected you've seen TestUser's attempts against the problem anyway, so opened it earlier :)
UPD so I quickly published the second part now... and as I see our new colleague tzyLee
already made some progress on the first, wow...
Thanks, understood.
Philosophical question: in the original game description, locations can have integer x and y values between 0 and 10. Is that a 10x10 or a 11x11 grid?
Also stumbled over this on first reading the description. Applying my meek archaeology skills :) found the bit surprising
answer - probably about lines 285-286
here - it seems
to be 0..9
range, a bit unnatural for non-programmer's perception (unless I'm missing something).
PyCharm users: you can download and install Lua from here, and then install the EmmyLua plugin in PyCharm - that allows you to develop and run Lua programs directly within PyCharm.
(thanks! added this advice to lua-quickstart instruction)
Don't know if this is part of the challenge, but I can't read the numbers with io.read().
Here the smallest source reproducible:
print('ready')
X, Y = io.read('*n', '*n')
print(X .. ' ' .. Y)
This fails for all tried names (X, x, ix, aaaix) for X, Y with:
/opt/lua: /test-ground/test.lua:3: attempt to concatenate a nil value (global 'y')
stack traceback:
/test-ground/test.lua:3: in main chunk
[C]: in ?
On local machine it works with lua5.3 and lua5.4.
What am I doing wrong?
Enrico, Hi!
Do you mean when running it with "sandbox" (i.e. clicking Lua
button below the code) or when submitting?
As for the button, it looks like working - just we need to keep in mind that input is read from the "Test Data" box.
P.S. and when running your submission, I guess, the checker will magically feed some (unknown) input by itself, as if human enters data...