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 » Scripting Helpers
Home Search
 

Re: Function arguments as a table?

Previous Thread :: Next Thread 
ShiroPixel is not online. ShiroPixel
Joined: 31 Jul 2010
Total Posts: 545
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
SoulStealer9875 is not online. SoulStealer9875
Joined: 20 Jul 2009
Total Posts: 13119
31 Jul 2011 02:51 PM
table = { }
function MyFunction(arg)
table.insert(table, arg)
end

MyFunction("Hello")
print(table[1])

> Hello
Report Abuse
ShiroPixel is not online. ShiroPixel
Joined: 31 Jul 2010
Total Posts: 545
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
SoulStealer9875 is not online. SoulStealer9875
Joined: 20 Jul 2009
Total Posts: 13119
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 is not online. 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
jetta765214Epic is not online. jetta765214Epic
Joined: 23 Feb 2011
Total Posts: 228
31 Jul 2011 03:21 PM
table = {}
table[1] = (function(words) print(words) end)

table[1]("line")

-->line

like this would work
Report Abuse
ShiroPixel is not online. ShiroPixel
Joined: 31 Jul 2010
Total Posts: 545
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
SoulStealer9875 is not online. SoulStealer9875
Joined: 20 Jul 2009
Total Posts: 13119
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
ShiroPixel is not online. ShiroPixel
Joined: 31 Jul 2010
Total Posts: 545
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
SoulStealer9875 is not online. SoulStealer9875
Joined: 20 Jul 2009
Total Posts: 13119
31 Jul 2011 04:03 PM
Your example won't work.

If you don't want help then get out.
Report Abuse
ShiroPixel is not online. ShiroPixel
Joined: 31 Jul 2010
Total Posts: 545
31 Jul 2011 04:06 PM
Do you read at all? My example shows how it is used.
Report Abuse
Boomarang is not online. 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
SoulStealer9875 is not online. SoulStealer9875
Joined: 20 Jul 2009
Total Posts: 13119
31 Jul 2011 04:11 PM
I ALREADY MADE YOU ONE.
Report Abuse
ShiroPixel is not online. ShiroPixel
Joined: 31 Jul 2010
Total Posts: 545
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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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 is not online. 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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
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
ShiroPixel is not online. ShiroPixel
Joined: 31 Jul 2010
Total Posts: 545
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
SoulStealer9875 is not online. SoulStealer9875
Joined: 20 Jul 2009
Total Posts: 13119
01 Aug 2011 11:59 AM
Shiro, just to let you know;

This is ROBLOX, not GMod.
Report Abuse
agent767 is not online. agent767
Joined: 03 Nov 2008
Total Posts: 4181
01 Aug 2011 12:01 PM
@Soul
game.Parent.Name = "GMod"
:p
Report Abuse
SoulStealer9875 is not online. SoulStealer9875
Joined: 20 Jul 2009
Total Posts: 13119
01 Aug 2011 12:02 PM
@agent
Respect = Respect - 1
Report Abuse
unknown89089 is not online. unknown89089
Joined: 21 Aug 2008
Total Posts: 2961
01 Aug 2011 12:03 PM
repeat
SoulStealer9875.Respect = SoulStealer9875.Respect - 1
until SoulStealer9875.Satisfied == true
Report Abuse
agent767 is not online. 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
unknown89089 is not online. unknown89089
Joined: 21 Aug 2008
Total Posts: 2961
01 Aug 2011 12:05 PM
Your print will error.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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