Jump to content
Totoka

Another stone combiner ( +NPC 2.4 )

Recommended Posts

Totoka, 

I'm using your script, however, when I'm going to combine, need 9x lv1 and only strip 8x lv1, how do I only need 8x and take 8x?

Share this post


Link to post
Share on other sites

Sorry for bumping up this old topic, but I need some help with this script.

 

The script only return 1 count, while I have 8 gems with level 1 stacked in one inventory slot.

Most likely the script below expect that each gem has their own inventory slot.

Is there a function to check the level of stacked items?

 

Also when I have more than 8 gems in one slot, for example 12 times a level 1 gem, the script removes 8 and converts all remaining gems into level 4.

 

 

function HasStone(character, stoneID, stoneLv, stoneCount)
    local amount = CheckBagItem(character,stoneID)
    if amount < stoneCount then
        return LUA_FALSE
    end
    local bagSize = GetKbCap(character)
    local count = 0
    for i=1, bagSize do
        local gem =GetChaItem(character, 2, i)
        if gem ~= nil then
            local id =GetItemID(gem)
            if id == stoneID then
                local lv = Get_StoneLv(gem)
                if lv == stoneLv then
                    count = count + 1
                end
            end
            if count >= stoneCount then
                return LUA_TRUE
            end
        end
    end
    return LUA_FALSE
end

 

I have now reversed the script and changed it into a check for the exact amount and exact level.

Quick and dirty, but this new version works.

 

function HasStone(character, stoneID, stoneLv, stoneCount)
    local amount = CheckBagItem(character,stoneID)
    if amount ~= stoneCount then
		SystemNotice(character,"You need exactly "..stoneCount.." gems in your inventory. Amount = "..amount)
        return LUA_FALSE
    end
	
    local bagSize = GetKbCap(character)
    for i=0, bagSize do
        local gem =GetChaItem(character, 2, i)
        if gem ~= nil then
            local id =GetItemID(gem)
            if id == stoneID then
                local lv = Get_StoneLv(gem)
                if lv ~= stoneLv then
					SystemNotice(character,"Found gem level = "..lv)
					SystemNotice(character,"Remove the high level gems from your inventory")
					return LUA_FALSE
                end
            end
        end
    end
	
	SystemNotice(character,"Succesful! "..amount.." gems of level "..stoneLv.." detected.")
    return LUA_TRUE
end

 

 

If anyone has a better solution for the stacked items, level check I am open for suggestions. 🙂

 

 

 

Edited by wouter2004

Share this post


Link to post
Share on other sites

@wouter2004 there is a function in Corsairs files that is GetItemStackSize()
you can use it
 

local itemCount = GetItemStackSize(gem)
if (itemCount >= stoneCount) then
	return	LUA_TRUE
end

 

  • Thanks 1

Share this post


Link to post
Share on other sites
On 9/28/2021 at 12:32 AM, JaR said:

@wouter2004 there is a function in Corsairs files that is GetItemStackSize()
you can use it
 


local itemCount = GetItemStackSize(gem)
if (itemCount >= stoneCount) then
	return	LUA_TRUE
end

 

many thanks this will help a lot.

using the counter and multiplying with the GetItemStackSize, will indeed with the right results 🙂

 

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.


×
×
  • Create New...