[QUOTE=c-unitV2;29746630]let me clean up his code real quick then[/QUOTE]
"Let me clean up his code real quick then. Yes, dump the garbage right there. See, it's cleaned up!"
Either you are trying to troll or you are just not of any help. Your code is usually more complicated and more unclean than the original code.
However, back to topic: Using a global variable or not really depends on the usage. Assuming he wants to save the money for some HUD stuff, he'd rather save it in a global variable (I'm separating UI-code and script-code, therefore a file-local doesn't work) with an unique and identifying name ("money" isn't something that sounds global or anything. "MONEY" is better (I'm assuming it's a "constant" in the sense that the server only is able to change it), perhaps saving it in the LocalPlayer-table is superior - depends on the design). If it is, however, thought to do something (for example, change a panel description) or something that requires that the money is only used within the function, a local does as well. And the third alternative, the local-on-file-scope would be useful, and that's my favourite, if he has a file specially designated for this stuff on the client. A file which receives updates about money and has at least a function to access the current money (and perhaps a few hooks that the script can use to react when the money changed, but that's really advanced).
So, tl;dr: I'd prefer (I wouldn't call my umsg "sendDollars" though, more like 'MoneyUpdate' or anything like that - after all, it's an usermessage, it's obvious that it is sent) something like
[lua]
--[[ cl_money.lua ]]--
-- We're storing the money in here.
local money = nil
-- Upon receiving money.
local function ReceivedSendDollars(msg)
money = msg:ReadLong()
-- Do something with money directly, i.e. forcing panels to update the text,
-- printing a message, doing a fancy dollar effect on the client.
end
usermessage.Hook('sendDollars', ReceiveSendDollars)
-- Returns the current money.
function GetMoney()
return money
end
[/lua]
[QUOTE=Zaubermuffin;29756117]Words[/QUOTE]
This is all a matter on opinion it comes down to how you like to manage your projects, if I am working on a new feature for a project I like to make a new file for it and keep everything local and if I want to access it somewhere else I will make a function to do that. I fail to understand why you are trying to argue why your opinion is the correct way to do things since people like doing things the way that works best for them. If you want to get nitpick then
[lua]local money = nil[/lua]
Should be
[lua]local money[/lua]
In the future if you are going to try and learn from C-units code I suggest you don't since he is... I don't really think I need to say it.
C-Unit should be banned from replying in the Lua section.
[QUOTE=Freze;29756355]C-Unit should be banned from replying in the Lua section.[/QUOTE]
He is still learning I understand that but at-least he is more helpful than lets say for example Science
[QUOTE=King Flawless;29756308]blorp.[/QUOTE]
I'm not learning anything from c-units code (except how to [i]not[/i] code perhaps). I would say that I can program in lua pretty well - initializing all values, and if it's just nil, is something I'm used to from Perl and C++.
Also, this all is a matter of style and I did not say or want to imply that my way was the best - I just wanted to show some ways how it [i]could[/i] be done (and providing the one I found the most usable - personal opinion). I'm sorry if it sounded like that.
[QUOTE=King Flawless;29756362]He is still learning I understand that but at-least he is more helpful than lets say for example Science[/QUOTE]
I agree. They shouldn't be replying, but posting questions instead. Learn before answering.
[QUOTE=Freze;29756469]I agree. They shouldn't be replying, but posting questions instead. Learn before answering.[/QUOTE]
If that was true this lua section would be a lot cleaner, I tell them time and time again but they don't learn so I give up on that dream and I will just continue acting like the jackass that I am.
Gentlemen. Get your hunting rifles.
[QUOTE=King Flawless;29756511]If that was true this lua section would be a lot cleaner, I tell them time and time again but they don't learn so I give up on that dream and I will just continue acting like the jackass that I am.[/QUOTE]
No, no.
Your just a jackass in general.
[QUOTE=Science;29760019]No, no.
Your just a jackass in general.[/QUOTE]
Aww sorry didn't know I was hurting your feelings
[QUOTE=King Flawless;29760218]Aww sorry didn't know I was hurting your feelings[/QUOTE]
This is the internet, You cant get hurt.
You wanna come down my end and we sort this with our fists once and for all?
[QUOTE=Science;29760389]This is the internet, You cant get hurt.
You wanna come down my end and we sort this with our fists once and for all?[/QUOTE]
Lmao, how old are you? :fireman:
[QUOTE=King Flawless;29760408]Lmao, how old are you? :fireman:[/QUOTE]
15.
I dont give a shit how old you are, you think you can hurt my feelings? Then come do it face to face.
[QUOTE=Science;29760498]15.
I dont give a shit how old you are, you think you can hurt my feelings? Then come do it face to face.[/QUOTE]
Us lua coders don't like social interaction, I challenge you to a code war do you accept?
[QUOTE=Science;29760498]15.[/QUOTE]
I threw some water bombs at 15 year olds today. Then we locked them in a building with cable ties.
Oh the fun of leaving school.
[editline].[/editline]
[code]20:05 - Flapadar: Playing time: 100.7 hrs past 2 weeks
20:05 - King Flawless -Kingdom of today: Hmm?
20:06 - Flapadar: He spends approx. 68 hours every 2 weeks not playing GMod
20:06 - King Flawless -Kingdom of today: Lol
20:06 - Flapadar: Of those, 60 are in school
20:06 - King Flawless -Kingdom of today: Wow
20:06 - King Flawless -Kingdom of today: the zing
20:08 - Flapadar: Oh
20:08 - Flapadar: I just accounted for the other 8 hours
20:08 - Flapadar: Source SDK - 5 hours
20:08 - Flapadar: CSS - 2 hours
[/code]
[QUOTE=FlapadarV2;29761000]
[code]20:05 - Flapadar: Playing time: 100.7 hrs past 2 weeks
20:05 - King Flawless -Kingdom of today: Hmm?
20:06 - Flapadar: He spends approx. 68 hours every 2 weeks not playing GMod
20:06 - King Flawless -Kingdom of today: Lol
20:06 - Flapadar: Of those, 60 are in school
20:06 - King Flawless -Kingdom of today: Wow
20:06 - King Flawless -Kingdom of today: the zing
20:08 - Flapadar: Oh
20:08 - Flapadar: I just accounted for the other 8 hours
20:08 - Flapadar: Source SDK - 5 hours
20:08 - Flapadar: CSS - 2 hours
[/code][/QUOTE]
How do you fit in the time for your boxing lessons Science?
[QUOTE=King Flawless;29761187]How do you fit in the time for your boxing lessons Science?[/QUOTE]
Sorry i dont box, But i do work out.
also, maybe if you bothered to look, i leave my pc on all day and night.
I was out yesterday and the day before and the day before. Im also going out tomorrow and saturday.
Theres too much shit on here to wait 5 minutes to start it all up so i just leave it on instead.
[editline]11th May 2011[/editline]
Some maths for you.
24 hours x 14 days = 336 hours.
93.9 hrs on gmod
4.3 hrs on Sourcesdk
2.3 hrs on css
= 100.5
+ 0.2 for the extra games.
[B]= 100.7 hours in the last 2 weeks.[/B]
6 hours of school plus 1 hour and 30 mins travel time per day = 7.5 hours.
[B]7.5 x 5 = 37.5 x 2 weeks = 75 hours of school.[/B]
So that at the moment is:
100.7 + 75 = 175.7 hours
336 - 175.7 hours = 160.3 hours of freetime.
Sleep time on average is about 11:00pm till 6:45 am so that is 7 hours and 45 mins sleep a day x 14 is 99hours and 30 minutes so at this time i have [B]61 hours of freetime.[/B]
Theres probably a few more things that are not constant variables and cannot be monitored or counted over 14 days so i have around 61 hours of freeday.
Learn 2 Maths next time you want to be smart.
[QUOTE=Science;29761345]Lmao[/QUOTE]
I think the lua section has learned something valuable today don't mess with Science because he is an internet tough guy. What he lacks in programming skills and IT knowledge he makes up for in being able to challenge people he has never met before to a fight via the internet that shows he is a true american hero.
You have yet to comment on my challenge so I am guessing that's a no
You forgot to count time for eating, showering (If you do so) and other such time-consuming activities which eat into your all-so-precious 4.3 "free" hours per day.
And hey, at 15 you're probably doing basic algebra, so don't bother talking down to your superiors.
[QUOTE=FlapadarV2;29761618]You forgot to count time for eating, showering (If you do so) and other such time-consuming activities which eat into your all-so-precious 4.3 "free" hours per day.
And hey, at 15 you're probably doing basic algebra, so don't bother talking down to your superiors.[/QUOTE]
Your forgetting all the time he spends at the gym as well
I normally spend a minimum of hour at the gym 3 days a week, so that's a nice chunk out of your free time
[QUOTE=FlapadarV2;29761618]You forgot to count time for eating, showering (If you do so) and other such time-consuming activities which eat into your all-so-precious 4.3 "free" hours per day.
And hey, at 15 you're probably doing basic algebra, so don't bother talking down to your superiors.[/QUOTE]
Basic Algebra? Lol?
Also, i do decline your challenge cause i dont have time for people like you to fight with 24/7 and i aint that good of a scripter.
[img]http://skiddiecentral.us/img/fish.jpg[/img]
Is this nuff said?
[QUOTE=Science;29761660]
[img_thumb]http://skiddiecentral.us/img/fish.jpg[/img_thumb]
[/QUOTE]
O god I love it
Seen as you didn't comment on the level of maths you are doing, I assume I was correct in my assumption.
Oh and while you're at it you should phone Flawless using the number on skiddiecentral I hear he likes a good conversation.
It's 1-888-843-4564 if you can't find it.
[QUOTE=King Flawless;29761691]I god I love it[/QUOTE]
Errr. No you are not god, far from it.
You are about this far down the scale.
|-God is here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|-Troll here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|-Your about here flawless.
[editline]11th May 2011[/editline]
[QUOTE=FlapadarV2;29761702]Seen as you didn't comment on the level of maths you are doing, I assume I was correct in my assumption.
Oh and while you're at it you should phone Flawless using the number on skiddiecentral I hear he likes a good conversation.
It's 1-888-843-4564 if you can't find it.[/QUOTE]
I didnt comment cause i actually thought you was joking.
[QUOTE=Science;29761719]Dumb[/QUOTE]
I look a lot more like flapjacks picture on that site actually
This thread has definitely gotten out of hand.
This thread was about a guy needing help with a Lua question, and you people have turned it into a flame war. If you feel the urge to fight like little kids, then please do so via PM's.
[QUOTE=Jocken300;29761825]This thread has definitely gotten out of hand.
This thread was about a guy needing help with a Lua question, and you people have turned it into a flame war. If you feel the urge to fight like little kids, then please do so via PM's.[/QUOTE]
PM's can only have 2 people, this involves the whole board.
when its in public its a lot more fun
[QUOTE=c-unitV2;29761845]when its in public its a lot more fun[/QUOTE]
c-unitV2 gets involved. Great, Twice the flawless.
Anything below this line is more shit posting
________________________________________________________________________________________________
We still manage to carry on fighting even after the admin tells us not to.
Someone go make a thread and ill carry this fight on there.
[QUOTE=Science;29761842]PM's can only have 2 people, this involves the whole board.[/QUOTE]
Guys I think we all need to back off Science is a member of the gym and he will challenge you to a fight if you go up against him.
[editline]11th May 2011[/editline]
[QUOTE=Science;29761859]c-unitV2 gets involved. Great, Twice the flawless.[/QUOTE]
0.5 more flawless
Sorry, you need to Log In to post a reply to this thread.