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: Table.copy

Previous Thread :: Next Thread 
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 11:17 AM
Table = table

Table.copy = function(Org, Meta, Tab)
local copy = {}
for _,v in pairs(Org) do
if type(v) == "table" then
if Tab == 1 then
table.insert(copy, table.copy(v, Meta, Tab))
elseif Tab == 2 then
table.insert(copy, v)
end
else
table.insert(copy, v)
end
end
if Meta == 1 then
setmetatable(copy, table.copy(getmetatable(Org), Meta, Tab))
elseif Meta == 2 then
setmetatable(copy,
getmetatable(Org))
end
return copy
end


T = {"a", "b", {}}

setmetatable(T, {__add = "yolo"})

Table.copy(T, 1, 1)



Says that Org isn't a table, it's nil, when I attempt to use pairs, one line 5.

Help.

By the way, a little note;

Org is a table, Meta has two options 1, copied, 2, shared. Same goes for Tab except for Tables inside. Will be adding option 0 soon. (Not copied)
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 03:53 PM
Any help?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:01 PM
Help?
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
05 Jul 2014 06:02 PM
suggestion: read a lua tutorial
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:04 PM
Alright, send one over when your finished with them.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:05 PM
you're
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
05 Jul 2014 06:05 PM
I'm surprised you haven't found one since you look for scripts to steal on a daily basis to show off on here.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:09 PM
Duel, how can I find one? Whenever you find a tutorial you takes it to make sure you can take the example code from it, you don't give anybody else a chance to learn!
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
05 Jul 2014 06:11 PM
"Duel, how can I find one? Whenever you find a tutorial you takes it to make sure you can take the example code from it, you don't give anybody else a chance to learn!"

1. Only tutorials I ever look at now a days are math related

2. You obviously need to learn how to use the internet, no one can "take" virtual text.

3. Sorry that you're forced to copy my educated posts to make yourself look smart.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:14 PM
1. Thanks for proving you had to look up the % operator using my links.

2. I know you can't, your not smart enough too

3. That has nothing to do with this, learn to stay on topic.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
05 Jul 2014 06:17 PM
"1. Thanks for proving you had to look up the % operator using my links.

2. I know you can't, your not smart enough too

3. That has nothing to do with this, learn to stay on topic."


1. Did not prove anything, and the links aren't yours + stackoverflow isn't for math idiot.

2. Coming from a brainless idiot

3. Meaning it's true.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:24 PM
Duelling, the only good thing about you is...

Well, there isn't really.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
05 Jul 2014 06:25 PM
Translation:

You lose and did everything that I have pointed out.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:28 PM
You know, you're proving yourself a fool right now, for 1 you're making no sense, for 2, you can't even answer my question


Anybody got a REAL answer?
Report Abuse
nomer888 is not online. nomer888
Joined: 13 Feb 2010
Total Posts: 551
05 Jul 2014 06:28 PM
Can you please elaborate on what this function exactly does? Your explanation wasn't too clear to me.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
05 Jul 2014 06:29 PM
@war

I did, since you probably ripped this off somewhere else, my suggestion was to learn to script.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:34 PM
I didn't rip it off anyone.

@nom

It is supposed to copy a table, when you assign a table to a val;

local X = {"Hi"}

X is just a "pointer", so this would happen;

local X = {"Hi"}
local Y = X

table.remove(X, 1)

print(Y[1])

--nil

So, this function should copy it, instead if creating a new reference to it.
Report Abuse
nomer888 is not online. nomer888
Joined: 13 Feb 2010
Total Posts: 551
05 Jul 2014 06:36 PM
Sorry, I was referring mainly to the last two arguments, "Meta" and "Tab."
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:39 PM
Well, Meta is either 1 or 2

1 means that the Metatable for the table you're copying is copied too
2 means that the Metatable for the table you're copying is just a reference or a "pointer"

The same goes for Tab, except instead of the Metatable it is for any table values IN the table.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
05 Jul 2014 06:45 PM
copying tables are easy
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:45 PM
Online you'd find two different types of copieing tables,

ShallowCopy: Copies the surface, main values, tables are references.

DeepCopy: Copies Metatables, surface, tables etc.


My function aims to be useable as both.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:47 PM
@duel

Depends on if you want a shallow copy, deep copy, or some type of in between.

I'm kind if glad that they are references, you can make more options for things like sharing Metatables, etc.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
05 Jul 2014 06:49 PM
So basically you want to copy EVERYTHING.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 06:50 PM
That would be a deep copy.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
05 Jul 2014 07:19 PM
So uh, any help here?
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