Dreamliner Posted June 26, 2013 Share Posted June 26, 2013 private int getFoodHeal(int food) { int val = 0; switch (food) { case 6701: // baked potato val = 4; break; case 2309: // bread val = 5; break; case 333: case 2289: // plain pizza case 2291: // half plain pizza val = 7; // trout break; case 351: // pike case 2293: // meat pizza case 2295: // half meat pizza case 2297: // anchovy pizza case 2299: // half anchovy pizza val = 8; break; case 329: // salmon val = 9; break; case 361: val = 10; // tuna break; case 1993: // wine case 2301: // pineapple pizza case 2303: // half pineapple pizza val = 11; break; case 379: val = 12; // lobster break; case 365: // bass val = 13; break; case 373: // swordfish case 6703: // Potato with butter case 7054: // chilli potato val = 14; break; case 6705: // potato with cheese case 7496: // monkfish val = 16; break; case 385: // shark case 7058: // Mushroom potato val = 20; break; case 7060: //tuna potato val = 22; break; default: val = 7; break; } return val; } thought this would be useful to others Link to comment Share on other sites More sharing options...
Jordan Posted June 27, 2013 Share Posted June 27, 2013 So this heals certain foods? 1 Link to comment Share on other sites More sharing options...
Nicholas Posted June 27, 2013 Share Posted June 27, 2013 So this heals certain foods? how do you heal foods ? 1 Link to comment Share on other sites More sharing options...
H0ppy Posted June 27, 2013 Share Posted June 27, 2013 (edited) haha thx for sharing this with. Always cool to see people working to make everything easier and better! ^^ btw why is defaul val 7? xD you should return 0 or -1 to let it know it didn't find the food xD H0ppy Edited June 27, 2013 by H0ppy Link to comment Share on other sites More sharing options...
Dreamliner Posted June 27, 2013 Author Share Posted June 27, 2013 haha thx for sharing this with. Always cool to see people working to make everything easier and better! ^^ btw why is defaul val 7? xD you should return 0 or -1 to let it know it didn't find the food xD H0ppy default value is 7 incase it's an unknown food type. If it returned 0, your script could possibly eat everything in your inventory So this heals certain foods? getDogFood(); get food for dog getFoodHeal(); get heal for food Link to comment Share on other sites More sharing options...
jelknab Posted June 27, 2013 Share Posted June 27, 2013 This should be using item names. Link to comment Share on other sites More sharing options...
Dreamliner Posted June 27, 2013 Author Share Posted June 27, 2013 This should be using item names. Direct ID method is easier on the CPU. Link to comment Share on other sites More sharing options...
Tyluur Posted June 27, 2013 Share Posted June 27, 2013 Would be better to use an enum for this. Link to comment Share on other sites More sharing options...
Nicholas Posted June 27, 2013 Share Posted June 27, 2013 #confused Link to comment Share on other sites More sharing options...
Cyro Posted June 27, 2013 Share Posted June 27, 2013 Would be better to use an enum for this. just what i was thinking of. he could then loop through them check if he id entered = to enumname.getId or something the return value. simpler and cleaner Link to comment Share on other sites More sharing options...
Dreamliner Posted June 29, 2013 Author Share Posted June 29, 2013 just what i was thinking of. he could then loop through them check if he id entered = to enumname.getId or something the return value. simpler and cleaner You guys are making this way harder than it needs to be. There's a reason comments exist Link to comment Share on other sites More sharing options...
Cyro Posted June 29, 2013 Share Posted June 29, 2013 (edited) You guys are making this way harder than it needs to be. There's a reason comments exist the way it is now is fine and there is no problem with it but just kinda messy. and enum are not hard and it was just a suggestion you dont have to use it. public enum food{ TUNA("Tuna", 10, 361), BREAD("Bread", 5, 2309); food(String name, int value, int id){ this.name = name; this.value = value; this.id = id; } private String name; private int value; private int id; /*Name of the item*/ public String toString(){ return name; } /*gets the id of the food item*/ public int getId(){ return id; } /*get the healing value of the food item*/ public int getValue(){ return value; } } public int getHealValue(int id){ for(food f : food.values()){ if(f.getId() == id) return f.getValue(); } return -1; } public int getFoodHealValue(String name){ for(food f : food.values()){ if(f.toString().equalsIgnoreCase(name)) return f.getValue(); } return -1; } simple and less messy? and sorry if i got somethings wrong as i said just an example dont have to use it. Edited June 29, 2013 by Cyro Link to comment Share on other sites More sharing options...