Page 1 of 1

Finding String

Posted: Sun Jan 06, 2013 12:42 pm
by kenzu38
Hey guyz, like title says, I wanna know how I can find string from the game's tooltip. Reason is that I wanna collect 3 stat fusion stones that I get from CoT and I segregate them by stats they have. So Stam/Int/X stones get mailed to a mule char, Stam/Dex/X get mailed to another mule and so on.

Can anyone help me with this? Thanks.

Re: Finding String

Posted: Sun Jan 06, 2013 12:56 pm
by rock5
The item class includes the stats of an item. The stats are saved in a table call Stats, ie. item.Stats and each stat includes the id and name of the stat, ie. item.Stats[1].Id and item[1].Name.

Re: Finding String

Posted: Sun Jan 06, 2013 1:50 pm
by kenzu38
Whoa, it's too complicated for me at my current level so if it's ok, maybe you can post a sample code that determines if a stone has Stam/Int/X stats to guide me?

Re: Finding String

Posted: Sun Jan 06, 2013 2:26 pm
by rock5

Code: Select all

function itemHasStat(item, stat)
    if (item.Stats[1] and item.Stats[1].Name == stat) or
      (item.Stats[2] and item.Stats[2].Name == stat) or
      (item.Stats[3] and item.Stats[3].Name == stat) then
        return true
    end
end

for slot = 61,120 do
    item = inventory.BagSlot[slot]
    if item.Name == "Fusion Stone" then
        if #item.Stats == 1 then
            -- send to mule 1
        elseif itemHasStat(item, "Dexterity I") then
            -- send to mule 2
        elseif itemHasStat(item, "Intelligence I") then
            -- send to mule 3
        end
    end
end
Note1: it's untested.
Note2: Checks all 60 slots of bag 1 and 2.
Note3: You have to put in the send commands

Re: Finding String

Posted: Mon Jan 07, 2013 3:21 am
by kenzu38
Ok, thanks for this code! :) I'll begin testing this.

Quick question though, #item.Stats means the number of stats the item has?

And for tier, can you use something like item.Tier?

Re: Finding String

Posted: Mon Jan 07, 2013 4:17 am
by botje
looking tru item.lua, tier is not yet used.

rest is there though

Re: Finding String

Posted: Mon Jan 07, 2013 5:28 am
by lisa
would we really need to know the tier of an item though?
If you are talking mana stone(might be fusion, can't remember which is which) the tier is in the name. I don't see a need to know the tier of an armor or weapon.

Re: Finding String

Posted: Mon Jan 07, 2013 1:18 pm
by kenzu38
I was just thinking of customizing the cleanBag function to filter runes through tier. The recent events they made made me want to stock up on III runes. :)

Anyway guyz, #item.Stats means the number of stats the item has?

Re: Finding String

Posted: Mon Jan 07, 2013 2:40 pm
by rock5
kenzu38 wrote:Anyway guyz, #item.Stats means the number of stats the item has?
Yes.

Re: Finding String

Posted: Mon Jan 07, 2013 4:47 pm
by botje
but for runes,, you could easily add them to the forcekeep, and done xd

Re: Finding String

Posted: Mon Jan 07, 2013 6:35 pm
by lisa
kenzu38 wrote:I was just thinking of customizing the cleanBag function to filter runes through tier.
yup the tier is in the name.
Harm II
Harm III
Harm IV
etc...

Re: Finding String

Posted: Tue Jan 08, 2013 4:16 am
by kenzu38
botje wrote:but for runes,, you could easily add them to the forcekeep, and done xd
Lol yea but I thought it would be easier to just filter 2 tiers (Tiers 1 and 2 ) of runes than type all the names of those runes in the forcekeep table, including the ones you get from minigames (which is quite a lot). When the list gets bulky, it will be harder to add or remove items in the future.
lisa wrote:yup the tier is in the name.
Harm II
Harm III
Harm IV
etc...
I also thought of string.find but I just think it's less reliable than filtering items through tier (if possible, but turns out it's not). If I filter items with "I", would it also delete II, III, IV, IX?

Anyway, this is easy to test myself, it's just that I'm hooked on some TV series right now and I wanna watch all the eps before I get back to playing (botting). :)
rock5 wrote:
kenzu38 wrote:Anyway guyz, #item.Stats means the number of stats the item has?
Yes.
Ok, thanks rock!

Re: Finding String

Posted: Tue Jan 08, 2013 6:24 am
by rock5
Filtering by "I" will filter everything with "I" in it. But you can do more with patterns eg. " I$" will filter names that end in " I" (note the space, so only one "I"), " II$" will filter items ending in " II", etc.

Re: Finding String

Posted: Tue Jan 08, 2013 7:35 am
by kenzu38
Hoho that's what I needed, didn't know about that pattern stuff. This'll make the bot delete exactly what I want it to.

As always, thanks a lot, rock! :D