General > Developers Corner

Learning Lua... (Just a random post from a lua super noob.)

<< < (5/11) > >>

Bytewave:

--- Quote from: Neku on January 24, 2014, 10:48:14 PM ---
--- Code: ---MEDAL[1] = { "Pasta Lover", "Obtain some yummy pasta.", 5 }
MEDAL[2] = { "Panty Thief", "Steal some underwear.", 10 }
MEDAL[3] = { "Pig Molester", "Bother a harmless pig.", 5 }
MEDAL[4] = { "Crisis", "Drop into crisis mode for the first time.", 5 }
MEDAL[5] = { "Error", "...", 20 }

--- End code ---

--- End quote ---
Couldn't you technically do this for the table value definitions?
It's a bit more confusing, but...

--- Code: ---MEDAL = {
{ "Pasta Lover", "Obtain some yummy pasta.", 5 },
{ "Panty Thief", "Steal some underwear.", 10 },
{ "Pig Molester", "Bother a harmless pig.", 5 },
{ "Crisis", "Drop into crisis mode for the first time.", 5},
{ "Error", "...", 20 }
}

--- End code ---
That would create table rows, would it not?
I know it's slightly impractical... :P
Wasn't quizzing anyone, by the way...
I was just curious if I learned that correctly. :)

Neku:
That works, but I prefer cleaner and user friendly code.

Mine would be obvious to whoever uses it that "here's how you edit it".

JamminR:
Good job Syn.

Guys, don't overwhelm him with 20 different ways to do tables.
One or two at a time.
Simple at first. Mine was simple enough, but had extraneous information to provide the challenge.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given

[0] Board index

Go to full version