License from €75 Log in
DE EN FR ES IT CZ

Inventory Item bug in 4.1

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 13 years ago
    This has only started happening since I upgraded to 4.1 full.

    I have "allow dragging" set for my interface items, and up until now if I wanted to use one inventory item with another, I would :


    • Click the first item, which would then become my cursor
    • Then click on the other item with this item, to trigger the use X with Y


    Now when I click the first item, it becomes my cursor but the inventory automatically closes, meaning I cannot click on the second item.

    Has anyone else noticed this change in the latest version? Is there a fix or workaround please?
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license.

    See licenses Try it for free
  3. · 13 years ago
    I am an idiot!

    Just remembered I'd changed one of the default mouse click actions to fix another Issue I had in play testing.

    When a player Leaves the inventory open, and starts to walk off to another place I'd changed the left click behaviour to close the inventory.

    Is there a simple way to close the inventory if the character walks to a new place?
  4. · 13 years ago
    maybe with an if query & loop in lua?
    function closeInventory()
     if game.GameCurrentCharacter.CharacterState == 3 and Interfaces["interface_name"].InterfaceVisible == true then
      Interfaces["interface_name"].InterfaceVisible = false
     end
    end
    
    registerEventHandler("mainLoop", "closeInventory")
    

    ...replace interface_name with actual interfaces name. it's case sensitive. This code is not verified & I'm using the new shorthand lua code, so I'm not sure if it is correct or not.

    I'm not sure how your interface works but this automatically hides interface if the interface is visible & character starts walking.
  5. · 13 years ago
    Worked an absolute charm!

    Thanks, as always excellent support
  6. · 13 years ago
    really... well that's good news then as it was just a guess. wink

    If you wanted to, you could only enable the loop whenever the interface is open by registering the event handler for the function on interface show & unregistering it on interface leave/hide.

    add after show action...
    registerEventHandler("mainLoop", "closeInventory")
    

    in the close/leave action or whatever you are using to close it manually...
    unregisterEventHandler("mainLoop", "closeInventory")
    

    updated block of code I gave you before in which it automatically unregisters loop on hide interface.
    function closeInventory()
     if game.GameCurrentCharacter.CharacterState == 3 and Interfaces["interface_name"].InterfaceVisible == true then
      Interfaces["interface_name"].InterfaceVisible = false
      unregisterEventHandler("mainLoop", "closeInventory")
     end
    end
    
  7. · 13 years ago
    You sir are a Legend.. I'll get this in tonight

    I'd always wondered if there was an unregister, I'm so used to AS3 addEventListener and removeEventListener which are very useful for limiting processing.

    I really need to get deeper into the LUA scripting, but am so close to completing act1 of my game I don't want to rock the boat so near to the finish line.
  8. · 13 years ago
    unregisterEventHandler was added to VS 4.0 beta or RC (I forget which). It's only valid for mainLoop handlers at the minute.

    No, I guess not. It's worth looking into when you are ready mind.

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?