Jump to content

Whats mean (. . .)?


mrvicio

Recommended Posts

Posted

In your case, the "..." works as a table of arguments later used in table.find function.

Example of using "..." as argument:

addCommandHandler("text", 
function( player, command, ... ) 
    local text = table.concat({...}, " ") -- This way the player can type texts with [b][u]spaces[/u][/b]. 
    outputChatBox(tostring(text)) 
end) 

Posted

Each function that has "..." as parameter, passes another hidden table that is arg. So, you can use arg instead of creating new table with all parameters. In addition, arg table has a

addCommandHandler("text", 
function( player, command, ... ) 
    local text = table.concat(arg, " ") -- This way the player can type texts with spaces. 
    outputChatBox( text ); 
end) 

table.concat returns string so there is no need to convert it to string.

Posted

is there any need for the semicolon here: outputChatBox( text );

just curious because ive never needed to use one like this.

Posted
is there any need for the semicolon here: outputChatBox( text );

just curious because ive never needed to use one like this.

In most scripting/programming language, semicolons are used, but in lua its optional (makes no difference if used or not).

Posted

ah so 50p used it out of habit.. ok thanks....

i see it quite a lot within code from experienced scripters but have never needed to use it myself...

i wasnt sure if it had some use in Lua or not.

thanks for the quick reply.

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...