• Your Idea of 'Pretty' Code?
    101 replies, posted
[QUOTE=Rocket;52100153]In some sort of hypothetical Clojure-like dialect of Lisp that worked with Garry's Mod functions and libraries: [code] (hook.Add "Init" "PrintIdiot" (fn [] (do (def idiot LocalPlayer) (if (= (idiot:Name) "Wavie") (print (.. (idiot:Name) " is an idiot.") (print (.. (idiot:Name) " is cool."))))))) [/code][/QUOTE] my god... [editline]13th April 2017[/editline] [QUOTE=Paperlacks;52099465]howcome your avatar is the lua icon ?[/QUOTE] Because I want it to be.
[QUOTE=Wavie;52100799]my god... [editline]13th April 2017[/editline] Because I want it to be.[/QUOTE] Cuz he is lua gOd. Obviously...
[QUOTE=MrRalgoman;52100808]Cuz he is lua gOd. Obviously...[/QUOTE] I'm [B]horrible[/B] at Lua.
[QUOTE=Rocket;52100268]Of all the indentation styles, you pick two spaces?[/QUOTE] It's used in the Lua Reference Manual, Programming in Lua, and Beginning Lua Programming. Not to say it's what you should use, but if you started learning from any of those and didn't have much experience with languages beforehand to already have an opinion on it.
[QUOTE=Rocket;52100153]In some sort of hypothetical Clojure-like dialect of Lisp that worked with Garry's Mod functions and libraries: [code] (hook.Add "Init" "PrintIdiot" (fn [] (do (def idiot LocalPlayer) (if (= (idiot:Name) "Wavie") (print (.. (idiot:Name) " is an idiot.") (print (.. (idiot:Name) " is cool."))))))) [/code][/QUOTE] In Hypothetical Haskell it does look nicer imo [code] addPrintIdiotHook :: IO () addPrintIdiotHook = Hook.add "init" "PrintIdiot" $ do idiot <- localPlayer let idiotStatus = if name idiot == "Wavie" then "an idiot" else "cool" print $ name idiot ++ " is " ++ idiotStatus ++ "." [/code]
[QUOTE=FPtje;52103312]In Hypothetical Haskell it does look nicer imo [code] addPrintIdiotHook :: IO () addPrintIdiotHook = Hook.add "init" "PrintIdiot" $ do idiot <- localPlayer let idiotStatus = if name idiot == "Wavie" then "an idiot" else "cool" print $ name idiot ++ " is " ++ idiotStatus ++ "." [/code][/QUOTE] I think JavaScript has to be my favorite to code in. It's just so pretty. [sp]It's a joke.[/sp]
[QUOTE=Wavie;52105466]I think JavaScript has to be my favorite to code in. It's just so pretty.[/QUOTE] [quote]&#65439;&#969;&#65439;&#65417;= /&#65344;&#65357;´&#65289;&#65417; ~&#9531;&#9473;&#9531; //*´&#8711;&#65344;*/ ['_']; o=(&#65439;&#65392;&#65439;) =_=3; c=(&#65439;&#920;&#65439;) =(&#65439;&#65392;&#65439;)-(&#65439;&#65392;&#65439;); (&#65439;&#1044;&#65439;) =(&#65439;&#920;&#65439;)= (o^_^o)/ (o^_^o);(&#65439;&#1044;&#65439;)={&#65439;&#920;&#65439;: '_' ,&#65439;&#969;&#65439;&#65417; : ((&#65439;&#969;&#65439;&#65417;==3) +'_') [&#65439;&#920;&#65439;] ,&#65439;&#65392;&#65439;&#65417; :(&#65439;&#969;&#65439;&#65417;+ '_')[o^_^o -(&#65439;&#920;&#65439;)] ,&#65439;&#1044;&#65439;&#65417;:((&#65439;&#65392;&#65439;==3) +'_')[&#65439;&#65392;&#65439;] }; (&#65439;&#1044;&#65439;) [&#65439;&#920;&#65439;] =((&#65439;&#969;&#65439;&#65417;==3) +'_') [c^_^o];(&#65439;&#1044;&#65439;) ['c'] = ((&#65439;&#1044;&#65439;)+'_') [ (&#65439;&#65392;&#65439;)+(&#65439;&#65392;&#65439;)-(&#65439;&#920;&#65439;) ];(&#65439;&#1044;&#65439;) ['o'] = ((&#65439;&#1044;&#65439;)+'_') [&#65439;&#920;&#65439;];(&#65439;o&#65439;)=(&#65439;&#1044;&#65439;) ['c']+(&#65439;&#1044;&#65439;) ['o']+(&#65439;&#969;&#65439;&#65417; +'_')[&#65439;&#920;&#65439;]+ ((&#65439;&#969;&#65439;&#65417;==3) +'_') [&#65439;&#65392;&#65439;] + ((&#65439;&#1044;&#65439;) +'_') [(&#65439;&#65392;&#65439;)+(&#65439;&#65392;&#65439;)]+ ((&#65439;&#65392;&#65439;==3) +'_') [&#65439;&#920;&#65439;]+((&#65439;&#65392;&#65439;==3) +'_') [(&#65439;&#65392;&#65439;) - (&#65439;&#920;&#65439;)]+(&#65439;&#1044;&#65439;) ['c']+((&#65439;&#1044;&#65439;)+'_') [(&#65439;&#65392;&#65439;)+(&#65439;&#65392;&#65439;)]+ (&#65439;&#1044;&#65439;) ['o']+((&#65439;&#65392;&#65439;==3) +'_') [&#65439;&#920;&#65439;];(&#65439;&#1044;&#65439;) ['_'] =(o^_^o) [&#65439;o&#65439;] [&#65439;o&#65439;];(&#65439;&#949;&#65439;)=((&#65439;&#65392;&#65439;==3) +'_') [&#65439;&#920;&#65439;]+ (&#65439;&#1044;&#65439;) .&#65439;&#1044;&#65439;&#65417;+((&#65439;&#1044;&#65439;)+'_') [(&#65439;&#65392;&#65439;) + (&#65439;&#65392;&#65439;)]+((&#65439;&#65392;&#65439;==3) +'_') [o^_^o -&#65439;&#920;&#65439;]+((&#65439;&#65392;&#65439;==3) +'_') [&#65439;&#920;&#65439;]+ (&#65439;&#969;&#65439;&#65417; +'_') [&#65439;&#920;&#65439;]; (&#65439;&#65392;&#65439;)+=(&#65439;&#920;&#65439;); (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]='\\'; (&#65439;&#1044;&#65439;).&#65439;&#920;&#65439;&#65417;=(&#65439;&#1044;&#65439;+ &#65439;&#65392;&#65439;)[o^_^o -(&#65439;&#920;&#65439;)];(o&#65439;&#65392;&#65439;o)=(&#65439;&#969;&#65439;&#65417; +'_')[c^_^o];(&#65439;&#1044;&#65439;) [&#65439;o&#65439;]='\"';(&#65439;&#1044;&#65439;) ['_'] ( (&#65439;&#1044;&#65439;) ['_'] (&#65439;&#949;&#65439;+(&#65439;&#1044;&#65439;)[&#65439;o&#65439;]+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#920;&#65439;)+ (&#65439;&#65392;&#65439;)+ (&#65439;&#920;&#65439;)+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#920;&#65439;)+ ((&#65439;&#65392;&#65439;) + (&#65439;&#920;&#65439;))+ (&#65439;&#65392;&#65439;)+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#920;&#65439;)+ (&#65439;&#65392;&#65439;)+ ((&#65439;&#65392;&#65439;) + (&#65439;&#920;&#65439;))+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#920;&#65439;)+ ((o^_^o) +(o^_^o))+ ((o^_^o) - (&#65439;&#920;&#65439;))+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#920;&#65439;)+ ((o^_^o) +(o^_^o))+ (&#65439;&#65392;&#65439;)+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+((&#65439;&#65392;&#65439;) + (&#65439;&#920;&#65439;))+ (c^_^o)+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#65392;&#65439;)+ ((o^_^o) - (&#65439;&#920;&#65439;))+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#920;&#65439;)+ (&#65439;&#920;&#65439;)+ (&#65439;&#920;&#65439;)+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#65392;&#65439;)+ (c^_^o)+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#920;&#65439;)+ (&#65439;&#65392;&#65439;)+ (&#65439;&#920;&#65439;)+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#920;&#65439;)+ (&#65439;&#65392;&#65439;)+ ((&#65439;&#65392;&#65439;) + (o^_^o))+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#920;&#65439;)+ ((o^_^o) +(o^_^o))+ ((o^_^o) - (&#65439;&#920;&#65439;))+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#920;&#65439;)+ (&#65439;&#65392;&#65439;)+ ((&#65439;&#65392;&#65439;) + (&#65439;&#920;&#65439;))+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#920;&#65439;)+ (&#65439;&#65392;&#65439;)+ ((&#65439;&#65392;&#65439;) + (&#65439;&#920;&#65439;))+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#65392;&#65439;)+ (&#65439;&#920;&#65439;)+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+(&#65439;&#65392;&#65439;)+ ((o^_^o) - (&#65439;&#920;&#65439;))+ (&#65439;&#1044;&#65439;)[&#65439;&#949;&#65439;]+((&#65439;&#65392;&#65439;) + (&#65439;&#920;&#65439;))+ (&#65439;&#920;&#65439;)+ (&#65439;&#1044;&#65439;)[&#65439;o&#65439;]) (&#65439;&#920;&#65439;)) ('_');[/quote]
[QUOTE=MadParakeet;52105717][/QUOTE] Absolutely beautiful. Goodjob, my man!
Holy shit, speaking of "hypothetical gmod lisp": [url]https://squiddev.github.io/urn/[/url]
[QUOTE=MadParakeet;52106658]Holy shit, speaking of "hypothetical gmod lisp": [url]https://squiddev.github.io/urn/[/url][/QUOTE] Well, shit. "hypothetical"
Pretty sure beautiful code is referring to what the code does, and how it does it rather than it's format.
[QUOTE=overki11;52107530]Pretty sure beautiful code is referring to what the code does, and how it does it rather than it's format.[/QUOTE] You say that, but code that doesn't put spaces after arguments and between parenthesis is absolutely not compilable. Spacing is important. [code]function example( arg1, arg2, arg3 ) print( "Hello, world!" ) local a = 15 a = 2 + 5 end[/code] :( I think it's pretty
[QUOTE=MadParakeet;52105717]:snip:[/QUOTE] Okay how did you do that? [img]http://i.imgur.com/GzEZsEL.png[/img]
[QUOTE=NeatNit;52111988]Okay how did you do that? [img]http://i.imgur.com/GzEZsEL.png[/img][/QUOTE] It's obfuscated
dont use tables, use elseif for everything!!!
[QUOTE=Tupac;52112258]dont use tables, use elseif for everything!!![/QUOTE] No silly goose, use functions for everything. [code] local function getPlayerScore(ply) return 0 end local function setPlayerScore(ply1,score) local old = getPlayerScore getPlayerScore = function(ply2) if ply1 == ply2 then return score else return old(ply2) end end end [/code] Untested, but you get the point. [B]Edit:[/B] Fixed. I think.
[QUOTE=MadParakeet;52113271]No silly goose, use functions for everything. [code] local function getPlayerScore(ply) return 0 end local function setPlayerScore(ply1,score) local old = getPlayerScore getPlayerScore = function(ply2) if ply1 == ply2 then return score end end end [/code] Untested, but you get the point.[/QUOTE] MIPS in a nutshell
There is no way to get bad code if you don't programming
[QUOTE=Wavie;52112230]It's obfuscated[/QUOTE] Thanks, captain obvious... I just want to understand at least a single tiny part of the obfuscation.
Best way of coding is putting spaces everywhere: [CODE] scp = {} scp.__list = {} scp.__index = scp function scp:Start (strName, strClass) self = {} self ["name"] = strName -- self ["class"] = strClass setmetatable (self, scp) scp.__list [strName] = self return self end function scp:GetAll () return scp.__list end function scp:OnPlayerSpawnBase (pActor) pActor:UnSpectate () pActor:GodDisable () pActor:StripWeapons () pActor:RemoveAllAmmo () pActor:SetTeam (TEAM_SCP) pActor:AllowFlashlight (false) pActor:SetNoTarget (true) pActor.WasTeam = TEAM_SCP pActor.canblink = false pActor.handsmodel = nil pActor.BaseStats = nil pActor.UsingArmor = nil end function scp:OnPlayerSpawn (pActor) return end function scp:OnPlayerDeath (pActor, etWeapon, pAttacker) return end function scp:OnPlayerAttack (pVictim, dmgInfo) return end function scp:OnPlayerAttacked (pActor, dmgInfo) return end function scp:OnRoundInit (pActor) return end function scp:OnRoundStart (pActor) return end function scp:OnRoundFinish (pActor) return end [/CODE]
[QUOTE=Potatofactory;52115650]Best way of coding is putting spaces everywhere: [CODE] scp = {} scp.__list = {} scp.__index = scp function scp:Start (strName, strClass) self = {} self ["name"] = strName -- self ["class"] = strClass setmetatable (self, scp) scp.__list [strName] = self return self end function scp:GetAll () return scp.__list end function scp:OnPlayerSpawnBase (pActor) pActor:UnSpectate () pActor:GodDisable () pActor:StripWeapons () pActor:RemoveAllAmmo () pActor:SetTeam (TEAM_SCP) pActor:AllowFlashlight (false) pActor:SetNoTarget (true) pActor.WasTeam = TEAM_SCP pActor.canblink = false pActor.handsmodel = nil pActor.BaseStats = nil pActor.UsingArmor = nil end function scp:OnPlayerSpawn (pActor) return end function scp:OnPlayerDeath (pActor, etWeapon, pAttacker) return end function scp:OnPlayerAttack (pVictim, dmgInfo) return end function scp:OnPlayerAttacked (pActor, dmgInfo) return end function scp:OnRoundInit (pActor) return end function scp:OnRoundStart (pActor) return end function scp:OnRoundFinish (pActor) return end [/CODE][/QUOTE] You just made me puke :vomit:
[QUOTE=tzahush;52116059]You just made me puke :vomit:[/QUOTE] Naw man, tis art [editline]17th April 2017[/editline] [QUOTE=NeatNit;52115402]Thanks, captain obvious... I just want to understand at least a single tiny part of the obfuscation.[/QUOTE] Obfuscated code is code that's encrypted. [sp]:)[/sp]
[QUOTE=Wavie;52116079]Naw man, tis art [editline]17th April 2017[/editline] Obfuscated code is code that's encrypted. [sp]:)[/sp][/QUOTE] There's actually a few fairly big differences between obfuscation and encryption.
I was about to start ranting about the "use emoji not spaces" meme, but it turns out they can totally break alignment in my editor (Victoria Secret Code). [img]http://cogg.rocks/uploads/Code_2017-04-17_10-23-53.png[/img] On a serious note, anyone want to write a legit addon in that lisp dialect? [B]Edit:[/B] And now I'm legit considering rewriting my entire addon in lisp. Partially to break compatibility with all the FNAF shit, of course. [B]Edit:[/B] I don't know lisp btw.
-snip- Need to study on lua more.
the best way of coding is whatever the fuck my format is [code]local goodTable = { goodValue = 1, betterValue = "no thanks" } goodTable["theBestValue"] = 42 local function goodishFunction(amazingValue) local isAmazing = false if amazingValue == true then isAmazing = true end return isAmazing end goodTable["goodFunction"] = goodishFunction function goodTable.theBestFunctionOnThisPlanet(i, buy, greatValue, products) return (i + buy + greatValue + products) == goodTable["goodValue"] end[/code]
For a tough example, when I like to insert users into a table and assign variables to them I like to use this method, this works best for me. [CODE] local char = char or {} local function char.playerStats( player ); char.List[player] ={ char.Stamina = 1, char.Endurance = 12, char.Wage = 75, }; end [/CODE] I'm a newbie, what can you say... end
[QUOTE=Chickengbs;52116744]For a tough example, when I like to insert users into a table and assign variables to them I like to use this method, this works best for me. [CODE] local char = char or {} local function char.playerStats( player ); char.List[player] ={ char.Stamina = 1, char.Endurance = 12, char.Wage = 75, }; end [/CODE] I'm a newbie, what can you say... end[/QUOTE] [CODE]local function char.playerStats( player );[/CODE] [CODE];[/CODE] no [CODE]char.List[player] ={[/CODE] [CODE]={[/CODE] spaces pls :(
[QUOTE=kaliii;52116802][CODE]local function char.playerStats( player );[/CODE] [CODE];[/CODE] no [CODE]char.List[player] ={[/CODE] [CODE]={[/CODE] spaces pls :([/QUOTE] [code]local function meme(x,y)return(math.abs(x-y));end[/code]
[QUOTE=txike;52116895][code]local function meme(x,y)return(math.abs(x-y));end[/code][/QUOTE] [code]local meme=function(x,y);return(math.abs(x-y));end;[/code]
Sorry, you need to Log In to post a reply to this thread.