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

Solved Having trouble with stat upgrade script

lukatxd

Active Member
Joined
Dec 9, 2010
Messages
85
Solutions
1
Reaction score
39
I'm trying to install this script in TFS 1.2 downgraded to 8.6 by Nekiro

But the following errors appear when trying to apply extra stats to items inside bag
1597009277463.png

For debugging purposes I've added:
stats.lua
Lua:
function find_loot_Container(pos, extraPercent, monsterName, extraStackable, killer)
    local rares = 0
    local c = Tile(pos):getTopDownItem()
    Player('Knight Sample'):sendTextMessage(MESSAGE_INFO_DESCR, monsterName)
    Player('Knight Sample'):sendTextMessage(MESSAGE_INFO_DESCR, pos)
    Player('Knight Sample'):sendTextMessage(MESSAGE_INFO_DESCR, c)
    if c ~= nil then
        if c:isContainer() then
            if STATS_SYSTEM_CONFIG.monsterLoot then
                rares = rares + assign_loot_Stat(c)
            end

the function called
Lua:
function assign_loot_Stat(c)
    local wp_string = {"", ""}
    local arm_string = {"", ""}
    local other_string = {"", ""}
    local rares = 0
  
    local h = c:getItemHoldingCount()
    if h > 0 then
        for i = 1, h do
            wp_string = {"", ""}
            arm_string = {"", ""}
            other_string = {"", ""}
            local it_u = c:getItem(i - 1)
            local u = it_u:getUpgradeType()

The pos, and container variables are null.
As you may see, the Legion Helmet is generated inside the bag, but I'm not sure if there should be more items there that couldnt be placed because the error happened. idk.

1597009407943.png



Edit:
Also added these debugging lines:
1597012074899.png
result is:
19:25 new c is userdata: 0x1eaca4c0
19:25 new it_u is nil
 
Last edited:
Solution
E
why don't you just remove bag from monster then? (they were removed on 8.54 if I'm not mistaken) and removing them is as easy as using find and replace a few times on the monster folder
why don't you just remove bag from monster then? (they were removed on 8.54 if I'm not mistaken) and removing them is as easy as using find and replace a few times on the monster folder
 
Solution
why don't you just remove bag from monster then? (they were removed on 8.54 if I'm not mistaken) and removing them is as easy as using find and replace a few times on the monster folder
I didnt know which version removed the bags, so I tried fixing the script.
Your solution works indeed, because when checking how many items the corpse carries, it sums with items inside the bag causing it to look for a index that does not exist.

I feel stupid now for trying to debug it for a few minutes when an way simpler (and more version accurate) fix was so easy.
Thanks anyway XD
 
Back
Top