Wintermute Engine Forum

Wintermute Engine => Scripts, plugins, utilities, goodies => Topic started by: GreyDay on February 01, 2012, 11:16:22 AM

Title: Splice arrays
Post by: GreyDay on February 01, 2012, 11:16:22 AM
I wanted to use a splice function for an Array in a game I am developing, and noticed that it isn't implemented in WME script.
I made a function that worked great for me for the purpose, and as I saw another question on the forum about it I thought that I might upload the piece of code for others to use. Nothing complicated, but nontheless:

Code: [Select]
function Splice(var array, var place){
//Move the unwanted object in the array to the end.
for (var i = place; i <= array.Length -1; i = i +1)
{
array[i] = array[i + 1];
}
//And pop it.
array.Pop();
}
Title: Re: Splice arrays
Post by: GreyDay on February 01, 2012, 12:20:50 PM
Noticed that i put the thread in the wrong place, could someone move it?
Title: Re: Splice arrays
Post by: Mnemonic on February 01, 2012, 06:16:20 PM
Done. Thanks!