Author Topic: How could I do this with Arrays?  (Read 495 times)

I'm making an array of data so it's

MassiveArray[1] = "Lots of data.";
MassiveArray[2] = "Even more data.";
MassiveArray[3] = "Data!";

When I do deleteVariables on MassiveArray[2] it leaves me with:

MassiveArray[1] = "Lots of data";
MassiveArray[3] = "Data";

Is there any method of storing variables so that when you delete an array I can cover up the gap or shuffle it so that [2] exists again and [3] is deleted. Otherwise if I can't do it I end up with large gaps in the Array for when I want to cycle through each value. I've looked for help on the forum and outside it but I can't find any information on how I could do this.

Something like this could work

Code: [Select]
$MassiveArrayList = " 0 1 3 4 6 ";

//to delete data in the list
$MassiveArrayList = strReplace($MassiveArrayList," " @ %dataNumber @ " "," ");

//to read your data
%list = trim($MassiveArrayList);
%count = getWordCount(%list);
for(%i=0;%i<%count;%i++)
    doSomething($MassiveArray[getWord(%list,%i)]);

Or you could rebuild the array

Something like this could work

Code: [Select]
$MassiveArrayList = " 0 1 3 4 6 ";

//to delete data in the list
$MassiveArrayList = strReplace($MassiveArrayList," " @ %dataNumber @ " "," ");

//to read your data
%list = trim($MassiveArrayList);
%count = getWordCount(%list);
for(%i=0;%i<%count;%i++)
    doSomething($MassiveArray[getWord(%list,%i)]);
That looks good. I'm testing it right now.

I'll give a bit more about the actual need for this. I'm making a large array and adding to it every time a player joins. I also want the ability to remove a player's Blockland ID from the array and I also want the ability to cycle through all the Blockland IDs.