• 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 Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #15 on: January 24, 2014, 11:39:47 pm »
I think yours is just a bit too complicated for him.

I mean, I barely understood what it did.
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 #16 on: January 24, 2014, 11:43:16 pm »
I think yours is just a bit too complicated for him.

I mean, I barely understood what it did.
Hmmmm... Really?
You sure it wasn't the math.randomseed() part that threw you off?
That was just for intimidation- it's nothing more than a simple math.random() seed that does some funky time to a Unix time stamp. Nothing too special, just makes things look scarier and work a bit better. Wasn't asking him to get what it actually does... :P
« Last Edit: January 24, 2014, 11:46:00 pm by Princess Twilight Sparkle »
bw81@ulysses-forums ~ % whoami
Homepage

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #17 on: January 24, 2014, 11:47:29 pm »
No, not that. Maybe it was just your lack of spacing.  ???
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 #18 on: January 24, 2014, 11:48:36 pm »
Could be... It's difficult on mobile, though.
Especially a really laggy mobile device.
I'll edit it, though.
bw81@ulysses-forums ~ % whoami
Homepage

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 #19 on: January 24, 2014, 11:55:55 pm »
There we go. Any better?
bw81@ulysses-forums ~ % whoami
Homepage

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 #20 on: January 25, 2014, 06:38:31 am »
Code: [Select]
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 }
Couldn't you technically do this for the table value definitions?
It's a bit more confusing, but...
Code: [Select]
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 }
}
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. :)
bw81@ulysses-forums ~ % whoami
Homepage

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #21 on: January 25, 2014, 09:02:51 am »
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".
Out of the Garry's Mod business.

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 #22 on: January 25, 2014, 09:16:09 am »
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.
« Last Edit: January 25, 2014, 09:19:56 am by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #23 on: January 25, 2014, 09:28:03 am »
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".

"Clean" and "user friendly" is all relative. I personally find Short Circuit's version better, but I wouldn't bother to quibble over it unless we were specifically discussing it.

We have had many complaints/threats/suggestions for our projects and our code style over the years, but there was one that stuck with me more than any other. We have two tables for whitelisting stool's prop movement and deletion, called "ULib.delWhiteList" and "ULib.moveWhiteList". If you look at them, this comment is by these tables:
Code: Lua
  1. -- Are you a STOOL author who's angry that your tool isn't on this list?
  2. -- Just add this to your code:
  3. -- if ULib then table.insert( ULib.delWhiteList, "my_stool" ) end

Well, a few years back, we had someone at Facepunch discuss how terribly coded our projects were, and pointed at these two tables. The user said that if we were good programmers, we would have coded an API to manipulate these tables (add, remove, check for values). I was shocked, and continue to be shocked. What's the problem with calling table.insert? When working in someone else's code, I'd rather stick with the tools Lua already gives me (as long as it makes sense), than work with their custom API.

Anyways, this story just goes to show you that everyone approaches problems differently and there's no "best solution".
Experiencing God's grace one day at a time.

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #24 on: January 25, 2014, 09:43:19 am »
Wait, threats?

And I forgot to mention my table was not originally written for Lua.
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 #25 on: January 25, 2014, 09:48:15 am »
I personally find Short Circuit's version better...
OCD approved syntax. C;
bw81@ulysses-forums ~ % whoami
Homepage

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Learning Lua... (Just a random post from a lua super noob.)
« Reply #26 on: January 25, 2014, 10:20:38 am »
Wait, threats?

Ha ha, yes. Those are the most funny. ;)
Experiencing God's grace one day at a time.

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 #27 on: January 25, 2014, 10:33:49 am »
Ha ha, yes. Those are the most funny. ;)
I can assume so. :P
What kinds of threats do you get?
The typical "boycott Ulysses" or "tell people not to use this" stuff, or the "DDoS your site if you don't fix it now" kind of stuff? :P
bw81@ulysses-forums ~ % whoami
Homepage

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 #28 on: January 25, 2014, 05:35:07 pm »
Syn, another puzzle.
What gets output?
(If I'm still too easy on you, let me know)

Code: [Select]
a = 0
b = 10
c = 20
x = { 0, 100, 20, 99 }
for n = x[3], x[2], b do
   print ( n )
   if n == 50 then c = 60 end
end
"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 #29 on: January 25, 2014, 06:05:40 pm »
um. so i know a isnt anywhere in the answer
Lua Student

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

  • Print