View Single Post
  #4  
Old 07-27-2012, 07:48 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
An easier more efficient approach would be to create a multi-dimensional array of warp coordinates:

PHP Code:
function onCreated(){
  
//x, y
  
this.warplocations = {
    {
5, 10},
    {
5, 20},
    {
5, 30},
    {
5, 40},
    {
15, 10},
    {
15, 20},
    {
15, 30},
    {
15, 40},
  };
  
this.warpamount = this.warplocations.size();
} 
And then increment an array index variable each time a player enters:

PHP Code:
function onPlayerEnters(){
  
player.x = this.warplocations[this.warpindex][0];
  
player.y = this.warplocations[this.warpindex][1];
  
//Use % to reset a value back to 0 if it overlaps specified value
  
this.warpindex = (this.warpindex + 1) % this.warpamount;
} 
Reply With Quote