|
| 31 Jul 2011 02:45 PM |
How would I go about making a table out of arguments?
function myFunction(argTable) local argTable = {argTable}; end;
or
function myFunction(...) end; |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 02:51 PM |
table = { } function MyFunction(arg) table.insert(table, arg) end
MyFunction("Hello") print(table[1])
> Hello |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 02:53 PM |
No..
I am not wanting to function to INSERT TO A TALBE.
I want the arguments to BE A TABLE. Also, learn to make it local, it is more optimized. |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 03:02 PM |
"Also, learn to make it local, it is more optimized."
I'm not going to help you now. |
|
|
| Report Abuse |
|
|
agent767
|
  |
| Joined: 03 Nov 2008 |
| Total Posts: 4181 |
|
|
| 31 Jul 2011 03:09 PM |
function dontblamesoul(table) print(table[1]) end
arguments = {"Dont blame him",anotherarguument,another_one} dontblamesoul(arguments) |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 03:21 PM |
table = {} table[1] = (function(words) print(words) end)
table[1]("line")
-->line
like this would work |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 03:37 PM |
This is what I mean, I will show you how I want this to be used,
function Call(arguments) arguments[1](arguments[2]); end;
local function meh(msg) print(msg) end
Call(meh, "hi") |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 03:50 PM |
function Call(func, str) func(str); end
local function meh(msg) print(msg); end
Call(meh, "hi") |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 03:54 PM |
| That isn't my example, all you did is treat the arguments like a variable, not a table like above. |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 04:03 PM |
Your example won't work.
If you don't want help then get out. |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 04:06 PM |
| Do you read at all? My example shows how it is used. |
|
|
| Report Abuse |
|
|
Boomarang
|
  |
| Joined: 15 Jul 2008 |
| Total Posts: 919 |
|
|
| 31 Jul 2011 04:10 PM |
function LOL(table) for i = 1, #table do print(table[1]) wait(1) end end
t = {23,48,60,92,38} function(t)
Do you mean like that? |
|
|
| Report Abuse |
|
|
| |
|
|
| 31 Jul 2011 11:22 PM |
You guys..
Seriously, you aren't understanding. Alright, I want something THAT WILL work like this:
function _function(argumentTable) print(argumentTable) end;
_function("Hi", "Bye", "Cya") and it would output:
Hi, Bye, Cya |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 11:32 PM |
Sigh...
function a (... ) local args = { ... } for _, v in pairs(args) do print(_,v) end end
a( "Hi", "Bye", "Cya" ) |
|
|
| Report Abuse |
|
|
aboy5643
|
  |
| Joined: 08 Oct 2010 |
| Total Posts: 5458 |
|
|
| 01 Aug 2011 12:25 AM |
"local is more optimized"
You mean efficient, and stop listening to xLEGOx. The efficiency boost is like .000001%... You'll spend more time typing local than you'll lose in every run of a non local variable.
~Get the water boiling... I'll get the cauldron and the seasoning... |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2011 12:32 AM |
You mean efficient, and stop listening to xLEGOx. The efficiency boost is like .000001%... You'll spend more time typing local than you'll lose in every run of a non local variable. _________________________________
How did you become a wiki writer...? >_> |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2011 12:35 AM |
> t = tick() for i = 1, 1000000 do X = 4; end print(tick() - t) 0.055094480514526 > t = tick() for i = 1, 1000000 do local X = 4; end print(tick() - t) 0.033602237701416
Seems that local variables are almost twice as fast as normal ones...?
~Sorcus |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2011 11:26 AM |
Listening to xLEGOx?
Hah! Try playing Garry's Mod. You then realize in GLua, optimizing code is important. |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2011 11:59 AM |
Shiro, just to let you know;
This is ROBLOX, not GMod. |
|
|
| Report Abuse |
|
|
agent767
|
  |
| Joined: 03 Nov 2008 |
| Total Posts: 4181 |
|
|
| 01 Aug 2011 12:01 PM |
@Soul game.Parent.Name = "GMod" :p |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2011 12:02 PM |
@agent Respect = Respect - 1 |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2011 12:03 PM |
repeat SoulStealer9875.Respect = SoulStealer9875.Respect - 1 until SoulStealer9875.Satisfied == true |
|
|
| Report Abuse |
|
|
agent767
|
  |
| Joined: 03 Nov 2008 |
| Total Posts: 4181 |
|
|
| 01 Aug 2011 12:03 PM |
Respect before: -73.1 Respect after: -74.1
Respect = math.abs(Respect) print(Soul respects me) |
|
|
| Report Abuse |
|
|
| |
|