HELP inventory failure...

  • #1, by nebirviFriday, 25. May 2018, 12:10 7 years ago
    So I've been avoiding this problem for some time but the game can't work without it so it is time to ask this probably simple question... HOW do I make a functional inventory?

    I watched this video https://www.youtube.com/watch?v=PQEsdmX_72Y but got kind of dissapointed since it didn't explain it all and left me haning some time ago... at the moment I've done exacly what the video says and I am now left with an inventory in the right place looking right but doesn't function.

    I would like the inventory to slide up when I bring the mouse to the bottom of the screen for starters becauce now it is there all the time (even though I have not checked that box) and all interaction at the same level as the inventory on the screen are covered by the inventory and can't be clicked. Any help on where I can find an english thread describing it already or new comments are welcome! Also looking for how to pick up things and add it to the inventory but first things first perhaps...

    // N

    Newbie

    30 Posts


  • #2, by afrlmeFriday, 25. May 2018, 12:28 7 years ago
    Can you post some screenshots of your inventory & how you have set it up please so I can get a better idea of what you have done so far?

    Imperator

    7285 Posts

  • #3, by nebirviFriday, 25. May 2018, 12:33 7 years ago
    Ofcourse! Here is how it looks atm.
    Oh and it is linked to the character just like the mouse. (as it says in the video)

    Newbie

    30 Posts

  • #4, by afrlmeFriday, 25. May 2018, 13:20 7 years ago
    It's been a while since I watched Redspark's video, so I'm not sure what he covered. Anyway, for sliding interfaces you need to use Lua script. It's only a few lines so it's nothing complicated.

    First things first, you should make sure you have defined the interface area.


    Now, inside of the properties tab you need to do 2 things...

    1. in the displacement set absolute & now in the offset you should leave x as whatever it currently is & in y you should offset it so that it pushes the interface below the scene.


    in my case I'm pushing the interface above the scene because my interface slides in from the top.

    2. click on the lightning bolt icon for action on leaving to open up a new window so that you can create an event to happen when the mouse cursor leaves the action area. Inside of this window create an execute a script action part & insert this code into it...
    Interfaces["inventory"]:to(1000, {InterfaceOffset = { x = 0, y = 1080 } }, easeQuintInOut)

    Don't forget to change the y value in the script to whatever you set in the y offset position in the properties tab.

    Next you need a method for sliding in the interface, I'm going to suggest a Lua mouse event handler, though maybe you would prefer to create another interface so that you can add a button that the player can mouse over. Anyway, for the mouse event handler method you will need to go to the script section of the editor & create a new script (make sure you set it as a definition type script in the properties section). Now insert this code into it...
    function onMouseEvent(typ, pos)
        if pos >= (game.WindowResolution.y - 10) then
            if Interfaces["inventory"].Visible and Interfaces["inventory"].InterfaceOffset.y == 1080 then
                Interfaces["inventory"]:to(1000, {InterfaceOffset = { x = 0, y = 350 } }, easeQuintInOut)
            end
        end
    end
    
    registerEventHandler("mouseEvent", "onMouseEvent")

    It should force the interface to slide out when the mouse cursor is 10 pixels or less from bottom of the screen providing the interface is visible & not already slid out.

    Alternatively again, you could create a button on screen or use a keyboard shortcut to toggle the inventory open/closed, or you could use the mouse wheel - but not everyone has a mouse wheel, so that has to be taken into consideration.

    Imperator

    7285 Posts

  • #5, by esmeraldaFriday, 25. May 2018, 14:01 7 years ago
    My way of a sliding interface is slightly differnt.

    I use a "sliding-area": i create a button in the inventory, define it as action area and set the borders of the area so that they are visible in the screen when the inventory is hidden. In my case the upper part of the inventory. (in your case the white transparent part visible in the screenshot, I guess)
    then I create an action - when the mouse enters the area I call a script that lets the inventory slide up or down, depending on the current positon. (I called it Slide_Interface, see images)

    My game resolution is 1280 x 720. So the hidden position of the intventory is y=700 , 20 px are visible in the screen. At a position of y=620 the inventory is fully visible.

    I hope the images make it a bit more understandable.



    Key Killer

    533 Posts

  • #6, by afrlmeFriday, 25. May 2018, 14:16 7 years ago
    I actually use a similar method myself. I'm not really that keen on having the interface slide out when the player moves the mouse cursor to the edge of the screen as they might slide the interface out by accident.

    As for the mouse over, it depends on the interface design. If it's designed in a way that makes sense for the interface to stick out a bit, even when it's slid in then it makes it easier as you can just create a button on the interface which you can draw an interaction polygon for around the edge of the interface & then create a on mouse over action part for which checks if the interface is in or out then slides it out or does nothing if it's already out or currently sliding out.

    The method I wrote in my last post was more to do with fully hidden inventory interfaces. Esmeralda's solution is certainly the simplest approach, but take note that neither of our methods allow you to hide the interface mid-slide because we are only checking if the interface is fully in or fully out. A more dynamic interface that can be interrupted mid-slide requires using a bit of math to calculate how long the transition should take for it to slide from the current position to make sure it always slides at a consistent same speed.

    Imperator

    7285 Posts

  • #7, by esmeraldaFriday, 25. May 2018, 14:30 7 years ago
    I actually use a similar method myself. I'm not really that keen on having the interface slide out when the player moves the mouse cursor to the edge of the screen as they might slide the interface out by accident.
    You are right, this happens quite a lot :-)

    By the way, the button (meaning the action area) doesn't have to be a visible part of the interface. It could also be a transparent part of your background image, so there is no visible disturbance of your scene.

    Key Killer

    533 Posts

  • #8, by nebirviSaturday, 26. May 2018, 10:24 7 years ago
    Thank you both! I tried yours @AFRLme but It did not work exactly like I wanted sadly... Now I'm trying @esmeralda s version and I have one question. When I use the action call script I can not call the script I created. Why is that you think? (I created the script under the script page of visionaire so it should be there?...)

    P.s I am an artist not a programmer but if I would like to learn more scripting in visionaire, is there any perticular ways to approach it?

    Thanks again // N

    Newbie

    30 Posts

  • #9, by afrlmeSaturday, 26. May 2018, 11:02 7 years ago
    By default when you create a script it will automatically be set as a definition type script. See the properties (cog icon on 4.x I think?) to check.

    A definition type script means it will be loaded at game launch. These types of scripts are for definining functions & variables that can be accessed at any point during the game from anywhere.

    An execution type script is one that you can call/load & typically should only contain a script that manipulates something.

    As for my method, it should work, but it's likely that you just haven't edited it to suit your needs. The positions you query have to be exact or it won't work.

    Final note: names in Visionaire are case sensitive, which means that when you try to access something in Visionaire via scripting that you need to make sure that you type out the name exactly the same as you have it inside of the Visionaire editor, this includes spelling, whitespace, symbols & case. For example if you gave something the name: Inventöry in the editor then you would have to type it out exactly like that.

    Imperator

    7285 Posts

  • #10, by afrlmeSaturday, 26. May 2018, 21:05 7 years ago
    Here's a sliding interface example that uses mouse over & interface leave. I've written the script with some calculations to determine the slide transition time based on the position of the interface so that it always slides at the same speed. The math gave me a headache. Took me an hour before I realized I'd stupidly wrapped my calculations in a math.floor() function which rounds up decimal numbers to the nearest whole number. Oops.


    P.S: it's for Visionaire Studio 5, but the method should be valid for 4.x.

    Imperator

    7285 Posts

  • #11, by sebastianSunday, 27. May 2018, 01:09 7 years ago
    wouldn't she be able to open your example project in 4.25, Afrlme?

    Thread Captain

    2346 Posts