Thread: [delta] 2d array teleporting

Results 1 to 6 of 6
  1. #1 [delta] 2d array teleporting 
    Donator

    Join Date
    Mar 2014
    Posts
    234
    Thanks given
    26
    Thanks received
    39
    Rep Power
    32
    So basically, i am working on a mini game where if you click on a portal, it will teleport you to a random fixed location. To do this, i have made a 2d array as suggested by a friend.

    Here is the 2d array
    Code:
    public int MazeMini[][] = {{2666, 10015}, {2654, 10004}, {2642, 10006}, {2666, 10025},};
    I can't seem to figure out how to implement those coords with my servers teleporting method. I am not familiar with 2d arrays so im not sure how i am supposed to do this.

    I tried the following methods, but they did not work
    Code:
    teleportox = MazeMini[1]
    teleporttoy - MazeMini[2]
    And

    Code:
    triggertele(MazeMini[1], MazeMini[2], 0, true)
    I can explain how the teleport methods work but its pretty self explanatory. Any ideas how i can get this to work? I would really appreciate some help.
    www.dodianxiv.com The most advanced Dodian remake ever.

    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Dec 2011
    Posts
    454
    Thanks given
    17
    Thanks received
    37
    Rep Power
    61
    You should look at 2d array in terms of x and y, or rows and columns. To get a piece of data you will need to specify the x and y.
    Code:
    public int MazeMini[][] = {{2666, 10015}, 
                                      {2654, 10004}, 
                                      {2642, 10006}, 
                                      {2666, 10025},};
    triggertele(MazeMini[0][0], MazeMini[0][1], 0, true)
    MazeMini[0][0] = 2666
    MazeMini[0][1] = 10015
    Reply With Quote  
     

  3. #3  
    Donator

    Join Date
    Mar 2014
    Posts
    234
    Thanks given
    26
    Thanks received
    39
    Rep Power
    32
    Quote Originally Posted by Gershon View Post
    You should look at 2d array in terms of x and y, or rows and columns. To get a piece of data you will need to specify the x and y.
    Code:
    public int MazeMini[][] = {{2666, 10015}, 
                                      {2654, 10004}, 
                                      {2642, 10006}, 
                                      {2666, 10025},};
    triggertele(MazeMini[0][0], MazeMini[0][1], 0, true)
    MazeMini[0][0] = 2666
    MazeMini[0][1] = 10015
    Okay i used the [0][1], i guess thats what i was missing. But it only teleports to the first coords. How would i make it so it teleports to a random coord in the array? Thanks btw
    www.dodianxiv.com The most advanced Dodian remake ever.

    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Dec 2011
    Posts
    454
    Thanks given
    17
    Thanks received
    37
    Rep Power
    61
    I believe that most sources come with a misc class that has a method which generates a random number from 0 to the input given I think, so you would do
    int tele = Misc.random(MazeMini.length);
    triggertele(MazeMini[tele][0], MazeMini[tele][1], 0, true)
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Donator

    Join Date
    Mar 2014
    Posts
    234
    Thanks given
    26
    Thanks received
    39
    Rep Power
    32
    Quote Originally Posted by Gershon View Post
    I believe that most sources come with a misc class that has a method which generates a random number from 0 to the input given I think, so you would do
    int tele = Misc.random(MazeMini.length);
    triggertele(MazeMini[tele][0], MazeMini[tele][1], 0, true)
    The triggertele doesn't work method isn't working. This is what i currently am using, and it keeps teleporting to the first location still. Any ideas?
    Code:
    						int teleporttoX = misc.random(MazeMini.length);
    						int teleporttoY = misc.random(MazeMini.length);
    						teleportToX = MazeMini[0][0];
    						teleportToY = MazeMini[0][1];
    EDIT: Nvm, i figured it out, thanks a bunch for your help.
    www.dodianxiv.com The most advanced Dodian remake ever.

    Reply With Quote  
     

  7. #6  
    Registered Member
    Join Date
    Dec 2010
    Posts
    354
    Thanks given
    17
    Thanks received
    61
    Rep Power
    47
    Code:
    Int randomNumber = misc.random(MazeMini.length);
    player.teleportX = MazeMini[randomNumber][0]
    player.teleportY = MazeMini[randomNumber][1]
    btw for conventions the maze mini array should be constant.
    Reply With Quote  
     

  8. Thankful user:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 5
    Last Post: 03-06-2010, 11:51 PM
  2. 2d array help;
    By Kastro in forum Help
    Replies: 3
    Last Post: 11-30-2009, 01:22 PM
  3. 2d arrays
    By Kastro in forum Requests
    Replies: 2
    Last Post: 11-17-2009, 09:06 AM
  4. 2d array herblore
    By Lighten in forum Snippets
    Replies: 6
    Last Post: 08-24-2009, 05:25 AM
  5. Replies: 10
    Last Post: 03-14-2009, 05:07 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •