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.remove

Previous Thread :: Next Thread 
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
24 May 2015 03:51 PM
Is it possible to do something like this with table.remove (instead of doing the index number like stated on the wiki)

table.remove(VeryLongTable, "value35") -- Searching for this, instead of the index number for 35.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
24 May 2015 03:51 PM
No.
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
24 May 2015 03:52 PM
are you asking about custom indices, or about removing based on the value not the index?
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
24 May 2015 03:53 PM
Removing based on the value, not index #
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
24 May 2015 03:53 PM
because the reason you can't remove based on the value the same way as an index, is because two different values can have the same index.
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
24 May 2015 03:53 PM
omg so much typo

two different indices can have the same value
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
24 May 2015 03:54 PM
You can make your own, or use warspyking's module.
This is how you would make it your own:

local function RemoveFromTable(table, value)
for i, v in pairs(table) do
if v == value then
table.remove(table, i)
end
end
end

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
Reinitialized is not online. Reinitialized
Joined: 11 Feb 2008
Total Posts: 688
24 May 2015 03:54 PM
No, this is not possible.
You can only use table.remove with numerical indexes.

Example:
local tbl={true,false,true,true,false,0,1,1,0,0,1,0,1,1,1,0};
local firstIndex=table.remove(tbl,1);
print(firstIndex,tbl[1]);
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
24 May 2015 04:03 PM
@powerhotmail123
Please let me test you.
It's a challange, 90% of all people on this forum won't succeed!
Find the error in your script.

If you can't find it pm me or reply to this thread, happy to help you out :)
If you can also pm me or reply to this thread.

I wish you the best of luck :)

Don't start to doubt your scripting skills if you can't find it , but it's a pretty simple and stupid error.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
24 May 2015 04:05 PM
@power

You simply don't avoid table.remove by looping through the table just to use table.remove at the end. That's just silly.
Report Abuse
BowtieMod is not online. BowtieMod
Joined: 01 Apr 2013
Total Posts: 804
24 May 2015 04:06 PM
table.remove(VeryLongTable, "value35")

what would that even do

associative arrays aren't even ordered

just do t[k] = nil
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
24 May 2015 04:07 PM
And no it's not this one:
"
local function RemoveFromT:6: attempt to call field 'remove' (a nil value)
"
that's just because you named a parameter after a datatype...
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
24 May 2015 04:09 PM
Ermm...

I only made it in 30 seconds lol. I have done it before in a real script.

I think it is because I used 'table'. I should have used something like Tab.

Am I right?

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
24 May 2015 04:11 PM
What's the simplest way to take the table from the module, and create a new one so that I can use table.remove on it without affecting the real table in the module?
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
24 May 2015 04:13 PM
No, it's because if the value's key is non-numeric then it will break because of the table.remove. Your script doesn't do anything more than what table.remove alone would be able to do.
Report Abuse
LucasLua is not online. LucasLua
Joined: 18 Jun 2008
Total Posts: 7386
24 May 2015 04:14 PM
http://wiki.roblox.com/index.php?title=Cloning_tables
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
24 May 2015 04:14 PM
I just said it wasn't that one...
It's alsno not that roblox parameters aren't passed by reference...
Report Abuse
BowtieMod is not online. BowtieMod
Joined: 01 Apr 2013
Total Posts: 804
24 May 2015 04:15 PM
there is nothing hard about this

set the reference to nil and the GC will take care of it

VeryLongTable[value35] = nil
Report Abuse
BowtieMod is not online. BowtieMod
Joined: 01 Apr 2013
Total Posts: 804
24 May 2015 04:17 PM
whoops

VeryLongTable["value35"]

huehuehue
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
24 May 2015 04:17 PM
@powerhotmail123
Just ignore the other people and try harder.
If you can find it, maybe I'll join your group...
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
24 May 2015 04:18 PM
Umm, I just tested the first script I posted, that didn't work. But when I replaces 'table' with 'Tab' it worked. So it does...
I also printed the values before and after, and it deleted it. With the exception of when I used 'table' instead of 'Tab', obviously.

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
24 May 2015 04:20 PM
@powerhotmail123
You still can't find it?
Think harder.
Like I said it's very simple, but a really annoying error...
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
24 May 2015 04:21 PM
Did you remove any non-numerical indices when you tested it?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
24 May 2015 04:21 PM
The obvious problem is that table.remove is not the thing he needed because it's not going to work in pairs.

function remove(t,v)
for k,n in pairs(t) do
if n == v then t[k] = nil; end;
end;
end;
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
24 May 2015 04:23 PM
@powerhotmail123
eLunate has the same error...
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