Opening menu clears dragged item

  • #10, by SimonSFriday, 02. May 2014, 23:57 10 years ago
    No, you can scroll through your items here with the wheel, so it is directly dragged. The fastest inventory I can imagine, as seen in Memoria and Chains of Satinavs.

    Thread Captain

    1581 Posts


  • #11, by afrlmeSaturday, 03. May 2014, 01:43 10 years ago
    I didn't play chains of satinav with a normal mouse. I used my laptops touchpad which doesn't have a mouse wheel unlike my last laptop.

    I'll have a go with your script later on & see if I can improve on it (less lines of code) & if not I'll add it to the script index of the wiki, as is. wink

    Imperator

    7278 Posts

  • #12, by stered86Tuesday, 28. November 2017, 12:46 6 years ago
    Hi, guys, sorry if I'm upping up this old topic but I'd need a little help with SimonS' code.

    Everything works as I wanted it, except for one detail: I don't want the scrolling to happen unless the player has got an item selected. Judging by the look of it, it shouldn't be hard to do, but then again I really can't understand lua...

    Newbie

    62 Posts

  • #13, by MachtnixTuesday, 28. November 2017, 15:22 6 years ago
    I am a Lua dummie too, but I would insert an if-clause into function mouseEvtHandler(evt) like this: if item dropped then start scolling.

    Sorry, but using Android it's a mess to mark text parts...

    Thread Captain

    1097 Posts

  • #14, by esmeraldaTuesday, 28. November 2017, 17:51 6 years ago
    I didn't know, this script was floating around in the forum. This is great, thank you SimonS! I used this function quit a lot while playing Chains of Satinav and Memoria.
    And thank you stered86 for bringing up this old topic - sadly I can't help with your actual question.

    Key Killer

    513 Posts

  • #15, by stered86Sunday, 03. December 2017, 11:54 6 years ago
    Hi!
    I made two changes to the original code by Simon:

    1- The scrolling only happens when the player has an item selected (dragged);
    2- The scrolling is now endless. When the player reaches the first item in the inventory, Visionaire will automatically select the last item; When the player reaches the last item in the inventory, Visionaire will automatically select the first one. Obviously the player can exit the endless cycle with the mouse right click.

    I would post the edited code but I don't know if I can! I'm waiting for Simon's permission to do so!

    Newbie

    62 Posts

  • #16, by afrlmeSunday, 03. December 2017, 13:17 6 years ago
    Hi!
    I made two changes to the original code by Simon:

    1- The scrolling only happens when the player has an item selected (dragged);
    2- The scrolling is now endless. When the player reaches the first item in the inventory, Visionaire will automatically select the last item; When the player reaches the last item in the inventory, Visionaire will automatically select the first one. Obviously the player can exit the endless cycle with the mouse right click.

    I would post the edited code but I don't know if I can! I'm waiting for Simon's permission to do so!
    If he didn't include a note in the script or a message in his post about not being able to modify his code then you can share your edited version.

    Did you check out my inventory scrolling script on the script index of the wiki? If I remember correctly it featured endless scrolling. Not the first thing you mentioned though.

    Imperator

    7278 Posts

  • #17, by stered86Friday, 16. February 2018, 15:26 6 years ago
    Thanks for your code, AFRLme, but as for now Simon's code seems alright for me. In the last weeks I've tested the edited code and I think it really works as it should, so I'll share it with you. If you use it and you happen to have problems, it is my fault and not Simon's.

    -- author: SimonS
    
    -- Inventory scrolling by mouse wheel
    
    registerEventHandler("mouseEvent", "mouseEvtHandler") 
    
    
    
    function mouseEvtHandler(evt)
    
        if evt == eEvtMouseWheelUp then
    
    if not game.UsedItem:isEmpty() then
    
       wheelUp()
    
    end
    
        end
    
        if evt == eEvtMouseWheelDown then
    
    if not game.UsedItem:isEmpty() then
    
       wheelDown()
    
        end
    
    end
    
    end
    
    
    
    function wheelUp ()
    
      local items = game:getLink(VGameCurrentCharacter):getLinks(VCharacterItems)
    
      local len = table.getn (items)
    
      local usedItem = game:getLink(VGameUsedItem)
    
    
    
      if len == 0 then
    
          game:setValue(VGameUsedItem,getObject("(-1,-1)"))
    
      else
    
          if usedItem:isEmpty() then
    
            game:setValue(VGameUsedItem,items[1])
    
          else
    
            for index = 0, len-1, 1 do
    
              if items[len-index]:getName() == usedItem:getName() then
    
                if len-index == len then
    
                   game:setValue(VGameUsedItem,items[1])
    
                else
    
                  game:setValue(VGameUsedItem,items[len-index+1])
    
                end
    
                break
    
              end 
    
            end
    
          end
    
      end
    
      game:setValue(VGameUsedItemPicked,true)
    
    end
    
    
    
    
    
    function wheelDown ()
    
      local character = getObject("Game.GameCurrentCharacter")
    
      local items = character:getLinks(VCharacterItems)
    
      local len = table.getn (items)
    
      local usedItem = game:getLink(VGameUsedItem)
    
    
    
      if len == 0 then
    
          game:setValue(VGameUsedItem,empty)
    
      else
    
        if usedItem:isEmpty() then
    
          game:setValue(VGameUsedItem,items[len])
    
        else
    
          for i = 1, len, 1 do
    
            if items[i]:getName() == usedItem:getName() then
    
              if i == 1 then
    
                game:setValue(VGameUsedItem,items[len])
    
              else
    
                game:setValue(VGameUsedItem,items[i-1])
    
              end
    
              break
    
            end 
    
          end
    
        end
    
      end
    
      game:setValue(VGameUsedItemPicked,true)
    
    end

    Now I only have a problem left. When I use an item on an object, the dragged item is automatically cleared. I'd like the used item to remain dragged, so that the player can try and use it over other scene objects without having to access the inventory again. This is lua work and, let me tell you, I usually end when lua begins. Any suggestions?

    Newbie

    62 Posts