• What's the dumbest mistake you've ever made in lua?
    171 replies, posted
Changing a bunch of files that I didn't have under revision control and didn't have any backups of... and completely breaking everything.
Not lua, but I had a database of all my bans, and I went to clear out the expired bans, so I did an if unban time < whatever time then remove it from the database. Unfortunately, all of my permabans were saved as 0. HNGGGGGGGGGGGGGGG
I once wrote a logging system for an admin mod I was working on. For some reason I thought it was a good idea to log every hook that was called on every plugin it had. The result was extreme lag and a few megabytes long log file filled with this: [code]17:31:05 - Event 'Think' called on mount 'Ticker' 17:31:05 - Event 'Think' called on mount 'Ticker' 17:31:13 - Event 'PlayerInitialSpawn' called on mount 'Ticker' 17:31:13 - Event 'Think' called on mount 'Ticker' 17:31:14 - Event 'Think' called on mount 'Ticker' 17:31:14 - Event 'Think' called on mount 'Ticker' 17:31:14 - Event 'Think' called on mount 'Ticker'[/code]
[QUOTE=Nevec;30820059]I once wrote a logging system for an admin mod I was working on. For some reason I thought it was a good idea to log every hook that was called on every plugin it had. The result was extreme lag and a few megabytes long log file filled with this: [code]17:31:05 - Event 'Think' called on mount 'Ticker' 17:31:05 - Event 'Think' called on mount 'Ticker' 17:31:13 - Event 'PlayerInitialSpawn' called on mount 'Ticker' 17:31:13 - Event 'Think' called on mount 'Ticker' 17:31:14 - Event 'Think' called on mount 'Ticker' 17:31:14 - Event 'Think' called on mount 'Ticker' 17:31:14 - Event 'Think' called on mount 'Ticker'[/code][/QUOTE] Thats just too awesome lol. Just done another one where I hit L instead of I and in notepad++ they look the same and ofcourse L was nothing so I was like "what".
Wondering why my code doesn't work and I turn red: [code]ent = data:ReadEntity() for _, v in ipairs( ents.GetAll() ) do ent:SetColor( 255, 0, 0, 255 ) end [/code] ent is from a usermessage with myself as the entity. That one took a while to figure out...
Confusing some arguments in timer.Create, resulting in a timer that was meant to network one big table once in a hundred seconds, once every second a hundred times. The result was a crashed server and 8 hours beating the shit out of the code until I found out that mistake.
Is it just me or is FP's login system constantly logging me out for no reason whenever I change pages? As for me, my big dumb mistakes usually come from confusing Lua syntax with one or two other scripting languages. For example, I'd write the following: [code]if variable = 19 then --stuff end[/code] Or, rarely: [code]if variable == 19 { --do stuff }[/code] And on very rare occasions, the two are combined, but it's only if I was previously scripting with a similar language...or if it's 4:30 in the morning. Happens less and less each script.
[QUOTE=HeadInjuryGames;30829474]Is it just me or is FP's login system constantly logging me out for no reason whenever I change pages? As for me, my big dumb mistakes usually come from confusing Lua syntax with one or two other scripting languages. For example, I'd write the following: [code]if variable = 19 then --stuff end[/code] Or, rarely: [code]if variable == 19 { --do stuff }[/code] And on very rare occasions, the two are combined, but it's only if I was previously scripting with a similar language...or if it's 4:30 in the morning. Happens less and less each script.[/QUOTE] remove your facepunch cookies.
I have a feeling everyone is just posting bad Lua code to try to feel witty ONE TIME I DID THIS [lua] print("super leet code) [/lua] I FORGOT THE END QUOTE!!
[QUOTE=Quark:;30841698]I have a feeling everyone is just posting bad Lua code to try to feel witty ONE TIME I DID THIS [lua] print("super leet code) [/lua] I FORGOT THE END QUOTE!![/QUOTE] Makes you feel witty huh?
Why would you print code as a single string? You know what code you're typing, wouldn't you want to print the value the code spits out?
I usually forget function arguments when I'm calling something like entity:GetPos()
[lua] timer.Create("1",1,1,function(ply) // wrong end) timer.Create("2",2,2,function() // right end,ply) [/lua]
[code]function TestCover(bool) TestCover(true) end[/code] Stack overflows up the ass, It took me 20 minutes to figure out what the hell was going on X_X
[QUOTE=zzaacckk;30843278][lua] timer.Create("1",1,1,function(ply) // wrong end) timer.Create("2",2,2,function() // right end,ply) [/lua][/QUOTE] You don't actually need to do anything like that all since "ply" is still in the same scope as that function. You should be able to use it just fine from there. [lua]local ply = Entity(1); timer.Create("ow", 1, 1, function() ply:Kill(); end);[/lua]
[QUOTE=DarKSunrise;30845556]You don't actually need to do anything like that all since "ply" is still in the same scope as that function. You should be able to use it just fine from there.[/QUOTE] Only if you define the function the timer runs in the same scope as the "ply" variable. [QUOTE=zzaacckk;30843278][lua]timer.Create("2",2,2,function() // right end,ply) [/lua][/QUOTE] Wrong. [lua]timer.Create("3",3,3,function(ply) // right end,ply)[/lua]
[QUOTE=Morcam;30843261]I usually forget function arguments when I'm calling something like entity:GetPos()[/QUOTE] But entity:GetPos() doesn't take any arguments:tinfoil:
[QUOTE=LauScript;30815951][lua] local steamid = tostring(pl:SteamID()) if (!steamid ) then return end local id = string.gsub( steamid,"STEAM","" ); id = string.gsub( id,":","" ); id = string.gsub( id,"_","" ); return id; [/lua] use that. not uid[/QUOTE] [lua] local steamid = playerobject:SteamID() local id = string.gsub(steamid, "STEAM_(%d):(%d):(%d)", "%1%2%3") return id [/lua] Do the first 2 numbers in the SteamID change?
My biggest mistake was big in a literal sense. I updated DarkRP to use chat.AddText, just after it was put in an update. I knew very little about injection, so serverside I just did: [lua]for k,v in pairs(ply.GetAll()) do v:SendLua("chat.AddText(<What one player said and some colours>)") end [/lua] I found out about it way after it was exploited. Now I know more about injections. :v:
[QUOTE=Loures;30948710][lua] local steamid = playerobject:SteamID() local id = string.gsub(steamid, "STEAM_(%d):(%d):(%d)", "%3") return id [/lua] Do the first 2 numbers in the SteamID change?[/QUOTE] Yes.
Fixed.
[QUOTE=CawldFussuian;30629358]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![/QUOTE] *misclicks funny rating* :(
I don't make mistakes in Lua. Lua makes mistakes trying to comprehend the kick ass scripts i write.
I somehow made it to where if I tired to change my class in my gamemode I would crash my game.
I was the mistake in lua.
[QUOTE=Remscar;30990844]I don't make mistakes in Lua. Lua makes mistakes trying to comprehend the kick ass scripts i write.[/QUOTE] Sorry you can't code remember?
[QUOTE=RetTurtl3;30994079]Sorry you can't code remember?[/QUOTE]Neither can you.
[CODE]starting lua[/CODE] :smile:
[QUOTE=RetTurtl3;30994079]RetTurtl3[/QUOTE] Why are you here? It says 'lua', as in the language you insult everyone on yet you can't do it. inb4box from Reherp
[lua]function GM:Think() for k,v in pairs(player.GetAll()) do tmysql.query("...") end end[/lua]
Sorry, you need to Log In to post a reply to this thread.