I’m obviously a big fan of the Corona SDK. Thus far it’s the tool I’ve used to create all my apps. CoronaLabs’ easy-to-use software and API libraries, combined with the not-so-steep learning curve of the Lua programming language make it less daunting for new developers to jump into the game without sacrificing much flexibility (now for free!). Additionally, the SDK’s online user community has rightfully earned a reputation for being a helpful and involved bunch—even the trolls on the Corona Forums are sort of lovable in their own way. (Alex M., someday we’ll make you smile!)
In the last year, it’s been interesting to see the Corona community grow from a grassroots-style collection of independent developers communicating on forums into more of a cottage industry: there’s now a weekly podcast (CoronaGeek), occasional Corona-only Game Jams (like the upcoming 48-hour GIG Jam) and even a glossy monthly magazine, CoronaPaper.
On more than one occasion, CoronaPaper has ended interviews with developers by asking them to answer an old riddle with a Corona twist: How would they get an elephant into a refrigerator using Corona and Lua? Now I’m still a small fry in the app development game, and unlikely to get interviewed by a magazine—even though CoronaLabs recently declared me one of the three Most Interesting Developers in the Universe—but that didn’t stop me from coming up with my very own answer to this question.
And without any further ado, I’m pleased to present Operation Dumbo (temperature) Drop!
local function DumboTempDrop()
for i = #animalCrackersBox, 1, -1 do
local cracker = animalCrackersBox[i]
if cracker.shape=="bear" then
mouth:chomp(cracker) -- bears were always my favorite
elseif cracker.shape=="elephant" then
table.remove(animalCrackersBox, i)
refrigerator:insert(cracker)
timer.performWithDelay(3600000, eatFridgeCrackers) -- we'll eat in an hour!
end
end
end
So, dear readers: how would YOU get an elephant into a refrigerator using Corona and Lua?
Beginners mistake. Use the loop in reverse from the last element to 1.
Good call! I’ve updated the original post so that the for loop iterates backwards. Thanks for reading and posting!
The following is invalid syntax, you probably meant for keyword to go the lhs of the name making cracker local to the for body.
cracker = local animalCrackersBox[i]
Yikes! I was apparently way off my game when punching this into the blog. I’ve updated the post. Thanks for reading!