Licence dès 75 €
DE EN FR ES IT CZ

Inventory Item bug in 4.1

Ce sujet date de quelques années. Certains détails peuvent concerner une ancienne version de Visionaire Studio. Tutoriels actuels

  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. Vous travaillez sur un jeu ?

    La version gratuite permet jusqu’à 25 scènes par projet. Pour plus de scènes et pour vendre votre jeu, il vous faut une licence. Les lecteurs du forum obtiennent l’Indie Bundle à 15 % de réduction avec le code FORUM15 : 84,15 € au lieu de 99 €, valable jusqu’au 31/12/2026.

    Profiter de 15 % de réduction Essayer gratuitement
  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.

Ce sujet est fermé, car personne n’a répondu depuis plus d’un an. N’hésitez pas à poser votre question dans un nouveau sujet.

Nouveau sujet

Supprimer vraiment ce message ?