View Full Version : How do you Split a Table
Kandoko
18-06-2006, 10:15 PM
Ok, im a bit Stumped, I need to divide a table of string values into two or three parts.
So for example values 1-10 in new table 1
values 11-20 in new table 2
any clues or help you can give. All my attempts have failed to copy the values over properly.
:ponder:
BamED
19-06-2006, 01:27 AM
Your explanation is very unclear. Please show an example of the input table and the expected output table. Then perhaps we can assist you in making a function that will do the job.
include
19-06-2006, 02:47 AM
hmmm... do you looking for something like that?
local big_table = { ...... } -- insert here your big table
local smalltables = {}; -- an array of small tables...
smalltables[1]={}; -- initiate the first small table
local i,j,count=1,1,1;
table.foreach(big_table, function(key,value)
smalltables[count][j]=value;
j=j+1;
if (j==11) then -- may be changed...
j=1;
count=count+1;
smalltable[count]={}; --initiate the next small table
end
end
Kandoko
23-06-2006, 01:17 AM
hmmm... do you looking for something like that?
end
Thanks include, a slight tweak and your code snippet was perfect for what I needed. :thumbsup:
Unfortunatly, Blizzard is not playing along so heres question #2
What is the maximum chat message length so I can make sure my mods data strings stay below that limit?
I am working on a mod of some mods(Gatherdump/GatherShare) that transmits data over a custom channel. Im running into a problem of the data being cut off due to hitting a max length allowed per message apparently.
I have tried to figure out what this length is by sending messages out but it seems to vary. If I send a message with no spaces I seemd to get ~150 characters in a message. But if i add 10 spaces in between some of the chat message i can fit ~250 chatacters per message.
So just what is the logic behind the chat length so I can make sure my mods data strings stay below that limit?
include
23-06-2006, 09:35 AM
hmmm... make your chatstrings below 150 chars in general...
theres no logic. its a feature of WoW!
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.