local function ReduceFallDamage( ent, inflictor, attacker, amount, dmginfo )
    if ent:IsPlayer() and ent.ShouldReduceFallDamage and dmginfo:IsFallDamage() then
    return true
  hook.Add( "EntityTakeDamage", "ReduceFallDamage", ReduceFallDamage )

Why are the arguments in this code snippet in the order that they are? Does the order matter? I’m kind of confused for arguments in GMod Lua.

The arguments are in that order because that’s the way garry made it, and yes, it does matter what order you put them in.

It varies for different functions, though. This is what is confusing me.

Different functions need different arguments, if you don’t understand that you should read up more about Lua.

What about custom functions? How do you know what arugments to use for them? Do they even need any?

Each functions or hook will put out different arguments but always in the same order, so if you changed

local function ReduceFallDamage( ent, inflictor, attacker, amount, dmginfo )


local function ReduceFallDamage( wut, rofl, lulz, nigs, FUUU )

wut would be assigned the ent that is being hit with falldamage
rofl would be the inflicter (worldspawn i beleive for falldmg)
lulz would be the attack (if i throw a explosive barrel at you and kill you im the attacker)
nigs would be the amount of damage done
FUUU would be the type of damage received on wut

just read on the wiki what each function puts out

When calling custom functions, you use the arguments you used in the same order when you defined that function.

What do you mean when I “defined” it?

:sigh: You really need to read about Lua before you take on the challenge of learning it.


If you haven’t already, read this.


and this

I read the entire PIL.


and the thing that confuses you is function arguments?

Yes. Pretty much only that.


i’m thirteen and what is this


function ENT:StartFuse( mintime, maxtime ) --it's the final countdown! (doo doo dooo doo)
	self:SetNetworkedBool( "loaded", false ) --we're no longer idle on 'loaded'...
	self:SetNetworkedBool( "firing", true ) --we're firing!
	--Wire_TriggerOutput(self, "Stage", 3)
	self:EmitFuseSounds( true ) --start our fuse sound
	timer.Simple( math.random(mintime, maxtime), function()
		self:EmitFuseSounds( false ) --countdown is done, stop our fuse sound
		self:EmitShootEffects() --give a nice explosion and smoke effect
		self:EmitShootSounds( true, 150 ) --"boom!"
		self:Shoot() --actually shoot the cannonball
		self:KickBack( -99000 ) --kick back the cannon itself
		self:SetNetworkedBool( "firing", false ) --we've fired away
		--Wire_TriggerOutput(self, "Stage", 0)
	end )

I got this for the “Cannons!” addon. It’s the first time the argument was used and it’s nowhere else in the script other than this…

function ENT:StartLoad( mintime, maxtime, cannonball ) --load it up!
	self:SetNetworkedBool("loading", true ) --we're going, cap'n!
	--Wire_TriggerOutput(self, "Stage", 1)
	cannonball:Remove() --get rid of the original cannonball (put it in the cannon)
	self:EmitLoadSounds( true, 100 ) --play our sound
	timer.Simple( math.random( mintime, maxtime ), function() --it takes a while
		self:SetNetworkedBool( "loading", false ) --we're done loading!
		self:SetNetworkedBool( "loaded", true ) ----^
		--Wire_TriggerOutput(self, "Stage", 2)
	end )

Ok here is the simple answer to what an argument is. It is a way to pass information from one function to another when you call the other function inside another function.
local playerss={}
function ineeddata(plyname,steamid)
function lookaplayerjoined(ply)
local sid=ply:SteamID()
local pname=ply:Nick()

OH. I understand now. Thanks!

You really need to learn basic programming concepts before trying anything. PiL is good, but does assume that you know the basics. Lua, while being an easy and fairly forgiving language, is the least well documented one I’ve ever found. I’d recommend learning JavaScript first, as there are a hell of a lot of beginner’s tutorials and it has a lot more uses than Lua.


i don’t understand