|
| 16 Dec 2015 10:39 PM |
I need to know how to print individual components of the (...) table (is it at table?)
function hi (...) --print statement...what goes here to print all args? end
hi (1,2,3) |
|
|
| Report Abuse |
|
|
| |
|
|
| 16 Dec 2015 10:43 PM |
ah, I get it. Thanks!
Also what version of Lua is roblox currently using? |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2015 10:47 PM |
| I'm wondering if there's any way to edit a value in (...) without making the whole thing into a table |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Dec 2015 10:49 PM |
Well sort of, but it's really not a good idea.
You can get certain values of a tuple using the select function but just stick to tables. |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2015 10:56 PM |
I made a sort-of-OOP thing for sending and receiving remote events and I'm using (...) a lot
But the thing is that I'm wanting to serialize empty tables into a string "empty table" which i can later deserialize into an empty table because otherwise I get a weird "keys must be strings" error when sending empty tables to and fro
So yeah, I'm wanting to search for a table in (...), checking if it's empty and changing it. |
|
|
| Report Abuse |
|
|
| |
|
|
| 16 Dec 2015 10:57 PM |
| Why isn't it a good idea, I'd really like to know? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Dec 2015 11:00 PM |
Dealing with tuples like that is a hassle and is just asking for trouble. If it's a tuple, it can be an array (so to speak). So you're not going to run into problems treating them as arrays then (if you really want to) reunpacking them. |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2015 11:01 PM |
| How do I remake the array into a tuple? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
| |
|
XIPokezIX
|
  |
| Joined: 24 Sep 2015 |
| Total Posts: 381 |
|
|
| 17 Dec 2015 03:05 AM |
| tuples like this are only really necessary for events imo |
|
|
| Report Abuse |
|
|
|
| 17 Dec 2015 06:16 AM |
^ They are necessary in a lot of cases, most being the thing your sending the parameters to won't know what it is, so you will send a couple of arguments.
function output(type, ...) if type == 'print' then for k, v in next, {...} do print(k, v) end elseif type == 'warn' then for k, v in next, {...} do warn(k, v) --Warn can take > 1 arguments? I am not sure.. end else print'no other types defined yet' end end |
|
|
| Report Abuse |
|
|
|
| 17 Dec 2015 10:53 AM |
local func=function(...) local args={...} args=unpack(args) otherfunc(args) end
I'm wanting to pass arguments into func, create a table out of the tuple then remake the table into a tuple which I want to send on its way to otherfunc with the same arguments func received. But I'm doing it wrong. Halp |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 17 Dec 2015 10:57 AM |
local func=function(...) otherfunc(...) end |
|
|
| Report Abuse |
|
|
|
| 17 Dec 2015 11:01 AM |
| Yeah I know but I'm trying to pack the taple into a tuple then unpack it again. Not sure if it's possible though |
|
|
| Report Abuse |
|
|
| |
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 17 Dec 2015 11:06 AM |
You can't set a variable to a tuple...
local func=function(...) local args={...} otherfunc(unpack(args)) end |
|
|
| Report Abuse |
|
|
| |
|