Sorry for this noobish thread, but I’m learning Lua.
I’m confused with arguments and I’m hoping someone could explain how they work to me.
If I look at this code;
function sayMyName(whatsMyName) Msg("Hey "..whatsMyName.."! ") end sayMyName("Jeff")
I understand it, it will print “Hey Jeff!”.
But if I look at this code;
function KeyPressed (P, key) Msg (P:GetName().." pressed "..key.." ") end hook.Add( "KeyPress", "KeyPressedHook", KeyPressed )
I don’t understand why it works. P and key isn’t defined like in the previous code.
So I tried making one myself, but it does not work;
function GetUserGroup( ply ) ply:PrintMessage(HUD_PRINTTALK, ply:GetUserGroup()) end GetUserGroup()
Can somebody explain?