function onItemDrag(eventType)
-- set object under cursor and item which is (maybe) dragged
local curObj=game:getLink(VGameCurrentObject)
if not game.UsedItem:isEmpty() then
-- if an item gets dragged, get its animation
local anim = getObject("ActiveAnimations["..game:getLink(VGameUsedItem):getName().."]")
-- if mouse moves over an object or NPC character
if eventType == eEvtMouseMove and (curObj:getId().tableId == eObjects or curObj:getId().tableId == eCharacters ) then
-- set animation to second frame
anim:setValue(VAnimationFirstFrame,2)
anim:setValue(VAnimationLastFrame,2)
else
-- else set animation to first frame to reset it
anim:setValue(VAnimationFirstFrame,1)
anim:setValue(VAnimationLastFrame,1)
end
-- if an item gets dragged and a a CLICK action was used, the animation of the item should also be resetted (scrolling flags was removed from the eventhandler register)
if eventType ~= eEvtMouseMove and anim ~= nil then
anim:setValue(VAnimationFirstFrame,1)
anim:setValue(VAnimationLastFrame,1)
return true
end
end
end
registerEventHandler("mouseEvent", "onItemDrag", {eEvtMouseMove, eEvtMouseLeftButtonDoubleClick, eEvtMouseLeftButtonDown, eEvtMouseLeftButtonUp, eEvtMouseLeftButtonHold, eEvtMouseLeftButtonHolding, eEvtMouseRightButtonDoubleClick, eEvtMouseRightButtonDown, eEvtMouseRightButtonUp, eEvtMouseMiddleButtonDown, eEvtMouseMiddleButtonUp})