Stop creating global functions which should be LOCAL.

I’m sick of seeing this happen when you clearly don’t know a thing about scopes, or are a lazy programmer:

[lua]function CollisionExample( Ent, Ent2 )
local Mins = Ent:LocalToWorld( Ent:OBBMins() )
local Maxs = Ent:LocalToWorld( Ent:OBBMaxs() )
for _, prop in pairs( ents.FindInBox( mins, maxs ) do
if ( Ent2 == prop ) then
Msg( “Position collision detected!” )
return true
end
end

return false

end[/lua]

Let’s say that you use this function ONCE, and only intend to use it ONCE. Then make it a LOCAL function.

“How difficult is this”, you say?

[lua]local function CollisionExample( Ent, Ent2 )
local Mins = Ent:LocalToWorld( Ent:OBBMins() )
local Maxs = Ent:LocalToWorld( Ent:OBBMaxs() )
for _, prop in pairs( ents.FindInBox( mins, maxs ) do
if ( Ent2 == prop ) then
Msg( “Position collision detected!” )
return true
end
end

return false

end[/lua]

Really difficult.

THE POINT: This stops your function from being called if it has the same name as another function somewhere in the game, or Lua environment with a different set of calculations or calls.

Stop making your VGUI elements in global functions with common names. You’ll eventually break something by being a fool.

What is a scope?

Need it in simple English? Too bad. People who know what they are doing will understand the definition. Stop programming altogether if you can’t read, or let alone type a sentence.

To developers: Please reference this thread in instances where it applies. Thanks.

Hooks ( event and usermessage ), console commands, and any form of callbacks should never exist in _G. There is never a good reason for them to be there.

This man speaks the truth.

Hi mister Lua coding standards. Oh wait.

In reality, what do you care? If people want to clutter their environment, let them. It won’t really bother you unless you go over sources just to pick stuff like this out, which would just make you an elitist person. You know who else were elitists? NAZI’S. Do you really want to be a nazi?

Now let the dumb and disagree ratings flow for expressing my opinion :V

Yes.

[editline]01:09PM[/editline]

Your point became invalid the third word in:

[editline]01:11PM[/editline]

Also:

“NAZIS”, without “’”, as there is no mention of possession or contraction. :byodood:

Great job at rating yourself funny. Also, I don’t know when you people will make up your minds, is it Lua or LUA now?

It’s always been “Lua”. It’s not an acronym.

I rated him funny :smile:

Everyone has their own coding style and talking style, you have no right to force them from being themselves.

He isnt forcing them, he is stating that this is the way you should do it!

“Stop creating global functions which should be LOCAL”

Sounds like forcing. But I’ll get out of here now.

Lua may refer to:-
-A Roman Goddess
-Hawaiian Martial arts
-Lua people from northern Laos
-“Moon” in Portuguese.

In the case of the Lua programming language, it refers to the moon, hence the logo. Like andrew said, It definitely isn’t an acronym

I know it’s not, but way too much people used to post that it’s LUA, and not lua or Lua.

This man knows his information.

[editline]01:21PM[/editline]

When we mention the programming language, it is a proper noun.

Forcing would be “I have your family in my basement. If you don’t stop creating global functions which should be local, you won’t see them again.”

I just PM’d you, should I let them go?

You lucked out this time Andrew.

Get over yourself.

Your username. :irony:

People like you should be sterilised.