ply is an argument of the funtion FishCake. An for concommand.Add, ply equals the player who ran the concommand.
2 days ago i watched a random Lua Video Lua tutorial. The guy making the tutorial creates this function :
This right hereCode:function FishCake( ply ) ply:concommand(" say F@#!ING MIGNBAGS ") end
...is driving me insane.Code:(ply)
Why did he put the ( ply ) after creating the function?
is it important? Do i need to do that if i wanted to use the player in my function?
I asked the author of the video, but i did not understand what he meant.
]skip to 0:40
Last edited by libintia; 07-27-2010 at 07:38 AM.
ply is an argument of the funtion FishCake. An for concommand.Add, ply equals the player who ran the concommand.
“Saying Java is good because it works on all operating systems is like saying anal sex is good because it works on all genders.”
Well, i don't think i get why he used the ply argument when he created the function, as far as i know, ply = player or LocalPlayer by default. Witch means that he didn't have to use it as an argument.
he could have just use it directly
like this for example:
But in any case I'm new to LUA and I am trying to understand how this works. I am currently reading (Lua Programming in Lua (first edition) ), and I'm almost done reading the functions section, but according to Chapter 5( Functions ): We pass parameters to the function so that we can pass arguments from outside the function or when we call the function.function FishCake()
ply:comncommand(" say F@#!ING MIGNBAGS ")
end
or am i wrong?
This is very confusing! LUA is confusing.
But i do appreciate your help, thank you.
It doesn't work that way either. Imagine, you create a function:And you want to pass a player object and how much ammo you want to give. You would do:Code:GiveAR2AmmoNow you have your function, now you call it by running:Code:function GiveAR2Ammo(Player,Amount) Player:GiveAmmo(Amount,"ar2",true) endNow you are passing a Player entity and a number as arguments to the function. Inside of the function you can access them like any variable.Code:GiveAR2Ammo(player.GetByID(1), 250)
“Saying Java is good because it works on all operating systems is like saying anal sex is good because it works on all genders.”
“Saying Java is good because it works on all operating systems is like saying anal sex is good because it works on all genders.”
Bookmarks