TFS 1.X+ Cant Use Potion on hotkey.

Mister Budex

BudexOT.com
Joined
Jun 22, 2016
Messages
1,148
Reaction score
201
Any Errors in console?
That should be in actions folder liquids file probably
 
OP
Sp0tl3ss

Sp0tl3ss

Nestalia.org
Joined
Jul 19, 2014
Messages
275
Reaction score
12
Lua:
local drunk = Condition(CONDITION_DRUNK)
drunk:setParameter(CONDITION_PARAM_TICKS, 60000)

local poison = Condition(CONDITION_POISON)
poison:setParameter(CONDITION_PARAM_DELAYED, true)
poison:setParameter(CONDITION_PARAM_MINVALUE, -50)
poison:setParameter(CONDITION_PARAM_MAXVALUE, -120)
poison:setParameter(CONDITION_PARAM_STARTVALUE, -5)
poison:setParameter(CONDITION_PARAM_TICKINTERVAL, 4000)
poison:setParameter(CONDITION_PARAM_FORCEUPDATE, true)

local fluidMessage = {
    [3] = "Aah...",
    [4] = "Urgh!",
    [5] = "Mmmh.",
    [7] = "Aaaah...",
    [10] = "Aaaah...",
    [11] = "Urgh!",
    [13] = "Urgh!",
    [15] = "Aah...",
    [19] = "Urgh!"
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local targetType = ItemType(target.itemid)
    if targetType:isFluidContainer() then
        if target.type == 0 and item.type ~= 0 then
            target:transform(target.itemid, item.type)
            item:transform(item.itemid, 0)
            return true
        elseif target.type ~= 0 and item.type == 0 then
            target:transform(target.itemid, 0)
            item:transform(item.itemid, target.type)
            return true
        end
    end

    if target.itemid == 1 then
        if item.type == 0 then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, 'It is empty.')

        elseif target.uid == player.uid then
            if isInArray({3, 15}, item.type) then
                player:addCondition(drunk)

            elseif item.type == 4 then
                player:addCondition(poison)

            elseif item.type == 7 then
                player:addMana(math.random(50, 150))
                fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)

            elseif item.type == 10 then
                player:addHealth(math.random(50, 70))
                fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
            end

            player:say(fluidMessage[item.type] or "Gulp.", TALKTYPE_MONSTER_SAY)
            item:transform(item.itemid, 0)
        else
            local pool = Game.createItem(2016, item.type, toPosition)
            if pool then
                pool:decay()
            end
            item:transform(item.itemid, 0)
        end

    else
        local fluidSource = targetType:getFluidSource()
        if fluidSource ~= 0 then
            item:transform(item.itemid, fluidSource)

        elseif item.type == 0 then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "It is empty.")

        else
            if toPosition.x == CONTAINER_POSITION then
                toPosition = player:getPosition()
            end

            local pool = Game.createItem(2016, item.type, toPosition)
            if pool then
                pool:decay()
            end
        end
        item:transform(item.itemid, 0)
    end

    return true
end
Any Errors in console?
That should be in actions folder liquids file probably
nope no errors at all.... i have no clue ive checked the scripts and they are identical exept the ids... i can post the scripts but i dont think they are the problem
 
Last edited:
OP
Sp0tl3ss

Sp0tl3ss

Nestalia.org
Joined
Jul 19, 2014
Messages
275
Reaction score
12
Bump, May it be in the source codes?
 

xKrazyx

Old School
Joined
Oct 23, 2012
Messages
786
Reaction score
436
check in config.lua if your able to use hotkeys?

is it giving you any message when you try and use with hotkey?

with just a quick glance hard to say anything looks wrong with your code..

Just some ideas.. might be how hotkey returns target when used on self?
maybe this line? elseif target.uid == player.uid then I doubt it tho

No clue m8.

What you can do is start adding print("") statements in key places to see how your code is running on execution, otherwise run it line by line.

so for instance if you want to see that the script is just running when you use with hotkey because you dont know yet or dont know whats happening.. put print("its working") directly under
function onUse(player, item, fromPosition, target, toPosition, isHotkey)..
if it prints then you know that the script is being called on hotkey..

From there move your prints around and see whatsup.. :) This technique will help you learn to debug fast, use it often.
(When I first write scripts, I always write print statements, and then --comment them out afterwards.. makes testing/debugin way faster and easier in my experience)

Best of luck.
 
Last edited:
Top