• What's the dumbest mistake you've ever made in lua?
    171 replies, posted
Read the goddamn title... [lua] sefl:DoStuff() [/lua]
[QUOTE=Loures;31932959]Read the goddamn title... [lua] sefl:DoStuff() [/lua][/QUOTE] I was correcting him -_-
[QUOTE=James xX;31932926][lua] for i=1, #player.GetAll() in pairs( player.GetAll() ) do print(k, v) end [/lua] :P[/QUOTE] I've done that too lol
On Topic: [lua]LocalPlayer():Concommand("kill") --I make this fucking typo all the time[/lua] Off Topic: [QUOTE=LauScript;31061096][lua] al = { } al["a"] = "RTHFGSDHDFSP}{)_+&($@#%*$(#%F^" al["b"] = "RRNAHAFDYBRTBSFBH*()&#$%*$(#*(^" al["c"] = "CFGPADFBYRAYAEBYPAORAY*)((@#$^" al["d"] = "#mM|DRSVRTOSGHK*&)@#$^" al["e"] = "&840GHSBFSTUJHYD@#$%*()GHJK}^" al["f"] = "456$$SDRATVSRT#$%GFU)*(^" al["g"] = "@4NAEVYAERYERAYR*()&@#$GDF{^" al["h"] = "234RFREVYSDTSUBFTUNSFGJ:{}&(&(%^" al["i"] = "2346$DABRTDYBRSUFGJYI*(*)&#^" al["j"] = "(%}{:SFHVRSVY#$!%#$_&*H^" al["k"] = "TTR#@@#@%*&_GHDFJ^" al["l"] = "3456fghDFZBYTF)&_()@#$@^" al["m"] = "678#SFTNVJHOV<<<<<<SDSH#!$%*(^" al["n"] = "2345#7IKJYBEV*)&@#$$%DHG^" al["o"] = "FROPrF$%TARBUSFBGUYSFGHRTF#$@(*&^" al["p"] = "NOLP!@#%SDFHG&*()FGDHB%^" al["q"] = "347HSBRTUVSRTUSGJ@#$%&*()(*&FHJK^" al["r"] = "PPAERBDYIFHJDYBTIDYHGDTNDITY#$@%#^" al["s"] = "RnPQESBYIDTYJDGHJ@#$!$#%&*()J^" al["t"] = "SSTCGFHBIO((&*_(@@!%DF^" al["u"] = "#%7V@#%DSHFGNFY&*)(__+^" al["v"] = "XXR+!@#%!DSAGFSDYKF*&*)#$%@^" al["w"] = "SSNTRPDFOHRTKMHF:JTR55MFHG5IPR7THFO^" al["x"] = "347HfDFGRET%HFGhfGgfGHrth456346457#$%346$%&hfg^" al["y"] = "DSPRDFGSHRTUDHR%$$%TRT#%^" al["z"] = "4lfK>@!#$WEAGDFG*()*FGH#$#$@%^" function Convert( l ) if ( al[ l ] != nil ) then return al[ l ] else print( al[l] .. " was nil.") end end function stringtokey( li ) local mct = string.Explode( "^", tostring(li) ); local len = string.len( tostring(li) ); tst = { } for i= 1, tonumber(len) do table.insert( tst, Convert( mct[i] ) ) end return table.concat( tst ) end [/lua] not a mistake, i have no idea why i wrote this. i don't know when i wrote it. it was just on my desktop. i don't even see the point of it, really.[/QUOTE] mind if i use this? :p
Yesterday I was looping through a table, returning false if something wasn't right :/ [lua] for k, v in pairs(player:GetWeapons()) do print(v:GetClass().." : "..v:GetNWString("ItemID")); local weaponSearch = RP.item:GetWeapon(v); if (weaponSearch and string.lower(weaponSearch.ammoClass) == string.lower(self.ammoClass)) then weaponTable = weaponSearch; else player:Notify("You need a gun that uses that ammo!"); return false; end; end; [/lua] I don't know how I managed to not realize that return false was terminating the function. I hate when you look over little things >.< Of course I fixed it though [lua] for k, v in pairs(player:GetWeapons()) do print(v:GetClass().." : "..v:GetNWString("ItemID")); local weaponSearch = RP.item:GetWeapon(v); if (weaponSearch and string.lower(weaponSearch.ammoClass) == string.lower(self.ammoClass)) then weaponTable = weaponSearch; end; end; if (weaponTable) then player:GiveAmmo(self.rounds, self.ammoClass); player:SetAmmoData(); self:RemoveInventory(player); else self:Notify("You have no weapon equiped that uses that ammo!"); end; [/lua]
[lua]function blah9) [/lua] That and other little typo's, or completely flawed logic on my end.
[QUOTE=James xX;31932926][lua] for i=1, #player.GetAll() in pairs( player.GetAll() ) do print(k, v) end [/lua] :P[/QUOTE] If you [B]really[/B] want to correct people, atleast show them the right code.
[lua] table = {} local function table.Test() end [/lua] :suicide: The worst part about it is that the error message is not helpful at all.
[CODE] if condition ~= true then --something wait() else --something else end [/CODE] I don't remember the exact content, but that's pretty much what I did.
[QUOTE=Loures;31944765]If you [B]really[/B] want to correct people, atleast show them the right code.[/QUOTE] Wait was he trying to correct me? [lua] local _ply = player.GetAll(); local i; for i=1, #_ply do print(i, _ply[i]); end [/lua] At least try and correct me in an efficient manner
since when do you have to set a localized i in that
[QUOTE=Banana Lord.;31948141]since when do you have to set a localized i in that[/QUOTE] Its just preference
It's pointless since the for loop creates it's i variable in it's own scope, thus your local i will never be used. [editline]26th August 2011[/editline] But the luA compiler most likely disposes of it anyways so it's not a problem. [editline]26th August 2011[/editline] Nope, seems it keeps the local (read: you're a psychotic monster and a criminal for wasting memory!)
Was trying to get brush-based planetary gravity working a day or two ago, it refused to work. Then I reset the collision bounds with lua_run and it worked, turned out I was setting up the original collisions [i]before[/i] I spawned the entity, so they just got reset to nothing again.
[lua] if data.group == "NULL", then do data.group = "User" end if data.priviliges = "NULL" then data.priviliges = "" end if data.warnings == "NULL" then data.warnings = "" end [/lua] I nearly kicked myself when I noticed this. This is what happens when I get up the early side of noon :v:
If typos count, I spent nearly 2 hours searching for a problem when I just typed %% instead of &&. :\
[QUOTE=Drakehawke;31951983][lua] if data.group == "NULL", then do data.group = "User" end if data.priviliges = "NULL" then data.priviliges = "" end if data.warnings == "NULL" then data.warnings = "" end [/lua] I nearly kicked myself when I noticed this. This is what happens when I get up the early side of noon :v:[/QUOTE] I didn't get what was wrong for about a half hour.
Even experienced coders make silly mistakes. It's part of the job/hobby.
timer.Simple(1, function() print("shit") end) It's not the dumbest, but it's one I make fairly often.
[QUOTE=PortalGod;32050535]timer.Simple(1, function() print("shit") end) It's not the dumbest, but it's one I make fairly often.[/QUOTE] There's nothing wrong with that code. Do you mean to say you use lambada functions in inefficient ways?
[QUOTE=Slight;32050772]There's nothing wrong with that code. Do you mean to say you use lambada functions in inefficient ways?[/QUOTE] It's pointless, you should be doing timer.Simple(1, print, "shit") instead. It's making a function to call a function.
[QUOTE=PortalGod;32050839]It's pointless, you should be doing timer.Simple(1, print, "shit") instead. It's making a function to call a function.[/QUOTE] FUNCEPTION.
Sorry, you need to Log In to post a reply to this thread.