IkiritokunI Posted December 9, 2018 Share 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! Quote Link to comment Share on other sites More sharing options...
jca Posted December 9, 2018 Share 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 Quote Link to comment Share on other sites More sharing options...
IkiritokunI Posted December 9, 2018 Author Share 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! Quote Link to comment Share on other sites More sharing options...
Explv Posted December 9, 2018 Share 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 Quote Link to comment Share on other sites More sharing options...
jca Posted December 9, 2018 Share Posted December 9, 2018 2 minutes ago, Explv said: That's going to be off by 1 Of course, my bad. I'll correct! Quote Link to comment Share on other sites More sharing options...
liverare Posted December 11, 2018 Share 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 Quote Link to comment Share on other sites More sharing options...
Tom Posted December 11, 2018 Share 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 Quote Link to comment Share on other sites More sharing options...