IkiritokunI Posted December 9, 2018 Posted December 9, 2018 Dear community! I got another question about getting my bot look at the total lvl we all know we can get static/dynamic skills like this: (getSkills().getDynamic(Skill.MINING) But I not found out yet how to get the bot look a total lvl Maybe a widget or is there a code for it? Thanks for the help!
jca Posted December 9, 2018 Posted December 9, 2018 (edited) Not sure if there is a method in the Skills API, I can't seem to find one, but you could do something like this... int totalLevel = 0; for( Skill skill : Skill.values() ){ totalLevel += getSkills().getStatic(skill); } log("My total level is " + totalLevel); Edited December 9, 2018 by jca
IkiritokunI Posted December 9, 2018 Author Posted December 9, 2018 5 minutes ago, jca said: Not sure if there is a method in the Skills API, I can't seem to find one, but you could do something like this... int totalLevel = -1; for( Skill skill : Skill.values() ){ totalLevel += getSkills().getStatic(skill); } log("My total level is " + totalLevel); Thanks! I will try this!
Explv Posted December 9, 2018 Posted December 9, 2018 (edited) 2 hours ago, jca said: Not sure if there is a method in the Skills API, I can't seem to find one, but you could do something like this... int totalLevel = -1; for( Skill skill : Skill.values() ){ totalLevel += getSkills().getStatic(skill); } log("My total level is " + totalLevel); That's going to be off by 1, totalLevel should be initialised to 0 Alternative using streams: int totalLevel = Arrays.stream(Skill.values()) .mapToInt(skill -> getSkills().getStatic(skill)) .sum(); Edited December 9, 2018 by Explv 3
jca Posted December 9, 2018 Posted December 9, 2018 2 minutes ago, Explv said: That's going to be off by 1 Of course, my bad. I'll correct!
liverare Posted December 11, 2018 Posted December 11, 2018 On 12/9/2018 at 11:30 AM, Explv said: That's going to be off by 1, totalLevel should be initialised to 0 Alternative using streams: int totalLevel = Arrays.stream(Skill.values()) .mapToInt(skill -> getSkills().getStatic(skill)) .sum(); *ahem* getSkills()::getStatic
Tom Posted December 11, 2018 Posted December 11, 2018 (edited) 2 hours ago, liverare said: *ahem* getSkills()::getStatic *drops mic* Now for the true s3 way to do it private final static int MAX_TOTAL_LEVEL = 2277; public int getTotalLevel(){ int totalLevel = MAX_TOTAL_LEVEL; for(int i = 0; i < Skill.values().length; i++){ totalLevel -= 99 - getSkills().getStatic(Skill.values()[i]); } return totalLevel; } I'll see myself out, selling private scripts Edited December 11, 2018 by Tom 2 1