Changing the image of the inventory item when it comes over a scene object?

  • #10, von sebastianDonnerstag, 20. August 2015, 21:06 Uhr vor 9 Jahren

    Thread König

    2346 Posts


  • #11, von AkcayKaraazmakDonnerstag, 20. August 2015, 21:21 Uhr vor 9 Jahren
    Hey mate, this is Simon's script. But it just for when you over the item in inventory and not the object in the scene. Hmm I'll try to look the script and maybe modify it smile .. Thank you so much bro!

    Simon's script;

    oldItem = nil
    function mainLoop()
    local curObj=game:getLink(VGameCurrentObject)
    if oldItem~=nil then
    oldItem:setValue(VAnimationFirstFrame,1)
    oldItem:setValue(VAnimationLastFrame,1)
    oldItem=nil
    end
    if curObj:getId().tableId==eObjects then
    if curObj:getBool(VObjectIsItem) then
    local act = getObject("ActiveAnimations["..curObj:getName().."]")
    act:setValue(VAnimationFirstFrame,2)
    act:setValue(VAnimationLastFrame,2)
    oldItem = act
    end
    end
    end
    function animStartedH(anim)
    local data = anim:getLink(VAnimationSavedObject)
    local curObj = data:getParent()
    if curObj:getId().tableId==eObjects then
    if curObj:getBool(VObjectIsItem) then
    anim:setValue(VAnimationFirstFrame,1)
    anim:setValue(VAnimationLastFrame,1)
    end
    end
    end
    registerEventHandler("animationStarted", "animStartedH")
    registerEventHandler("mainLoop","mainLoop")

    Experte

    440 Posts

  • #12, von sebastianDonnerstag, 20. August 2015, 21:40 Uhr vor 9 Jahren
    try Lee's script a few posts later... I didn't test it myself but it seems good

    Thread König

    2346 Posts

  • #13, von AkcayKaraazmakDonnerstag, 20. August 2015, 21:44 Uhr vor 9 Jahren
    Allright bro

    Experte

    440 Posts

  • #14, von sebastianDonnerstag, 20. August 2015, 21:48 Uhr vor 9 Jahren
    also you can remove the
    if curObj:getBool(VObjectIsItem) then
    

    condition check from the first. so it will trigger also on scene objects.
    VObjectIsItem = ITEM
    VObjectIsItem = SCENE OBJECT
    But i dont know if then also stuff like buttons trigger it...

    Thread König

    2346 Posts

  • #15, von AkcayKaraazmakDonnerstag, 20. August 2015, 21:54 Uhr vor 9 Jahren
    Hmm great, I'll try and write you. Thank you so much mate!!!

    Experte

    440 Posts

  • #16, von sebastianDonnerstag, 20. August 2015, 21:58 Uhr vor 9 Jahren
    i tried to implement this, too but cant get anything working like it should:
    SCRIPT 1 from Simon just works on the Item i dragged
    SCRIPT 2 doesnt work anyway
    --
    Ah, i see now, that the Topic i linked is just for changing the appearance when hovering the item itself. I thought it changes when you drag it over a scene object like wanted... Hmm i think we have to modify the script a bit...

    Thread König

    2346 Posts

  • #17, von sebastianDonnerstag, 20. August 2015, 23:53 Uhr vor 9 Jahren
    so i made this (based on scripts from Lee and Simon):
    oldItem = nil
    
    function onItemDrag(eventType)
    
      local curObj=game:getLink(VGameCurrentObject)
      local draggedItem=game:getLink(VGameUsedItem)
    
      if oldItem~=nil then
        oldItem:setValue(VAnimationFirstFrame,1)
        oldItem:setValue(VAnimationLastFrame,1)
        oldItem=nil
      end
    
      if eventType == eEvtMouseMove and (curObj:getId().tableId == eObjects or curObj:getId().tableId == eCharacters ) then
        local act = getObject("ActiveAnimations["..draggedItem:getName().."]")
        act:setValue(VAnimationFirstFrame,2)
        act:setValue(VAnimationLastFrame,2)
        oldItem = act
      end
    end
    
    registerEventHandler("mouseEvent", "onItemDrag", {eEvtMouseMove})
    


    Also add on first frame of an item as execute script action part:
    getObject("ActiveAnimations[Speer]"):setValue(VAnimationLastFrame, 1)
    


    2 Problems so far:
    1.: hovering the item itself in the inventory also changes the image of the item (of course). This looks a bit stupid.
    2.: The script seems to fail after dropping an the item successfully on an opject or item.
    Any ideas how to solve this?

    Thread König

    2346 Posts

  • #18, von AkcayKaraazmakFreitag, 21. August 2015, 11:26 Uhr vor 9 Jahren
    Hey developers help us pleaeseeeee smile

    Experte

    440 Posts

  • #19, von sebastianFreitag, 21. August 2015, 20:17 Uhr vor 9 Jahren
    script seems to break after the second time using an item on an object

    Thread König

    2346 Posts

  • #20, von AkcayKaraazmakFreitag, 21. August 2015, 20:42 Uhr vor 9 Jahren
    I wrote to Simon, hope he will sort it out.

    Experte

    440 Posts