Jump to content

SkillTracker Paint


Yellows

Recommended Posts

g.drawString("" + getExperienceTracker().getGainedXPPerHour(Skill.ATTACK), 346, 415);

This gets the experience of one skill, but I want multiple skills in paint, so I tried 

g.drawString("" + getExperienceTracker().getGainedXPPerHour(Skill.ATTACK) + getExperienceTracker().getGainedXPPerHour(Skill.DEFENCE), 346, 415);

But it doesn't start on 0 and it starts at 9000 and something.

Link to comment
Share on other sites

g.drawString("Strength XP gained: " + xpGainedstr + "    " + beginningstrLevel + " / " + currentstrLevel + " (+" + levelsstrGained + ")", 10, 285); 
g.drawString("Attack XP gained: " + xpGainedatt + "    " + beginningattLevel + " / " + currentattLevel + " (+" + levelsattGained + ")", 10, 300); 

This is what I use for something with more than 1 skill smile.png

Edited by IHB
Link to comment
Share on other sites

g.drawString("" + getExperienceTracker().getGainedXPPerHour(Skill.ATTACK), 346, 415);

This gets the experience of one skill, but I want multiple skills in paint, so I tried 

g.drawString("" + getExperienceTracker().getGainedXPPerHour(Skill.ATTACK) + getExperienceTracker().getGainedXPPerHour(Skill.DEFENCE), 346, 415);

But it doesn't start on 0 and it starts at 9000 and something.

 

 

This is due to the String thinking + is concatenation, and you figuring the 2 Integers would be added. How java reads this is:

"" + "900" + "0"

Where you want code like:

Integer totalXpPerHour = getExperienceTracker().getGainedXPPerHour(Skill.ATTACK) + getExperienceTracker().getGainedXPPerHour(Skill.DEFENCE);
g.drawString("" + totalXpPerHour, 346, 415);

You could also do it like this, but I feel it is messier:

g.drawString("" + (getExperienceTracker().getGainedXPPerHour(Skill.ATTACK) + getExperienceTracker().getGainedXPPerHour(Skill.DEFENCE)), 346, 415);

Note the parenthesis around the addition parts, then the "" + to make it a String.

Edited by Lemons
  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...