ULX

Author Topic: Learning Lua... (Just a random post from a lua super noob.)  (Read 14581 times)

0 Members and 2 Guests are viewing this topic.

Offline syn.

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 6
  • Lua Padawan
    • SynGaming
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #45 on: January 26, 2014, 03:15:42 PM »
I haven't added anything I've made myself to the server besided some really simple custom commands because TTT is confusing and I get stuck on where to put certain things and I don't really know much about gmod lua in general, also I can't seem to get ipairs :( I'll keep trying but any small hints on Jam's puzzle would be awesome:)
Lua Student

"The more you understand, the crazier you get."

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #46 on: January 26, 2014, 03:31:24 PM »
ipairs = indexed pairs
k = (index) key
v = value
ipairs gives you both (a pair) from the table parts.
The for loop goes through the table and assigns each variable (k, v) the respective key and value.

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline syn.

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 6
  • Lua Padawan
    • SynGaming
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #47 on: January 26, 2014, 06:02:53 PM »
ohh okay so k would be the third key in the table (20) and value would be it's value?
If so then it would be: "I found 20!"
Lua Student

"The more you understand, the crazier you get."

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #48 on: January 26, 2014, 06:07:40 PM »
ohh okay so k would be the third key in the table (20) and value would be it's value?
If so then it would be: "I found 20!"
Partially correct. There's more output than that.
What would all the output be?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

An Error Has Occurred!

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