Moony Posted July 22, 2010 Share Posted July 22, 2010 I recently started learning LUA and its things. Someone sent me this example of a LUA file and as usual, i dont understand it. function test ( player ) local name = getPlayerName ( player ) outputChatBox ( name ) end function testB ( player ) outputChatBox ( getPlayerName ( player ) ) end addCommandHandler ( "command1", test) addCommandHandler ( "command2", testB) I'd like to know the following things: Definitions of: -"local" -"getPlayerName ( player )" -"outputChatBox ( name )" -"addCommandHandler ( "command1", test) addCommandHandler ( "command2", testB)" Basically its every meaning of every part of the function. Thanks very much! Link to comment
dzek (varez) Posted July 22, 2010 Share Posted July 22, 2010 function test ( player ) -- our function name.. according to wiki page of addCommandHandler (click below on addCommandHandler), 1st argument is player element (more about elements in link below) who triggered function -- link for elements help [url=https://wiki.multitheftauto.com/wiki/Element]https://wiki.multitheftauto.com/wiki/Element[/url] local name = getPlayerName ( player ) -- we are getting name of player element passsed with addCommandHandler outputChatBox ( name ) -- we are writing that name in chatbox end -- end of function function testB ( player ) -- same outputChatBox ( getPlayerName ( player ) ) -- shortened version of function "test", we are not storing any variables end -- .. addCommandHandler ( "command1", test) -- if player type "/command1" in chatbox - [b]test[/b] function will be fired addCommandHandler ( "command2", testB) -- if player type "/command2" in chatbox - [b]testB[/b] function will be fired I'd like to know the following things:Definitions of: -"local" -"getPlayerName ( player )" -"outputChatBox ( name )" -"addCommandHandler ( "command1", test) addCommandHandler ( "command2", testB)" Basically its every meaning of every part of the function. Thanks very much! rly weird way to learn scripting.. - local: http://www.lua.org/pil/4.2.html and rest are described PERFECTLY on wiki (click on function name in script above to be redirected to wiki) Link to comment
Moony Posted July 23, 2010 Author Share Posted July 23, 2010 And varez, one last question. Where did you got that link for lua? Mind if i use it? Link to comment
Discord Moderators Zango Posted July 23, 2010 Discord Moderators Share Posted July 23, 2010 Where did you got that link for lua? Mind if i use it? http://lmgtfy.com/?q=local+lua I seriously doubt anybody has anything against you reading the LUA manual. Should have been skimmed over in advance. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now