Opening menu clears dragged item

  • #1, by EvrenFriday, 02. May 2014, 14:47 10 years ago
    I don't know if it would be considered a real bug, but when you open a menu then swtich back to the scene dragged item gets lost. I tried to get the dragged item to a variable (in definition script) and put it back when going back to the scene but realized GameUsedItem is not scriptable. You can use an action part Set Item, so it seems a bit weird not being able to use it in script. (Action part won't do any good because when using the action part you have to know the item, but in this case dragged item can be anything.) The player can pick the item from the inventory again but what if it's an item that doesn't exist in inventory, and given by the game (imaginary scenario). Thinking of it, it can also be a timed event scenario. Maybe the player wanted to puase the game but when he returns back now he needs to do the actions all over again. Just wanted to let you know. smile

    Newbie

    19 Posts


  • #2, by SimonSFriday, 02. May 2014, 14:54 10 years ago
    It's scriptable with Vis 4.0.
    game:setValue(VGameUsedItem,getObject("(-1,-1)"))
    game:setValue(VGameUsedItemPicked,true)
    

    Order matters here.

    Thread Captain

    1580 Posts

  • #3, by EvrenFriday, 02. May 2014, 15:32 10 years ago
    I am using Vis 4.0, I created a definition script with a global variable "ItemBeingDragged", and saved the object to that variable. When returning to scene I used this line:

    game:setValue(VGameUsedItem, ItemBeingDragged)

    this didn't work. roll

    http://wiki.visionaire-tracker.net/wiki/Data_Structure, I didn't see VGameUsedItemPicked here roll and getObject("(-1,-1)") is new to me, what does it do?

    Newbie

    19 Posts

  • #4, by AlexFriday, 02. May 2014, 15:57 10 years ago
    getObject('(-1,-1)') returns an empty object, it uses a tuple to specifiy the object (table-id, object-id) - in this case a non-existing object.
    But for better readability I'd recommend to use emptyObject instead.

    Great Poster

    378 Posts

  • #5, by EvrenFriday, 02. May 2014, 17:24 10 years ago
    I can't give the item back to cursor. It's not working. I had some mistakes I corrected them but now the action text has the item's name but there is no item icon and when I click on another object it doesn't drop it, just walks to the object. Then the action text is cleared.

    Is there such a thing as GameUsedItemPicked ? I tried it, didn't work.

    Then the scripts started to change between execution and definition. I guess it's time for a rest again before going crazy.

    @Alex
    Thank you for that.

    Newbie

    19 Posts

  • #6, by AlexFriday, 02. May 2014, 18:49 10 years ago

    Then the scripts started to change between execution and definition. I guess it's time for a rest again before going crazy.


    that's a known bug which will be fixed with the next update. The problem is in the underlying gui lib, when the first tab is selected and you change the script, the selected script gets the same radio button setting as the previously selected.

    Great Poster

    378 Posts

  • #7, by EvrenFriday, 02. May 2014, 19:28 10 years ago
    It's scriptable with Vis 4.0.
    game:setValue(VGameUsedItem,getObject("(-1,-1)"))
    game:setValue(VGameUsedItemPicked,true)
    

    Order matters here.


    I can't get it to work, is it in a newer build?

    Newbie

    19 Posts

  • #8, by afrlmeFriday, 02. May 2014, 19:58 10 years ago
    It's incorrect. It's actually...
    game:setValue(VGameDestinationItemPicked, true)
    

    the the gameuseditem part looks correct though. although technically I could store the current item like so...
    if not game:getLink(VGameUsedItem):isEmpty() then
     var = game:getLink(VGameUsedItem) else var = nil
    end
    

    then I could return it like so...
    if var ~= nil then
     game:setValue(VGameUsedItem, var)
     game:setValue(VGameDestinationItemPicked, true)
    end
    

    something along the lines of this.

    Imperator

    7278 Posts

  • #9, by SimonSFriday, 02. May 2014, 20:07 10 years ago
    Here, try my inventory scroll script:
    -- author: SimonS
    -- Inventory scrolling by mouse wheel
    registerEventHandler("mouseEvent", "mouseEvtHandler") 
    
    function mouseEvtHandler(evt)
    	   if evt == eEvtMouseWheelUp then
    			wheelUp()
    	   end
    	   if evt == eEvtMouseWheelDown then
    			wheelDown()
    	   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,getObject("(-1,-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,getObject("(-1,-1)"))
              else
                game:setValue(VGameUsedItem,items[i-1])
              end
              break
            end  
          end
        end
      end
      game:setValue(VGameUsedItemPicked,true)
    end
    

    Thread Captain

    1580 Posts

  • #10, by afrlmeFriday, 02. May 2014, 22:11 10 years ago
    I also wrote a script a few months ago that allowed you to cycle/scroll through the inventory items. razz http://wiki.visionaire-tracker.net/wiki/Cycle_Inventory_Item... - I've not gone over your script but I think it's scrolling through currently selected item? Mine scrolls the inventory itself.

    Imperator

    7278 Posts

  • #11, 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

    1580 Posts