Thread: Opening Every Door Flawlessly

Results 1 to 7 of 7
  1. #1 Opening Every Door Flawlessly 
    Registered Member
    Mister Maggot's Avatar
    Join Date
    Dec 2008
    Posts
    7,227
    Thanks given
    3,283
    Thanks received
    2,875
    Rep Power
    5000
    Alright, me and chase young were working on a project that would open every door in the server individually, without error. We were using this method,
    Code:
    public void openDoor(int doorID, int objectX, int objectY, String position) { 
              int face = 0;
              
              int oldObjectX = server.objectHandler.ObjectX[doorID]; //Leeched
              int oldObjectY = server.objectHandler.ObjectY[doorID]; //Leeched
              int oldFace = server.objectHandler.ObjectFace[doorID]; //Leeched
              
              if (position.equalsIgnoreCase("east")) {
                      face = -1;
              } else if (position.equalsIgnoreCase("west")) {
                      face = -3;
              } else if (position.equalsIgnoreCase("south")) {
                      face = -2;
              } else if (position.equalsIgnoreCase("north")) {
                      face = 0;
              } else {
                      misc.println("Invalid direction input");
              }
              
               if (objectX == oldObjectX && objectY == oldObjectY && oldFace != face) {
              ReplaceObject2(objectX, objectY, doorID, face, 10);
          } else {
                     misc.println("Error: cannot find door or face's are the same");
      }
      }
    paired w/ an if statement *unimportant, will keep hidden until released*
    and it would open every door to the correct face if used correctly in a switch.

    anyway, this method, sadly, doesnt work. it only prints out "Error: cannot find door or face's are the same", i am simply asking anyone who knows, if they could fix it please, i will give credits in the release
    Reply With Quote  
     

  2. #2  
    Registered Member
    Its paris's Avatar
    Join Date
    Apr 2009
    Posts
    1,141
    Thanks given
    56
    Thanks received
    234
    Rep Power
    689
    I just noticed something. You say the next thing:
    int oldObjectX = server.objectHandler.ObjectX[doorID];
    but in my server the doorID equals the objectModelId, so more than 1 door have the same doorID. This will probably help you out.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Mister Maggot's Avatar
    Join Date
    Dec 2008
    Posts
    7,227
    Thanks given
    3,283
    Thanks received
    2,875
    Rep Power
    5000
    i know, chase added in the specific coords for the door, so instead of opening every door with that id, it would open the one on that set of coords
    Reply With Quote  
     

  4. #4  
    Registered Member
    Deadly Uzi's Avatar
    Join Date
    Jul 2008
    Posts
    994
    Thanks given
    177
    Thanks received
    87
    Rep Power
    362
    Just remove that last if statement and see if the code works at all!
    Attempting to develop a multi-revision library. See it on GitHub.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Mister Maggot's Avatar
    Join Date
    Dec 2008
    Posts
    7,227
    Thanks given
    3,283
    Thanks received
    2,875
    Rep Power
    5000
    ive tried that... it is very aggravating, the code LOOKS perfect...
    Reply With Quote  
     

  6. #6  
    Registered Member
    Its paris's Avatar
    Join Date
    Apr 2009
    Posts
    1,141
    Thanks given
    56
    Thanks received
    234
    Rep Power
    689
    It often helps to write a debugline, try putting:
    Code:
    System.out.println("position :" + position);
    as the first line in the method.
    It'll most likely give you an insight in where it goes wrong, and why.
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Dec 2007
    Age
    32
    Posts
    551
    Thanks given
    0
    Thanks received
    2
    Rep Power
    503
    Code:
    public void openDoor(int doorID, int objectX, int objectY, String position) { 
              int face = 0;
              if (position.equalsIgnoreCase("east")) {
                      face = -1;
              } else if (position.equalsIgnoreCase("west")) {
                      face = -3;
              } else if (position.equalsIgnoreCase("south")) {
                      face = -2;
              } else if (position.equalsIgnoreCase("north")) {
                      face = 0;
              }
               if (face > -3 {
                    System.err.println("Invalid direction input:" +face+".");
              } else {
                  ReplaceObject2(objectX, objectY, doorID, face, 10);
              }
      }
    You had stuff that wasn't needed tbh lol. Also, that objecthandler class is pointless.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •