• 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!

Help with function

Elpulpo

Member
Joined
Mar 18, 2016
Messages
52
Reaction score
8
I need to transform this TFS 1.x function to OTHire (7.72).
Code:
local function getMoneyAmount(position)
    local moneyAmount = 0
    for _, item in ipairs(Tile(position):getItems()) do
        local itemId = item:getId()
        if itemId == ITEM_GOLD_COIN then
            moneyAmount = moneyAmount + item.type
        elseif itemId == ITEM_PLATINUM_COIN then
            moneyAmount = moneyAmount + item.type * 100
        elseif itemId == ITEM_CRYSTAL_COIN then
            moneyAmount = moneyAmount + item.type * 10000
        end
    end

    return moneyAmount
end
It looks for the amount of money in a position and returns a variable with the amount of money.
Can anyone help me?
 
Code:
local function getMoneyAmount(position)
    local moneyAmount = 0
    for _, item in ipairs(getThingFromPos(position)) do
        local itemName = getItemName(item)
        local itemId = getItemIdByName(itemName)
        if itemId == ITEM_GOLD_COIN then
            moneyAmount = moneyAmount + item.type
        elseif itemId == ITEM_PLATINUM_COIN then
            moneyAmount = moneyAmount + item.type * 100
        elseif itemId == ITEM_CRYSTAL_COIN then
            moneyAmount = moneyAmount + item.type * 10000
        end
    end

    return moneyAmount
end
 
Back
Top