Lua [TFS 1.2] Sweetheart Ring Script Error

Discussion in 'Support' started by flaviiojr, Apr 20, 2017.

Tags:
  1. flaviiojr

    flaviiojr Member

    Joined:
    Jan 20, 2017
    Messages:
    76
    Likes Received:
    3
    Best Answers:
    0
    I created a script for the sweetheart to work the same as the global one, but an error appears on the console...
    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

    Code (Lua):
    1. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    2. local ringItem = player:getSlotItem(CONST_SLOT_RING)
    3. if not ringItem or ringItem.itemid ~= 24324 then
    4. return true
    5. end
    6.  
    7. player:getposition():sendMagicEffect(CONST_ME_HEARTS)
    8. return true
    9. end
     
  2. Aled

    Aled Active Member (probably)

    Joined:
    Mar 30, 2017
    Messages:
    214
    Likes Received:
    126
    Best Answers:
    15
    How EXACTLY is it supposed to work? what does your actions.xml look like?
     
  3. flaviiojr

    flaviiojr Member

    Joined:
    Jan 20, 2017
    Messages:
    76
    Likes Received:
    3
    Best Answers:
    0
    When the ring is equipped, the player will use and will leave heart effects
    But the player can only use the ring if he is equipped...
     
  4. Aled

    Aled Active Member (probably)

    Joined:
    Mar 30, 2017
    Messages:
    214
    Likes Received:
    126
    Best Answers:
    15
    I don't understand what the problem is
     
  5. flaviiojr

    flaviiojr Member

    Joined:
    Jan 20, 2017
    Messages:
    76
    Likes Received:
    3
    Best Answers:
    0
    This error is appearing, and when you use the ring, the hearts do not appear
     
  6. Aled

    Aled Active Member (probably)

    Joined:
    Mar 30, 2017
    Messages:
    214
    Likes Received:
    126
    Best Answers:
    15
    what does your actions.xml look like
     
  7. flaviiojr

    flaviiojr Member

    Joined:
    Jan 20, 2017
    Messages:
    76
    Likes Received:
    3
    Best Answers:
    0
    Code (Text):
    1. <action itemid="24324" script="sweetheart.lua"/>
     
  8. Aled

    Aled Active Member (probably)

    Joined:
    Mar 30, 2017
    Messages:
    214
    Likes Received:
    126
    Best Answers:
    15
    ok, do this instead
    Code (Lua):
    1. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    2.     local ringItem = player:getSlotItem(CONST_SLOT_RING)
    3.     if item == ringItem then
    4.         player:getPosition():sendMagicEffect(CONST_ME_HEARTS)
    5.         return true
    6.     else
    7.         return false
    8.     end
    9. end
    Unless there is some other underlying problem, it should work
     
    Last edited: Apr 20, 2017
  9. flaviiojr

    flaviiojr Member

    Joined:
    Jan 20, 2017
    Messages:
    76
    Likes Received:
    3
    Best Answers:
    0
    I tried this script and this error appears:
    Code (Lua):
    1. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    2.     local ringItem = player:getSlotItem(CONST_SLOT_RING)
    3.     if item == ringItem then
    4.         local position = player:getPosition()
    5.         position:sendMagicEffect(CONST_ME_HEARTS)
    6.         return true
    7.     else
    8.         return false
    9.     end
    10.     end
     
  10. Aled

    Aled Active Member (probably)

    Joined:
    Mar 30, 2017
    Messages:
    214
    Likes Received:
    126
    Best Answers:
    15
    That's because it should be
    Code (Lua):
    1. getPosition()
    not
    Code (Lua):
    1. getposition()
    Yeesh, thats what I get for copying other peoples code, fixed
     
  11. flaviiojr

    flaviiojr Member

    Joined:
    Jan 20, 2017
    Messages:
    76
    Likes Received:
    3
    Best Answers:
    0
  12. Aled

    Aled Active Member (probably)

    Joined:
    Mar 30, 2017
    Messages:
    214
    Likes Received:
    126
    Best Answers:
    15
    I find that hard to believe
    Code (Lua):
    1. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    2.     local ringItem = player:getSlotItem(CONST_SLOT_RING)
    3.     if item == ringItem then
    4.         player:getPosition():sendMagicEffect(CONST_ME_HEARTS)
    5.         return true
    6.     else
    7.         return false
    8.     end
    9. end
    This is what your running right?
    Just do this instead
    Code (Lua):
    1. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    2.     local ringItem = player:getSlotItem(CONST_SLOT_RING)
    3.     if item == ringItem then
    4.         fromposition:sendMagicEffect(CONST_ME_HEARTS)
    5.         return true
    6.     else
    7.         return false
    8.     end
    9. end
     
    Saints Anathema likes this.
  13. Saints Anathema

    Saints Anathema Old School Doleran

    Joined:
    Feb 24, 2009
    Messages:
    654
    Likes Received:
    7
    Best Answers:
    0
    @Aled, your script is confirmed working on tfs 1.2 10.98

    nice work
     

Share This Page

Loading...