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

Using Obsidian in a Ice Cube tons of bugs.

vichoko

Member
Joined
Oct 9, 2008
Messages
128
Reaction score
6
Location
Santiago, Chile
So, i have this mystery problem when i use my obsidian knife on a icecube.
So the progression of the icecube is:
7441 - Ice Cube,
7442- Ice Cube,
7444- Ice Cube,
7445- Ice Cube,
7446 - Ice mamooth.

The thing is that the id: 7443-bullseye potion is somehow appearing in the action.

When i use the obsidian in the 7441 cube, it creates two 7442 cubes if the process works; if it fails then a single 7442 cube appears.
Afterwards, if i use the obsidian knife in the 7442 cube, and it fails this 7443 potion appears. Otherwise, if the process works it converts to the 7444-ice cube correctly.

After that, if i use the knife in the 7444 ice cube, and it fails or work it converts to the 7445 - ice cube. The same happens with the 7445, if it works or it fails the ice mamooth appears.
I know when it fails because the 'fail message' displays correctly.
--
This is what happens, but taking a look to the script i'm using i can't find the problem.
For expample, the id 7443 doesn't appear anywhere in the script. I don't know what else to do.
If someone can help me with this script, or giving me other one that works it could be great :D

Sorry for my bad english, if is there something you didn't understand i can try to explain it better.

My obsidian.lua:
Code:
local config = {
    [5908] = {
        -- Minotaurs
        [2830] = {value = 25000, newItem = 5878},
        [2871] = {value = 25000, newItem = 5878},
        [2866] = {value = 25000, newItem = 5878},
        [2876] = {value = 25000, newItem = 5878},
        [3090] = {value = 25000, newItem = 5878},

        -- Low Class Lizards
        [4259] = {value = 25000, newItem = 5876},
        [4262] = {value = 25000, newItem = 5876},
        [4256] = {value = 25000, newItem = 5876},

        -- High Class Lizards
        [11288] = {value = 25000, newItem = 5876},
        [11280] = {value = 25000, newItem = 5876},
        [11272] = {value = 25000, newItem = 5876},
        [11284] = {value = 25000, newItem = 5876},

        -- Dragons
        [3104] = {value = 25000, newItem = 5877},
        [2844] = {value = 25000, newItem = 5877},

        -- Dragon Lords
        [2881] = {value = 25000, newItem = 5948},

        -- Behemoths
        [2931] = { {value = 10000, newItem = 5930 }, {value = 35000, newItem = 5893 } },

        -- Bone Beasts
        [3031] = {value = 25000, newItem = 5925},

        -- The Mutated Pumpkin
        [8961] = { { value = 5000, newItem = 7487 }, { value = 10000, newItem = 7737 }, { value = 20000, 6492 }, { value = 30000, newItem = 8860 }, { value = 45000, newItem = 2683 }, { value = 60000, newItem = 2096 }, { value = 90000, newItem = 9005, amount = 50 } },

        -- Marble
        [11343] = { {value = 10000, newItem = 11345, desc = "This shoddy work was made by |PLAYERNAME|." }, {value = 35000, newItem = 11345, desc = "This little figurine made by |PLAYERNAME| has some room for improvement." }, { value = 60000, newItem = 11346, desc = "This little figurine of Tibiasula was masterfully sculpted by |PLAYERNAME|." } },

        -- Ice Cube
        [7441] = {value = 25000, newItem = 7442},
        [7442] = {value = 25000, newItem = 7444},
        [7444] = {value = 25000, newItem = 7445},
        [7445] = {value = 25000, newItem = 7446},
    },
    [5942] = {
        -- Demon
        [2916] = {value = 25000, newItem = 5906},

        -- Vampires
        [2956] = {value = 25000, newItem = 5905},
        [9654] = {value = 25000, newItem = 5905, after = 9658},
        [8938] = {value = 25000, newItem = 5905},
        [21275] = {value = 25000, newItem= 5905}
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    local skin = config[item.itemid][itemEx.itemid]

    -- Wrath of the emperor quest
    if item.itemid == 5908 and itemEx.itemid == 12295 then
        Item(itemEx.uid):transform(12287)
        player:say("You carve a solid bowl of the chunk of wood.", TALKTYPE_MONSTER_SAY)
    end

    if not skin then
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return true
    end

    local random, effect, transform = math.random(1, 100000), CONST_ME_MAGIC_GREEN, true
    if type(skin.value) == 'table' then
        local added = false
        for _, _skin in ipairs(skin) do
            if random <= _skin.value then
                if itemEx.itemid == 11343 then
                    effect = CONST_ME_ICEAREA
                    local goblet = player:addItem(_skin.newItem, _skin.amount or 1)
                    goblet:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, skin.desc)
                    added = true
                elseif isInArray({7441, 7442, 7444, 7445}, itemEx.itemid) then
                    player:addItem(_skin.newItem, _skin.amount or 1)
                    effect = CONST_ME_HITAREA
                    added = true
                else
                    player:addItem(_skin.newItem, _skin.amount or 1)
                    added = true
                end
                break
            end
        end

        if not added and itemEx.itemid == 8961 then
            effect = CONST_ME_POFF
            transform = false
        end
    elseif random <= skin.value then
        if itemEx.itemid == 11343 then
            effect = CONST_ME_ICEAREA
            local goblet = player:addItem(skin.newItem, skin.amount or 1)
            goblet:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, skin.desc)
        elseif isInArray({7441, 7442, 7444, 7445}, itemEx.itemid) then
            player:addItem(skin.newItem, skin.amount or 1)
            effect = CONST_ME_HITAREA
        else
            player:addItem(skin.newItem, skin.amount or 1)
        end
    else
        if isInArray({7441, 7442, 7444, 7445}, itemEx.itemid) then
            player:say('The attempt of sculpting failed miserably.', TALKTYPE_MONSTER_SAY)
            effect = CONST_ME_HITAREA
        else
            effect = CONST_ME_POFF
        end
    end

    toPosition:sendMagicEffect(effect)
    if transform then
        Item(itemEx.uid):transform(skin.after or itemEx.itemid + 1)
    end

    return true
end

Can someone just give me an action that is working for TFS 1.0 please
 
Last edited by a moderator:
Can someone just give me an action that is working for TFS 1.0 please
Updated ice cube, marble sculpting and monster changes/ids (corrected some)
Could be done better but it works properly so..
Code:
local config = {
    [5908] = {
        -- Minotaurs
        [2830] = {value = 6750, newItem = 5878}, -- minotaur
        [2871] = {value = 5170, newItem = 5878}, -- archer
        [2866] = {value = 6670, newItem = 5878}, -- mage
        [2876] = {value = 7200, newItem = 5878}, -- guard
        [3090] = {value = 6750, newItem = 5878}, -- some minotar boss? (looks like normal minotaur)

        -- Low Class Lizards
        [4259] = {value = 3550, newItem = 5876}, -- sentinel
        [4262] = {value = 7040, newItem = 5876}, -- snake
        [4256] = {value = 4200, newItem = 5876}, -- templar

        -- High Class Lizards
        [11288] = {value = 25000, newItem = 5876, after = 11286}, -- chosen
        [11276] = {value = 9760, newItem = 5876, after = 11274}, -- legionare
        [11280] = {value = 7590, newItem = 5876, after = 11278}, -- priest
        [11272] = {value = 10000, newItem = 5876, after = 11270}, -- high class
        [11284] = {value = 20000, newItem = 5876, after = 11282}, -- zaogun

        -- Dragons
        [3104] = {value = 4640, newItem = 5877},
        [2844] = {value = 4640, newItem = 5877},

        -- Dragon Lords
        [2881] = {value = 3450, newItem = 5948},

        -- Behemoths
        [2931] = {value = 6000, newItem = 5893},

        -- Bone Beasts
        [3031] = {value = 5010, newItem = 5925},

        -- The Mutated Pumpkin
        [8961] = { { value = 5000, newItem = 7487 }, { value = 10000, newItem = 7737 }, { value = 20000, 6492 }, { value = 30000, newItem = 8860 }, { value = 45000, newItem = 2683 }, { value = 60000, newItem = 2096 }, { value = 90000, newItem = 9005, amount = 50 } },
    },
    [5942] = {
        -- Demon
        [2916] = {value = 25000, newItem = 5906},

        -- Vampires
        [2956] = {value = 4480, newItem = 5905}, -- vampire
        [9654] = {value = 5430, newItem = 5905, after = 9658}, -- bride
        [8938] = {value = 25000, newItem = 5905}, --lord
        [21275] = {value = 2040, newItem= 5905} -- viscount
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local skin = config[item.itemid][target.itemid]
    if target.itemid == 11343 then -- marble sclupting
        local rand = math.random(100000)
        target:getPosition():sendMagicEffect(tonumber(10))
        if rand <= 37571 then
            if rand <= 830 then
                target:transform(11344)
                target:setDescription("This shoddy work was made by ".. player:getName() ..".")
            elseif rand > 830 and rand <= 12501 then
                target:transform(11345)
                target:setDescription("This little figurine made by ".. player:getName() .." has some room for improvement..")
            else
                target:transform(11346)
                target:setDescription("This little figurine of Tibiasula was masterfully sculpted by ".. player:getName() ..".")
            end
        else
            player:say('The attempt at shaping that marble rock failed miserably.', TALKTYPE_MONSTER_SAY)
            target:remove()
        end
    end
   
    if isInArray({7441, 7442, 7444, 7445}, target.itemid) then -- ice cube
        local rand = math.random(100000)
        target:getPosition():sendMagicEffect(tonumber(10))   
        if target.itemid == 7445 and rand <= 40 then
            player:addAchievement('Ice Sculptor')
            target:transform(7446)
        elseif target.itemid == 7444 and rand <= 4800 then
            target:transform(7445)
        elseif target.itemid == 7442 and rand <= 22050 then
            target:transform(7444)
        elseif target.itemid == 7441 and rand <= 72220 then
            target:transform(7442)
        else
            target:remove()
            player:say('The attempt at sclupting failed miserably.', TALKTYPE_MONSTER_SAY)
        end
    end       
   
    -- Wrath of the emperor quest
    if item.itemid == 5908 and target.itemid == 12295 then
        target:transform(12287)
        player:say("You carve a solid bowl of the chunk of wood.", TALKTYPE_MONSTER_SAY)
    -- An Interest In Botany Quest
    elseif item.itemid == 5908 and target.itemid == 11691 and player:getItemCount(12655) > 0 and player:getStorageValue(Storage.TibiaTales.AnInterestInBotany) == 1 then
        player:say("The plant feels cold but dry and very soft. You streak the plant gently with your knife and put a fragment in the almanach.", TALKTYPE_MONSTER_SAY)
        player:setStorageValue(Storage.TibiaTales.AnInterestInBotany, 2)
    elseif item.itemid == 5908 and target.itemid == 11653 and player:getItemCount(12655) > 0 and player:getStorageValue(Storage.TibiaTales.AnInterestInBotany) == 2 then
        player:say("You cut a leaf from a branch and put it in the almanach. It smells strangely sweet and awfully bitter at the same time.", TALKTYPE_MONSTER_SAY)
        player:setStorageValue(Storage.TibiaTales.AnInterestInBotany, 3)
    end

    if not skin then
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return true
    end
   
    local random, effect, transform = math.random(1, 100000), CONST_ME_MAGIC_GREEN, true
    if type(skin[1]) == 'table' then
        local added = false
        for _, _skin in ipairs(skin) do
            if random <= _skin.value then
                player:addItem(_skin.newItem, _skin.amount or 1)
                added = true
            break
            end
        end

        if not added and target.itemid == 8961 then
            effect = CONST_ME_POFF
            transform = false
        end
    elseif random <= skin.value then
        player:addItem(skin.newItem, skin.amount or 1)
    else
        effect = CONST_ME_POFF
    end

    toPosition:sendMagicEffect(effect)
    if transform then
        target:transform(skin.after or target.itemid + 1)
    end

    return true
end
 
Thank you for the script!
But i get this error in the console:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/tools/obsidian.lua:onUse
data/actions/scripts/tools/obsidian.lua:74: attempt to call method 'getPosition' (a nil value)
stack traceback:
    [C]: in function 'getPosition'
    data/actions/scripts/tools/obsidian.lua:74: in function <data/actions/scripts/tools/obsidian.lua:50>

And if i just delete the effect, then this error shows up: :C
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/tools/obsidian.lua:onUse
data/actions/scripts/tools/obsidian.lua:85: attempt to call method 'remove' (a nil value)
stack traceback:
    [C]: in function 'remove'
 
Last edited:
Thank you for the script!
But i get this error in the console:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/tools/obsidian.lua:onUse
data/actions/scripts/tools/obsidian.lua:74: attempt to call method 'getPosition' (a nil value)
stack traceback:
    [C]: in function 'getPosition'
    data/actions/scripts/tools/obsidian.lua:74: in function <data/actions/scripts/tools/obsidian.lua:50>

And if i just delete the effect, then this error shows up: :C
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/tools/obsidian.lua:onUse
data/actions/scripts/tools/obsidian.lua:85: attempt to call method 'remove' (a nil value)
stack traceback:
    [C]: in function 'remove'
How old is your TFS?
I suggest you to upgrade to tfs 1.1 > more features. (if possible)
 
I had a problem with 10.41 that the time were going too fast. Corpses dissapeared fast, rings depleted faster. 1 min rl was like 3 min ingame.
So i think migrating to 10.41 isn't an option by now u.u

There is anyway to fix the script to make it work to TFS 1.0? :C

Thanks for the help.
 
There was time issue on tfs 1.1~ some weeks ago, it has been fixed.
I strongly suggest you to upgrade your tfs so more functions will work.
 
Okay, i think you are right.
Do you think it will exist problems of compatiblity when i migrate my server + DB?
I mean, i can just configure the DB in the config.lua and correctly add my custom data to the TFS 1.1 files, and the server should work fine in 10.41?
 
Okay, i think you are right.
Do you think it will exist problems of compatiblity when i migrate my server + DB?
I mean, i can just configure the DB in the config.lua and correctly add my custom data to the TFS 1.1 files, and the server should work fine in 10.41?
Yeah, it should work fine.
 
Back
Top