Jump to content

where i can find definitions about arguments?


Carbonik

Recommended Posts

The arguments you are going to use depends the event handler you are using

if I want to make the event onPlayerChat, first of all I'll go to wiki to check what arguments/parameters I have to use the wiki says

string message, int messageType 

* message: A string representing the message typed into the chat.

* messageType: An integer value representing the message type.

now I know the first argument is the message which was typed in to the chat by the source of the event, and I want to make a script which will output "You typed player'sMessage" in the chat of the player who typed it,

the arguments doesn't have to be only 'message' or 'messageType' I can use anything, just remember that the first argument is message and second is message type.

function chat(msg,msgtype) --- msgtype is not actually needed because I am not going to use it anywhere you can read about it on wiki 
outputChatBox("You typed "..msg.."!",source) 
end 

Samilarly, for commands,

for example, I want to make a command,

the arguments I'll use these arguments at the function,

function command (arg1, arg2, and so on) 
--- just an example 
addCommandHandler("cmd",command) 

for commands the first argument's element can only be the play who typed the command, the arg2 has to be the command which was typed, in the above example the arg2 will return "cmd", you can add custom arguments for example, I want to make a script which outputs "Playername doesn't likes targetname",

function command(player,cmd,target) 
outputChatBox(getPlayerName(player).." doesn't likes "..target,root,255,0,0) 
end 

P/S: if/elseif/else/for loop are not arguments they are statements, read about statements here http://www.lua.org/pil/

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...