generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Call a function from a table with arguments?

Previous Thread :: Next Thread 
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
19 Mar 2016 10:45 AM
So if I had table = {kill(), fly()}

How could I call kill with arguments?

-- It needs to be in this setup


Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
19 Mar 2016 10:47 AM
tab - {kill('Everybody','Srsly'),fly('To Heaven',667)}
Report Abuse
wonderful72pike is not online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
19 Mar 2016 10:48 AM
table.kill(a, b, c)

If you wanted the table to be your argument, like a brick destroying itself, you can do it like this:

table:kill()

Then in the actual code it'll act like the table is the first argument.
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
19 Mar 2016 10:48 AM
table[1] would equal to the result of kill function call and table[2] would equal to the result of fly function

just reference the functions like
local t = {kill,fly}

t.kill(1,2)
t.fly(3,4)
Report Abuse
HumanXerxes is not online. HumanXerxes
Joined: 17 Apr 2011
Total Posts: 1351
19 Mar 2016 10:49 AM
Just use their names when making the table. Try this:

table = {kill, fly}

table.kill(arg1,arg2)
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
19 Mar 2016 11:11 AM
I have a table of tables:

commands = { -- FORMAT : Permission level needed ( 1 - Lowest, 5 highest), the function, words to trigger it


killCmd = {

1,
functions.kill(),
{"kill", "murder", "respawn"}

}

flyCmd = {
1,
functions.fly(),
{"fly"}

}


I've got a script to identify which table it is in, but I can't refer to it via name


Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
19 Mar 2016 11:52 AM
Table = {
["HelloWorld"] = function()
print("Hello World")
end}


Table.HelloWorld()


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image