[QUOTE=Positive;44902112]I hate doing 'true' and 'false'
so I do
local yes = true
local no = false
and I prefer
'player' over 'ply'
NEVER Any Semi colon's,[/QUOTE]
You can use is/is not and ! to do this a bit cleaner. Using yes/no in syntax doesn't make much sense when you read it since something usually is or is not rather than yes/no logically.
[QUOTE=Positive;44902112]I hate doing 'true' and 'false'
so I do
local yes = true
local no = false
and I prefer
'player' over 'ply'
NEVER Any Semi colon's,[/QUOTE]
There's a reason why people use "ply", because "player" can refer to the [url=http://wiki.garrysmod.com/page/Category:player]"player" library[/url] which can get pretty confusing when "Attempt to call method IsPlayer a nil value". Since the "player" is defined, but not as an actual player object.
[code]
-- This is how I name constants, seems pretty standard, right?
ARCPHONE_ERROR_PLAYER_OFFLINE = 5
-- Other than that, I tend to use CamelCaps for almost everything.
local ExampleVar = true
-- But when it comes to function arguments, I tend to have this bad habit of... well... this
local function ThingThatDoesStuff(firstarg,secondarg)
return firstarg+secondarg -- Also, no spaces.
end
-- Notice how I like to use the C/C++ operators even though I use lua comments
if ExampleVar && !OtherThing then
end
-- The only reason why I got into the habit of this is because of shit like pastebin with lua syntax highlighters
-- Other habit related fun-fact is the way I use hooks, Here's a whitelist system I made.
local ValidTesters = {"STEAM_0:0:18610144","STEAM_0:1:56899522","STEAM_0:0:42390936","STEAM_0:1:49506333","STEAM_0:1:30027673"} -- Oh I know that some of you are going to look these up.
hook.Add( "CheckPassword", "CheckingThePassword", function(steamid,ip,svpass,clpass,nick)
steamid = util.SteamIDFrom64(steamid)
if !table.HasValue(ValidTesters,steamid) then -- Some people hate garrycode, but hey. Doing a for loop of the entire table would done the same thing that this function does anyways.
MsgN(steamid.." has been blocked from the whitelist.") -- MsgN, because, why type \n?
return false,"I'm sorry, "..nick..".\nARitz Cracker's Testing Server is currently not open to the public."
end
end)
[/code]
[QUOTE=Positive;44902112]I hate doing 'true' and 'false'
so I do
local yes = true
local no = false
[/QUOTE]
that made me sad
[editline]25th May 2014[/editline]
[QUOTE=rbreslow;44873287]Ever since I got into gLua I always forget to put semicolons in my PHP scripts. Fuck you Lua.[/QUOTE]
I know that feel bro.
[lua]
--calculate distance of two vectors
local function dist(pos1, pos2)
return pos1:Distance(pos2)
end
--example of use: print(dist( Vector(0,0,1), Vector(20, 20, 20) ))
[/lua]
[QUOTE=john552;44907689][lua]
print(dist( Vector(0,0,1), Vector(20, 20, 20) ))
[/lua][/QUOTE]
You should really make your argument spacing consistent.
Your style doesn't matter but you should keep it the same throughout your code.
[QUOTE=Khub;44907796]You should really make your argument spacing consistent.
Your style doesn't matter but you should keep it the same throughout your code.[/QUOTE]
most of the time it doesn't matter much to me, I know it does to others but I sometimes switch it around
[QUOTE=Khub;44907796]You should really make your argument spacing consistent.
Your style doesn't matter but you should keep it the same throughout your code.[/QUOTE]
If there are too many parentheses, I like to space the outer-most ones in a group to make it clear.
Sorry, you need to Log In to post a reply to this thread.