• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved function onLook showing how much gold is inside

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,484
Solutions
9
Reaction score
217
Hello, as the tittle says, I want make some script onLook, to show how much gold are in the container, the container in this case is a normal backpack, the script will count in GOLD COINS, but if have crystal coins and platinum coins it will count as gold coins in the bag exemple:
I have 3 gold coins, 1 platinum coin and 1 crystal coin, the script will make it count 10103 gold coins...
I can't see what I can use to count this...
 
Solution
nice, it work flawlessly, then I need just adjust the string
Code:
if thing.itemid == 26688 and thing.isContainer then
            local goldcoins = thing:deepItemCount(ITEM_CRYSTAL_COIN) * 10000 + thing:deepItemCount(ITEM_PLATINUM_COIN) * 100 + thing:deepItemCount(ITEM_GOLD_COIN)
            description = description .. 'a gold pounch. \nIt contains ' .. goldcoins .. ' gold coins.'
I need to fix the look when have 1 gold coin and when have more than 1 gold coin
0 or 1 coin =
You see a gold pounch.
It contains 1 gold coin.
more than 1 coin =
You see a gold pounch.
It contains 10000 gold coins.
I know that is this line:
Code:
description = description .. 'a gold pounch. \nIt contains ' .. goldcoins .. ' gold coins.'
also I need...
Code:
function Container.deepItemCount(self, itemId)
    local ret = 0
    local size = self:getSize()
    for i = 0, size-1 do
        local item = self:getItem(i)
        if item then
            if item:isContainer() then
                ret = ret + Container(item:getUniqueId()):deepItemCount(itemId)
            end
            if item:getId() == itemId then
                ret = ret + item:getCount()
            end
        end
        
    end
    return ret
end

Then just use:
Code:
container:deepItemCount(ITEM_CRYSTAL_COIN) * 10000 + container:deepItemCount(ITEM_PLATINUM_COIN) * 100 + container:deepItemCount(ITEM_GOLD_COIN)
 
Code:
function Container.deepItemCount(self, itemId)
    local ret = 0
    local size = self:getSize()
    for i = 0, size-1 do
        local item = self:getItem(i)
        if item then
            if item:isContainer() then
                ret = ret + Container(item:getUniqueId()):deepItemCount(itemId)
            end
            if item:getId() == itemId then
                ret = ret + item:getCount()
            end
        end
      
    end
    return ret
end

Then just use:
Code:
container:deepItemCount(ITEM_CRYSTAL_COIN) * 10000 + container:deepItemCount(ITEM_PLATINUM_COIN) * 100 + container:deepItemCount(ITEM_GOLD_COIN)
nice, it work flawlessly, then I need just adjust the string
Code:
if thing.itemid == 26688 and thing.isContainer then
            local goldcoins = thing:deepItemCount(ITEM_CRYSTAL_COIN) * 10000 + thing:deepItemCount(ITEM_PLATINUM_COIN) * 100 + thing:deepItemCount(ITEM_GOLD_COIN)
            description = description .. 'a gold pounch. \nIt contains ' .. goldcoins .. ' gold coins.'
I need to fix the look when have 1 gold coin and when have more than 1 gold coin
0 or 1 coin =
You see a gold pounch.
It contains 1 gold coin.
more than 1 coin =
You see a gold pounch.
It contains 10000 gold coins.
I know that is this line:
Code:
description = description .. 'a gold pounch. \nIt contains ' .. goldcoins .. ' gold coins.'
also I need show the weigh
 
nice, it work flawlessly, then I need just adjust the string
Code:
if thing.itemid == 26688 and thing.isContainer then
            local goldcoins = thing:deepItemCount(ITEM_CRYSTAL_COIN) * 10000 + thing:deepItemCount(ITEM_PLATINUM_COIN) * 100 + thing:deepItemCount(ITEM_GOLD_COIN)
            description = description .. 'a gold pounch. \nIt contains ' .. goldcoins .. ' gold coins.'
I need to fix the look when have 1 gold coin and when have more than 1 gold coin
0 or 1 coin =
You see a gold pounch.
It contains 1 gold coin.
more than 1 coin =
You see a gold pounch.
It contains 10000 gold coins.
I know that is this line:
Code:
description = description .. 'a gold pounch. \nIt contains ' .. goldcoins .. ' gold coins.'
also I need show the weigh
Code:
description = ("%sa gold pounch. \nIt contains %d gold coin%s."):format(description, goldcoins, goldcoins > 1 and 's' or '')
 
Solution
Back
Top