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

  • #10, by sebastianThursday, 20. August 2015, 21:06 6 years ago

    Thread Captain

    2346 Posts


  • #11, by AkcayKaraazmakThursday, 20. August 2015, 21:21 6 years ago
    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")

    Great Poster

    440 Posts

  • #12, by sebastianThursday, 20. August 2015, 21:40 6 years ago
    try Lee's script a few posts later... I didn't test it myself but it seems good

    Thread Captain

    2346 Posts

  • #13, by AkcayKaraazmakThursday, 20. August 2015, 21:44 6 years ago
    Allright bro

    Great Poster

    440 Posts

  • #14, by sebastianThursday, 20. August 2015, 21:48 6 years ago
    also you can remove the
    if curObj:getBool(VObjectIsItem) then
    1
    2

    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 Captain

    2346 Posts

  • #15, by AkcayKaraazmakThursday, 20. August 2015, 21:54 6 years ago
    Hmm great, I'll try and write you. Thank you so much mate!!!

    Great Poster

    440 Posts

  • #16, by sebastianThursday, 20. August 2015, 21:58 6 years ago
    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 Captain

    2346 Posts

  • #17, by sebastianThursday, 20. August 2015, 23:53 6 years ago
    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})
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23


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


    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 Captain

    2346 Posts

  • #18, by AkcayKaraazmakFriday, 21. August 2015, 11:26 6 years ago
    Hey developers help us pleaeseeeee smile

    Great Poster

    440 Posts

  • #19, by sebastianFriday, 21. August 2015, 20:17 6 years ago
    script seems to break after the second time using an item on an object

    Thread Captain

    2346 Posts

  • #20, by AkcayKaraazmakFriday, 21. August 2015, 20:42 6 years ago
    I wrote to Simon, hope he will sort it out.

    Great Poster

    440 Posts