Inventory Item bug in 4.1

  • #1, by andiliddellSaturday, 18. October 2014, 16:00 6 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?

    Forum Fan

    178 Posts


  • #2, by andiliddellSaturday, 18. October 2014, 16:03 6 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?

    Forum Fan

    178 Posts

  • #3, by afrlmeSaturday, 18. October 2014, 16:16 6 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")
    1
    2
    3
    4
    5
    6
    7
    8

    ...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.

    Imperator

    6842 Posts

  • #4, by andiliddellSaturday, 18. October 2014, 21:04 6 years ago
    Worked an absolute charm!

    Thanks, as always excellent support

    Forum Fan

    178 Posts

  • #5, by afrlmeSaturday, 18. October 2014, 22:07 6 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")
    1
    2

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

    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
    1
    2
    3
    4
    5
    6
    7

    Imperator

    6842 Posts

  • #6, by andiliddellMonday, 20. October 2014, 12:19 6 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.

    Forum Fan

    178 Posts

  • #7, by afrlmeMonday, 20. October 2014, 12:28 6 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.

    Imperator

    6842 Posts

Write post