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: how to return tupple arguments

Previous Thread :: Next Thread 
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
09 Jun 2015 07:43 AM
hi ^^

simple question, however I can't find it
with calling a function you can do this:
function thing(...)
end

however I can't do this:
... = thing();

you can probably do something like this:
package = {thing()};
however I don't like it
is there a fancy way to return a tupple?
Report Abuse
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
09 Jun 2015 07:45 AM
What..? O.e

function thing(...)
return {...}
end

thing1 = thing(args)
Report Abuse
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
09 Jun 2015 07:49 AM
okay I will restate my question :D

I have a function that returns 0 - infinite arguments
function thing()
return a, b c -- etc
end

how can I make it, that I get the tupple arguments
... = thing(); -- this does not work
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
09 Jun 2015 08:07 AM
you can use unpack and a table to return an unspecified number of arguments. Of course, returning the table would be better IMO.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
09 Jun 2015 08:08 AM
Oh. That's what you meant.

You can do that like this:

local TablizedTuple = {FunctionThatReturnsTuple(Arguments)}
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
09 Jun 2015 08:09 AM
local a, b, c = thing()
Report Abuse
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
09 Jun 2015 08:09 AM
okay, it would have been fun if it was possible the way I explained
I'll stick to returning tables and unpacking ^^
Report Abuse
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
09 Jun 2015 08:10 AM
@amanda that's not what I want, I want 0 - infinite arguments back
since I don't want to type infinite arguments that won't work
Report Abuse
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
09 Jun 2015 08:12 AM
@jarold
okay so {thing()} will work, however I don't like that syntax :D
thanks for the help ^^

sorry for the spamming :3
I got ninja'd
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
09 Jun 2015 08:22 AM
So you want to use the ellipsis operator?


local FunctionToHandleReturns = function(...)
-- Do stuff with ...
end

FunctionToHandleReturns(FunctionThatReturnsTuple(Arguments))
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
09 Jun 2015 08:22 AM
lol, that's even worse though :P
Report Abuse
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
09 Jun 2015 08:25 AM
wow I didn't thought about that
thank you for adding this :D
I think I'm going to do something like this, because it looks fancy
Report Abuse
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
09 Jun 2015 08:27 AM
if you do something like

function tuppleAction(...)
-- stuf
end

tuppleAction(functionTuppleReturn());

I think it looks quite nice ^^
Report Abuse
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
09 Jun 2015 08:29 AM
Couldn't you just do this?

function Var(...)
return {...}
end

Table = Var()
Report Abuse
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
09 Jun 2015 08:34 AM
yea that's almost the same ^^
expect that the action with the ... is placed to another function instead of first making a table :D
Report Abuse
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
09 Jun 2015 08:36 AM
You make the table in the function, then assign the returned table to a variable.

It's no different than doing: {unpack(Var())}

Doing: {Var()} creates a nested table if I'm not mistaken.
Report Abuse
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
09 Jun 2015 08:44 AM
euh wait, I think we meant the same but say it in different words :D

-- this is packing
function Var(...)
return {...}
end
Table = Var(functionThatReturnsTupple());
-- action with table

-- first from yarold (this one is the same as Var()):
table = {unctionThatReturnsTupple()};
-- action with table

--the last one from yarold was this:
function tuppleFunction(...)
-- action with ...
end
Table = tuppleFunction(functionThatReturnsTupple());

for some reason I more like the syntax of the last one, not really sure why though ^^
Report Abuse
anaIyze is not online. anaIyze
Joined: 29 May 2014
Total Posts: 2048
09 Jun 2015 09:00 AM
op is dumb
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
09 Jun 2015 09:09 AM
2 + 2 = 54
Report Abuse
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
09 Jun 2015 09:10 AM
@analize
thank you for this kind insult
next time say why you think so instead of insulting please,
because then I can do something with it
Report Abuse
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
09 Jun 2015 09:15 AM
How do you want your table to look?
1. {A, B, C}
2. {{A,B,C}}
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