Thread: Equiptment Types

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1 Equiptment Types (updated) 
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,336
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    rs2d base v2.1 was used for this

    this tutorial is used to make handling equiptment types alot easier
    instead of using an array to find all of the item ids and then return it takes forever
    it also misses alot of items

    instead we are going to find the items by findind if the phrase of the word is in there name

    first off head to
    net.varek.rs2d.model.EquiptmentTypes

    at the top add
    Code:
    import net.varek.rs2d.cfgloader.ItemLoader;
    we'll need this for the method getNameForID
    it will also find the name of the item in the item.cfg

    now go find
    Code:
        public static int getItemSlot(int item) {
    now instead of finding all the item ids from an integer we are going to find the items by there name which will be place in a txt file

    first off import the java.io class so we can use the buffered reader

    next add
    Code:
    	public static boolean readEquips(String path, int item) {
    			String line = null;
    		try {
        			BufferedReader in = new BufferedReader(new FileReader("conf/Equips/"+path+".txt"));
    			ItemLoader.getNameForID(item).toLowerCase().replaceAll("_", " ");
    
    			while((line = in.readLine()) != null) {
    				if(ItemLoader.getNameForID(item).toLowerCase().contains(line)) {
    					return true;
    				}
    			}
    
    		 } catch(Exception e) {
    			return false;
    		}
    		return false;
    	}
    thisll be used to find the names of the item in the text file

    now replace
    getItemSlot
    with
    Code:
        public static int getItemSlot(int item) {
            if (readEquips("capes", item)) {
                return EquipmentController.CAPE;
            }
    
            if (readEquips("boots", item)) {
                return EquipmentController.FEET;
            }
    
            if (readEquips("hands", item)) {
                return EquipmentController.HANDS;
            }
    
            if (readEquips("shields", item)) {
                return EquipmentController.SHIELD;
            }
    
            if (readEquips("amulets", item)) {
                return EquipmentController.AMULET;
            }
    
            if (readEquips("arrows", item)) {
                return EquipmentController.ARROWS;
            }
    
            if (readEquips("rings", item)) {
                return EquipmentController.RING;
            }
    
            if (readEquips("legs", item)) {
                return EquipmentController.LEGS;
            }
    
            if (readEquips("chests", item)) {
                return EquipmentController.TORSO;
            }
    
            if (readEquips("hats", item)) {
                return EquipmentController.HAT;
            }
    				
            // Else it is a weapon
            return EquipmentController.WEAPON;
        }
    now add the attachment to the folder conf

    save compile and run
    your done
    Last edited by Shamon King; 07-08-2008 at 12:35 AM. Reason: made a better version
    Reply With Quote  
     

  2. #2  
    Jim
    Jim is offline
    I dunno, its fine I guess

    Join Date
    Feb 2007
    Posts
    147
    Thanks given
    12
    Thanks received
    33
    Rep Power
    265
    Added both of these to the next release
    Reply With Quote  
     

  3. #3  
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,336
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    thanks
    =9 cant wait for the next one
    are you guys planing on getting hits to work?
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Aug 2006
    Posts
    50
    Thanks given
    0
    Thanks received
    0
    Rep Power
    4
    any reason why contains("hield") is missing the S ?
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. #5  
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,336
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    just incase something starts with a capital s
    just easier instead of doing startswith and endswith
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jun 2007
    Posts
    276
    Thanks given
    0
    Thanks received
    2
    Rep Power
    14
    Quote Originally Posted by shamon king View Post
    just incase something starts with a capital s
    just easier instead of doing startswith and endswith
    Can you use "containsIgnoreCase"?
    Reply With Quote  
     

  7. #7  
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,336
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    nope says cannot find sysmbol
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Jun 2007
    Posts
    276
    Thanks given
    0
    Thanks received
    2
    Rep Power
    14
    Quote Originally Posted by shamon king View Post
    nope says cannot find sysmbol

    What about "equalsIgnoreCase"? that one should work?
    Reply With Quote  
     

  9. #9  
    Jim
    Jim is offline
    I dunno, its fine I guess

    Join Date
    Feb 2007
    Posts
    147
    Thanks given
    12
    Thanks received
    33
    Rep Power
    265
    Quote Originally Posted by Brett` View Post
    What about "equalsIgnoreCase"? that one should work?
    equals is not the same concept as contains

    you could always go:

    Code:
    ItemLoader.getNameForID(item).toLowerCase().contains("boots")
    or leave it how it is... it works so there isn't really anything wrong with it
    Reply With Quote  
     

  10. #10  
    Registered Member
    Join Date
    Jun 2007
    Posts
    276
    Thanks given
    0
    Thanks received
    2
    Rep Power
    14
    Quote Originally Posted by Jim View Post
    equals is not the same concept as contains

    you could always go:

    Code:
    ItemLoader.getNameForID(item).toLowerCase().contains("boots")
    or leave it how it is... it works so there isn't really anything wrong with it
    yeah I kinda figured that
    Reply With Quote  
     

Page 1 of 2 12 LastLast

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
  •