Clipboard parsing Topic is solved

Ask gaming related questions
Guest

Clipboard parsing

09 Dec 2017, 22:30

I'm new to the forums so first I'd just like to say hi and that it seems like a great community around here!

Anyway, I'm stumped on parsing text from a webpage to get data, specifically copying all text on the page and trying to perform math on a number found from the parsing. Here's some code for example:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



And here is a clipping from text on the page:

Trade Skills Rank: Taskmate
Weaponcrafting: 88
Armorcrafting: 400
Bowcrafting: 11
Spellcrafting: 18
Reliccrafting: 4
Chantcrafting: 4
Metalworking: 400
Leatherworking: 400
Woodworking: 82
Glassworking: 19
Gemworking: 22
Runeworking: 6

It seems intermittent whether or not craftLevel will resolve to show 88 or some other odd text or nothing at all. And when it does resolve correctly I can never get the division to work properly either. What am I doing wrong?
User avatar
evilC
Posts: 4175
Joined: 27 Feb 2014, 12:30

Re: Clipboard parsing

11 Dec 2017, 05:41

I found zero intermittent behavior. findText("Weaponcrafting") always returns 88.
FYI, you probably need a check in findText, as if you search for something that is not present, it returns the last line.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
evilC
Posts: 4175
Joined: 27 Feb 2014, 12:30

Re: Clipboard parsing  Topic is solved

11 Dec 2017, 05:45

Also, there is a more efficient way to do this:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Download] GeSHi © Codebox Plus

autoCraft(craftSkill) {
static lookups := {Weapon: 14, Armor: 20, Bow: 12, Spell: 17, Relic: 11}
if (lookups.HasKey(craftSkill))
itemType := lookups[craftSkill]
else
return
[...]

Return to “Gaming”

Who is online

Users browsing this forum: davorj and 6 guests