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

Lua [TFS 1.2] Sweetheart Ring Script Error

flaviiojr

Active Member
Joined
Jan 20, 2017
Messages
230
Solutions
13
Reaction score
39
I created a script for the sweetheart to work the same as the global one, but an error appears on the console...
[Warning - Event:: checkScript] Event onUse not found. scripts/sweetheart.lua
The player can only use if the ring is in the ring slot
can you help me? Thank you very much in advance!
TFS 1.2 Client 10.99

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local ringItem = player:getSlotItem(CONST_SLOT_RING)
if not ringItem or ringItem.itemid ~= 24324 then
return true
end

player:getposition():sendMagicEffect(CONST_ME_HEARTS)
return true
end
 
Solution
I find that hard to believe
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if item == ringItem then
        player:getPosition():sendMagicEffect(CONST_ME_HEARTS)
        return true
    else
        return false
    end
end
This is what your running right?
Just do this instead
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if item == ringItem then
        fromposition:sendMagicEffect(CONST_ME_HEARTS)
        return true
    else
        return false
    end
end
ok, do this instead
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if item == ringItem then
        player:getPosition():sendMagicEffect(CONST_ME_HEARTS)
        return true
    else
        return false
    end
end
Unless there is some other underlying problem, it should work
 
Last edited:
I tried this script and this error appears:
Lua Script Error: [Action Interface]
data/actions/scripts/sweetheart.lua:eek:nUse
data/actions/scripts/sweetheart.lua:4: attempt to call method 'getposition' (a nil value)
stack traceback:
[C]: in function 'getposition'
data/actions/scripts/sweetheart.lua:4: in function <data/actions/scripts/sweetheart.lua:1>

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if item == ringItem then
        local position = player:getPosition()
        position:sendMagicEffect(CONST_ME_HEARTS)
        return true
    else
        return false
    end
    end
 
That's because it should be
Lua:
getPosition()
not
Lua:
getposition()
Yeesh, thats what I get for copying other peoples code, fixed
 
I find that hard to believe
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if item == ringItem then
        player:getPosition():sendMagicEffect(CONST_ME_HEARTS)
        return true
    else
        return false
    end
end
This is what your running right?
Just do this instead
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ringItem = player:getSlotItem(CONST_SLOT_RING)
    if item == ringItem then
        fromposition:sendMagicEffect(CONST_ME_HEARTS)
        return true
    else
        return false
    end
end
 
Solution
Back
Top