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: Table to input

Previous Thread :: Next Thread 
TheShadowMessage is not online. TheShadowMessage
Joined: 21 Sep 2012
Total Posts: 10379
01 Apr 2017 10:55 PM
Goal: Put entries of a table into the input of a function.
The number of entries is known only to the script.

Table=part:GetChildren()

function stuff(Table[1],Table[2],Table[3]...)
end

Basically I want it to continue adding inputs for each member of the table. Is that even possible?
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
01 Apr 2017 10:57 PM
local tab = part:GetChildren()

local function func(...)
print(...)
end

func(unpack(tab))


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
01 Apr 2017 10:59 PM
print is an example of a variadic function (vararg)

local function count( ... )
print( #( {...} ) ) --... will be a sequence of inputs, not a table (1,2,3 vs {1,2,3})
end


count( 2, 5, "HI", string )

you can place other arguments in a vararg function, but only beforehand

local function countMult( multiplier, ... )
print( #( {...} ) * multiplier )
end

countMult( 2, 5, "HI", string )
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
01 Apr 2017 11:00 PM
That's completely irrelevant...


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
01 Apr 2017 11:02 PM
ik, but also why do you need to do that? just give them the table if you need to send the arguments.. unless you are storing arguments it needs to use in a table
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
01 Apr 2017 11:06 PM
I understand what you mean, but OP probably has a reason why he wants them each as a parameter. If he's doing something where the variable number of arguments would end up in a table anyway then yeah, of course you would just send the table.


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