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

How to change Local Table Values with without using direct function?

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
626
Location
Estonia
Well im now at the point where i wanted to finish up my custom stat system.
Its nothing too fancy, but i wanted to make the script look fancy and small as possible.
So i had the idea how making functions, inside the functions.

But now the problem comes: how to pass the result into local table?
Here is what i tried, but it doesn't work so easily
Code:
local resistances = {
fireResistance = 0,
iceResistance = 0,
deathResistance = 0,
energyResistance = 0,
physicalResistance = 0
}
Code:
function checkStats(item, resistances)
    local itemStat = item:getDescription()
    local hasGem = gemCheck(itemStat)
    if hasGem then
        local resType = resCheck(hasGem)
        for k, v in pairs(resistances) do
            if k == resType then
                v = getValue(hasGem)
            end
        end
    end
    return resistances
end

Would be nice if someone knows how to make this function pass values to table without using function inside the table, then that would be aawzom.
Meanwhile i simply wont use the checkStats function.
 
Back
Top