What's the dumbest mistake you've ever made in lua?
171 replies, posted
Post yer dumbest mistake mine would have to be;
[lua]
function GM:Think()
for _,v in pairs(player.GetAll()) do
if v:Health() < 1 then
v:Kill()
end
end
end
[/lua]
:bravo:
Also if they made you rage you must post it which will get you 10 e-peen points! :buddy:
[lua]function GM:Think()
for _, v in pairs( player.GetAll() ) do
if v:Nick() == "jrj996" then v:Ban( 0, "Bai" ) v:Kick( "Bai" ) end
end
end[/lua]
[lua]if varible != nil then[/lua]
Trying to code with absolutely no knowledge of it :eng99:
[QUOTE=G-Foce85;30629288][lua]function GM:Think()
for _, v in pairs( player.GetAll() ) do
if v:Nick() == "jrj996" then v:Ban( 0, "Bai" ) v:Kick( "Bai" ) end
end
end[/lua][/QUOTE]
Ooooh, clever.
[QUOTE=Thermadyle;30629304][lua]if varible != nil then[/lua][/QUOTE]
That its shorter doesn't mean its better.
a = false
b = nil
if a then print("a") end
if b then print("b") end
if a != nil then print("a!") end
Will print a!
I meant that I could just have done
[lua]if varible then[/lua]
instead of
[lua]if varible != nil then[/lua]
Not the dumbest thing but it's something that came to my mind.
Infinite loops. That don't trigger Garry's pseudo-protection.
None because I'm that good at lua.
Just because he rated me dumb..
I should've said I don't know because I'm not dumb like jrj996. :v:
[QUOTE=Thermadyle;30629620]I meant that I could just have done
[lua]if varible then[/lua]
instead of
[lua]if varible != nil then[/lua]
Not the dumbest thing but it's something that came to my mind.[/QUOTE]
Actually, the later method is commonly used when dealing with variables that aren't booleans. Both methods are the same in Lua, but in other languages nil (and null) don't always evaulate to false.
Yer, but in my case; I meant checking for nil and bool, I am just not very informative in my posts.
Oh, did not read properly; Informative of you.
[lua]var = var or nil[/lua]
[QUOTE=Grea$eMonkey;30636415][lua]var = var or nil[/lua][/QUOTE]
Stops it being false. Might not be a bad thing.
[lua]
x = bool and false or true
[/lua]
I could not remember on the orginal code but this example is really close.
[lua]
function Loop()
timer.Create("timer1", 1, 0, Msg, "....")
end
hook.Add("Think","lool",Loop)
[/lua]
[QUOTE=RetTurtl3;30635743]None because I'm that good at lua.
Just because he rated me dumb..
I should've said I don't know because I'm not dumb like jrj996. :v:[/QUOTE]
Calm down, it's a box.
aaactually..... a better one is
[lua]for ply:Kills() do[/lua]
cause I was pretty stupid back when i didn't know anything about lua :(
[lua]
function()
[/lua]
[lua]cam.End3D()[/lua]
[QUOTE=_Chewgum;30651403][lua]
function()
[/lua][/QUOTE]
Herp, I've done that too :v:
[editline]23rd June 2011[/editline]
Did someone just come in here and rate us all dumb?
You can disable the ratings in your control panel.
Actually, I once wrote a e2 extension that allowed e2 to access DamageInfo, the problem was, I had an e2 that fired bullet using another custom function on a timer, but whenever the bullets hit something all the damage hooks were removed due infinite loop.
It turned out that while the e2 trigger status was still set to timer when it was triggered by runOnDamage since bullet impacts are instant apparently(the more you know).
It was a hell to figure out what exactly crashed it.
The stupidest thing I've ever done is remove the world entity,
[lua] for k,v in pairs (ents.GetAll()) do v:Remove() end [/lua]
Crashes your game, oh and I've done cam.End3d
[QUOTE=Nevec;30653616]You can disable the ratings in your control panel.[/QUOTE]
Shh, don't tell Science, next thing we know we won't be able to rate him dumb anymore.
:ohdear: Don't do it, but also I just derped it up a bit more, I made a panel popup in my chatbox and my GMod crashed along with my graphics card. :buddy:
Writing a whole thing without checking constantly for errors, then when it comes to running it: ERRORS.
Or, a slight syntax error that takes me 5 hours just to find and fix.
One time Kogitsune and I were dual coding something in Gobby (multiplayer text editor, its friggin sweet)
I was testing the code after an edit, it errored, I told him the line number, we both scroll to it and what do we find?
Nothing on the line but the following
[code]
dmginfo.Toaster
[/code]
No variable set to it, no manipulation of it whatsoever, one of us just blanked out and typed toaster for some reason. Mind you this was at 6 am after we were up all night coding straight a few years back.
Lets just say I don't think either of us had laughed that hard at a programming fuck up in our entire lives, and I know I haven't since.
[code] '=' expected near '<eof>' [/code]
:confused:
[lua]dmginfo.Toaster[/lua]
:specialschool:
The times I've been debugging for hours at completly wrong place to find out that I've missed a quote at another place.
Why is czmate10 mate rating everyone dumb?
Also, once wiped out my whole mysql database by accident, its rather SQL related but I did it in lua after all.
Sorry, you need to Log In to post a reply to this thread.