Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Splice arrays  (Read 6595 times)

0 Members and 1 Guest are viewing this topic.

GreyDay

  • Lurker
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 23
    • View Profile
Splice arrays
« 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();
}
Logged

GreyDay

  • Lurker
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 23
    • View Profile
Re: Splice arrays
« Reply #1 on: February 01, 2012, 12:20:50 PM »

Noticed that i put the thread in the wrong place, could someone move it?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Splice arrays
« Reply #2 on: February 01, 2012, 06:16:20 PM »

Done. Thanks!
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.036 seconds with 19 queries.