|
| 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 |
|
|
|
| 19 Mar 2016 10:47 AM |
| tab - {kill('Everybody','Srsly'),fly('To Heaven',667)} |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 19 Mar 2016 11:52 AM |
Table = { ["HelloWorld"] = function() print("Hello World") end}
Table.HelloWorld()
|
|
|
| Report Abuse |
|
|