How To Hide Inventory During Display Text

  • #1, by ice7Tuesday, 05. June 2018, 05:58 6 years ago
    Hello, I have an inquiry.

    I would like to hide the inventory whenever there is display text.

    Is there a simple way to accomplish this ?  

    Thank you for your time.

    Newbie

    14 Posts


  • #2, by afrlmeTuesday, 05. June 2018, 11:22 6 years ago
    It should automatically hide providing you haven't set the inventory interface to be displayed permanently via its properties.

    P.S: could you please edit & delete the multiple duplicate threads you have created please? Cheers.

    Imperator

    7278 Posts

  • #3, by sebastianTuesday, 05. June 2018, 11:52 6 years ago
    @afrlme the inventory doesnt get hidden when showing a display text...

    Probably you need to hide and reshow the interface  manually. 
    Or use lua to hook into a textStarted/textStopped event and temporary hide hide/show it globally

    Thread Captain

    2346 Posts

  • #4, by afrlmeTuesday, 05. June 2018, 14:56 6 years ago
    No? Oh yeah, sorry. Forgot. grin

    Just use the Lua event handlers for textStarted & textStopped.

    Create a script in the script section of the editor & add this to it... (replace "inventory" with whatever you have named your inventory interface)

    function txtStart(text)
     if text.Owner:getId().tableId == eCharacters or text.Owner == nil then
      Interfaces["inventory"].Visible = false
     end
    end
    
    function txtEnd(text)
     Interfaces["inventory"].Visible = true
    end
    
    registerEventHandler("textStarted", "txtStart")
    registerEventHandler("textStopped", "txtEnd")

    Imperator

    7278 Posts

  • #5, by ice7Friday, 08. June 2018, 01:38 6 years ago
    Hello, thank you for replying to this thread.

     
    I have added the script, and replaced the "inventory" with what I named the interface, however the script is not working

    In editor there is a big red line under the second last line of code:
    registerEventHandler("textStarted" "txtStart")

    Thank you again.

    Newbie

    14 Posts

  • #6, by afrlmeFriday, 08. June 2018, 02:03 6 years ago
    Yeah sorry, seems I missed the comma between the 2 different values. I've updated the code block.

    Imperator

    7278 Posts

  • #7, by ice7Friday, 08. June 2018, 05:01 6 years ago
    Thank you for that.

    One last small bug with the code.

    After every display text, the inventory pops open. Even when it was closed to begin with.

    Kind Regards

    Newbie

    14 Posts

  • #8, by afrlmeFriday, 08. June 2018, 05:54 6 years ago
    So you just want it to hide only? If that's the case then...

    function txtStart(text)
     if text.Owner:getId().tableId == eCharacters or text.Owner == nil then
      Interfaces["inventory"].Visible = false
     end
    end
    
    registerEventHandler("textStarted", "txtStart")

    I have no idea what your inventory looks like or how you've rigged it up. Anyway, you're going to have to use Lua to show & hide it as needed.

    Use an execute a script action part & with this line of code whenever you want to show the interface... replace "inventory" with the actual name of the inventory interface.

    Interfaces["inventory"].Visible = true

    & same again when you want to hide it, but true should be false instead.

    Imperator

    7278 Posts

  • #9, by ice7Friday, 08. June 2018, 05:57 6 years ago
    Hi, that worked perfectly. Thank you for your help.

    Newbie

    14 Posts

  • #10, by afrlmeFriday, 08. June 2018, 05:59 6 years ago
    Just edited my last post with additional information.

    Imperator

    7278 Posts

  • #11, by ice7Friday, 08. June 2018, 08:14 6 years ago
    Hello, Thanks for the update.

    I will use that new code, whenever adding a new item to the inventory.

    Kind Regards

    Newbie

    14 Posts