|
| 08 Jul 2016 12:44 PM |
is there a way to get a string value containing the functions arguments
for example
function message(text) print (text) end
print(message.arguments) --prints "text"
?? |
|
|
| Report Abuse |
|
|
123rhylee
|
  |
| Joined: 03 Apr 2012 |
| Total Posts: 15 |
|
|
| 08 Jul 2016 12:49 PM |
| Why would you ever need that? You pass arguments into a function = you already have the arguments. If you want to edit/do anything with the arguments, you edit the function to do that. |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2016 12:51 PM |
| i just wanna print them out of a long table of functions so i can sorta add a description |
|
|
| Report Abuse |
|
|
123rhylee
|
  |
| Joined: 03 Apr 2012 |
| Total Posts: 15 |
|
|
| 08 Jul 2016 12:54 PM |
| Are you looking instead for a function's return value? You could just make all those functions return something, assign them to variables/added to an array and concatenate the strings together. |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2016 12:57 PM |
| no I'm just trying to make a list of all my functions that are in a module script but when you print a list of the functions it only prints the function name and not its arguments so i would have to individually type all of them which is fine but it would be easier to update it if i could somehow get the arguments |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 08 Jul 2016 01:05 PM |
--module local module = { ['FunctionA'] = function(argument) print(argument) end }
return module
--script
local tableOfFunctions = require(modulehere) for i,v in next(tableOfFunctions) do print(i) end
- Isosta |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 08 Jul 2016 01:06 PM |
change the for loop to this, i used ipairs syntax mb
for i,v in next, tableOfFunctions do print(i) end
- Isosta |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2016 01:06 PM |
| that only prints the functions name I'm trying to also print the functions arguments |
|
|
| Report Abuse |
|
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 08 Jul 2016 01:07 PM |
whatever you're doing is inefficient and a horrible method.
- Isosta |
|
|
| Report Abuse |
|
|
| |
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 08 Jul 2016 01:09 PM |
if you must, though, pass another argument like this
local message = function(text,bool) if bool then return {'text'} else --run the function end end
local arguments = message('',true) for i,v in ipairs(arguments) do print(v) end
you'd have to add the arguments into the return yourself.
- Isosta |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2016 01:14 PM |
ok thanks for helping i was pretty sure it wouldn't work out well anyways :P |
|
|
| Report Abuse |
|
|