• Print

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

0 Members and 1 Guest 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 #30 on: January 25, 2014, 06:07:00 pm »
I know it probably goes from 20 to 100 or 100 to 20 but I don't know what b does :p
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 #31 on: January 25, 2014, 06:14:54 pm »
Which, and how?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #32 on: January 25, 2014, 06:18:35 pm »
The third variable (b in this case) is a step.
See if that helps you.

Offline syn.

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 6
  • Lua Padawan
    • SynGaming
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #33 on: January 25, 2014, 06:25:04 pm »
you made a table with x which had 4 keys/values inside then with
Code: [Select]
for n = x[3], x[2], b do you chose the 3rd and 2nd Key/value which I'm assuming means they go from one to the other. but i dont know what "b" does in the previously shown code. :-* lol nvm Pres just replied and since it's a step it would mean that it goes either
    20             100
    30              90
    40              80
    50              70
    60      or     60
    70               50
    80               40
    90               30
    100             20
Lua Student

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

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #34 on: January 25, 2014, 07:14:50 pm »
Code: Lua
  1. a = 0
  2. b = 10
  3. c = 20
  4. x = { 0, 100, 20, 99 }
  5. for n = x[3], x[2], b do
  6.    print ( n )
  7.    if n == 50 then c = 60 end
  8. end
  9.  

Ignore, for a second, what is actually in that for loop.

The structure for a loop like that is

for n = a, b, c do

a is the starting value
b is the ending value
c is the step.

Now, let's go back into Jam's code.
There are 4 values in table x, but this code only uses 2 of them. The 3rd and the 2nd value inside of the table.

Now, try again. You are close, but you can't give two answers and just say "one of these is correct"

Offline syn.

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 6
  • Lua Padawan
    • SynGaming
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #35 on: January 25, 2014, 08:14:52 pm »
oh okay thanks pres I didn't know the order of the values and stuff. It's
20
30
40
50
60
70
80
90
100
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 #36 on: January 25, 2014, 10:18:07 pm »
Got it syn.
I'll delve more into tables and table specific for loop functions in my next puzzle.
Not right now though. (it's now ~115am my time, and I'm running on fumes)

In your learning, are you finding any challenges/questions you're having trouble with specifically?
Perhaps I, or MrPresident if he so feels, could make a puzzle or two specifically aimed at challenges you're specifically having.

Also, i just realized, this post may better fit in developers corner (it's both off-topic to ULX, and, it is learning development/code logic.)
"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 #37 on: January 25, 2014, 10:32:39 pm »
not having many problems anymore thanks to Mr.Pres I think I'm ready for a tiny bit more :)
Lua Student

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

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #38 on: January 25, 2014, 10:49:06 pm »
Pick a topic.

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 #39 on: January 26, 2014, 07:32:01 am »
Let's go table ipairs. :)
Just wait till I get to next statements inside the for loop.
Easy at first.
Code: [Select]
x = { 0, 100, 20, 99 }
for k, v in ipairs( x ) do
   print ( k, v )
   if k == 3 then print ( "I found " .. v .. "!") end
end
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #40 on: January 26, 2014, 10:10:13 am »
I am very glad there are people on here who aren't the usual "do this for me" type.

Good job on your efforts syn.
Out of the Garry's Mod business.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #41 on: January 26, 2014, 10:44:25 am »
I am very glad there are people on here who aren't the usual "do this for me" type.

Good job on your efforts syn.
Agreed on both statements. :)
bw81@ulysses-forums ~ % whoami
Homepage

Offline syn.

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 6
  • Lua Padawan
    • SynGaming
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #42 on: January 26, 2014, 02:22:24 pm »
Thanks guys:) I'm glad that theres people willing to help out a complete stranger on problem that has nothing to do with them, *clap clap* for ulysses team and everyone else who helps out!
Lua Student

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

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #43 on: January 26, 2014, 02:54:54 pm »
Thanks guys:) I'm glad that theres people willing to help out a complete stranger on problem that has nothing to do with them, *clap clap* for ulysses team and everyone else who helps out!

By the way, I'd like to hop on your server to check out how it's going.
Send me the ip sometime.
Out of the Garry's Mod business.

Offline syn.

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 6
  • Lua Padawan
    • SynGaming
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #44 on: January 26, 2014, 03:05:02 pm »
By the way, I'd like to hop on your server to check out how it's going.
Send me the ip sometime.
IP is: 50.31.23.82:27015
Everyone is welcome to join :)
Lua Student

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

  • Print