Asset - Scripts exINV - Inventory System

Discussion in 'Marketplace' started by Catan, Sep 20, 2016.

  1. oudin.chen

    oudin.chen Member

    Joined:
    Aug 16, 2018
    Posts:
    7
    How to use the arrow keys to select the obj_inv_panel_backpack item
     
  2. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    484
    @oudin.chen , you should take a look at the implementation of the toolbar panel. That specific panel already has a key based selection mechanism that works with the numbers from 0 to 9, it shouldn't be to difficult to convert that to an arrow based one.
     
  3. oudin.chen

    oudin.chen Member

    Joined:
    Aug 16, 2018
    Posts:
    7
    I am going to make a slot like a mouse slot, a bit like the 0-9 button, but it moves using the arrow keys
     
  4. oudin.chen

    oudin.chen Member

    Joined:
    Aug 16, 2018
    Posts:
    7
    @Catan, I want 2 breads plus 3 radishes to synthesize a blood bag, can give an example of me?
     
  5. oudin.chen

    oudin.chen Member

    Joined:
    Aug 16, 2018
    Posts:
    7
    I want 2 breads plus 3 radishes to synthesize a blood bag, can give an example of me?
     
  6. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    484
    You can change / define recipes in the craft_init script, by using ex_craft_add_recipe(key_of_resulting_item, number_of_resulting_items, ingredient_1, [ingredient_2], ...).

    It's just a call like:

    Code:
    ex_craft_add_recipe("blood_bag",2,"food_bread","food_radish");
    
     
  7. oudin.chen

    oudin.chen Member

    Joined:
    Aug 16, 2018
    Posts:
    7
    like this?
    Code:
    ex_craft_add_recipe("blood_bag",2,"food_bread","food_bread","food_radish","food_radish","food_radish",);
    but i want code like this:
    Code:
    ex_craft_add_recipe("blood_bag",2,"food_bread",2,"food_radish",3);
     
  8. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    484
    In this case you’ll need to change the crafting system so that it considers the quantities (as stacks) of the ingredients. Right now since crafting is not the main focus of the asset i tried to keep things simple.

    This requires changing how recipes are stored, and therefore you’ll also need to adapt the recipe checking and the crafting panel accordingly. It’s not too difficult but requires some work, if you need some directions feel free to contact me by email
     
  9. oudin.chen

    oudin.chen Member

    Joined:
    Aug 16, 2018
    Posts:
    7
    I can't find your email. My email : oudin.chen@icloud.com . Can you send your email to this email?
     
  10. SkyKnight

    SkyKnight Member

    Joined:
    May 9, 2017
    Posts:
    11
    Is there a way, or have I missed some magical change to the inventories, Backpack, hot bar, equipped items and crafting, all over to the GUI rather than an object in game? Having a problem now that my game is getting larger that if I move around in a room the inventories jump one pixel or one move behind where the camera is. Also I cant zoom in or out with Camera Properties without the inventory moving around the screen and changing size with it. I can kinda get around the Zoom where if we are zoomed in... close all the inventories. But if this CAN be in the GUI and I have missed how... would love to know. Thank you. Thank you for your time.
     
  11. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    484
    You can definitely draw everything to the gui layer, but since the user has to interact with the inventory, you still need to move the actual objects around to register the mouse clicks.
    When using a gui resolution that is different than the game resolution (or things lile zoom and rotation) of course this can get difficult to handle and the inventory doesn’t adjust automatically (since I can’t know in advance how you handle your views).

    It’s a known problem in general when using the gui layer, not just specific to exinv, that can be solved in different ways, but you’ll have to adapt the inventory object yourself.
     
  12. SkyKnight

    SkyKnight Member

    Joined:
    May 9, 2017
    Posts:
    11
    Well I may just ignore the GUI side of it and close down all the windows when we zoom in and allow them to open again when we zoom out. How about the twitching it does when we move and the camera follows. I mean even with out doing anything fancy its as if its one step behind and needs to keep up... I could pause the game when we open items and we would never know but the hot bar down there still twitches and I was looking forward to using it. - Again thank you for your time.
     
  13. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    484
    Are you using the latest version? I move the panels in the end step event, which should be happening after the view has been moved, UNLESS of course you are moving the view yourself also in the end step (or draw).

    A simple solution to this would be to draw the inventory on the gui layer, keeping the object position as it is now. Otherwise you have to ensure the that the follow view code (end step in obj_inv_panel) is run after you move your view.
     
  14. SkyKnight

    SkyKnight Member

    Joined:
    May 9, 2017
    Posts:
    11
    Ok I did "fix" this problem just now- I may need to go back and tweak with it but I sat down with coffee and looked over everything. In the test room of my game I removed anything and everything to do with a camera or effects for it. STILL had the twitch when we moved. All I was using at this point was the View port 0s Object following from the properties for the room. BUT! I used three lines of code for the step even of the player to move the camera, allowing the end step of the obj_inv_panels to run last and all is right with the world- neat.

    At this point I should be able to mess with it and tell it when to allow or not allow us to open the inventories.

    I would love to know HOW to move this to the GUI, I'm not the best at coding. I don't know if you recall but I was on here last time asking help for how to check what item we had in what slot and based on a left or right mouse button we would attack or use an object. You told me that the info was in the documentation... I took a lot of time and looked it all over and I am happy to say I got it working and now even have a layer system in the draw event for our player to add clothing and armors based on what is in what slot also. Pretty happy about it! BUT, back to my point. Not the best at coding or just knowing what to mess with in here and if you had it written down or could give me some tips as to how to move the panels and items to the GUI that we can still click on and moved around.

    Again, thank you for the tip about making sure it ran AFTER we moved the view and for being so quick to reply!
     
  15. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    484
    If you already solved the problem with the view there’s no real need to move everything to the gui layer imho.

    I’ll be releasing a new version in a few weeks that already uses the draw gui event instead of the regular draw, but it’s just to avoid the problem you had about the twitching since it’s quite common. It doesn’t solve obviously the view zoom / rotation / resolution problem since, as said, it really depends on how your game is structured and it’s not really a inventory issue, but a more generic GUI one.
     
  16. SkyKnight

    SkyKnight Member

    Joined:
    May 9, 2017
    Posts:
    11
    Super cool! I look forward to the update. Ill change over when it comes out : ) Thanks!
     
  17. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    484
    Update 1.6.0 is available right now!

    This update is all about small but extremely important changes that should simplify using the asset. Below you'll find the most notable changes explained, please refer to the open post for a detailed list.

    New event notification system!

    The goal of exINV has always been to provide an inventory system that is decoupled from its representation, allowing the developer to program his own user interface from scratch if required. This was achieved using a callback script (ex_inv_updated) that was in charge of update all the UI components. It worked, but was less than ideal.

    The new event notification system, based on the observer pattern, allows any instance to "subscribe" to event notifications. By simply adding a line like the one below to any object, you are telling exINV to run the specified script for the specified instance whenever the inventory changes.
    Code:
    ex_ev_subscribe(player_equpment_inv, player_instance, update_player_equipment)
    The code above for example could update the player appearance or attributes automatically whenever something changes in his equipment inventory.

    Database updates
    You are no longer forced to use the built in CSV loader to create an item database. The ex_db_add script allows populating the item database manually from code.
    Moreover, items in the database can be assigned to groups, allowing retrieving a list of item keys for specific groups (useful for example if you want to get random items of a specific type for loot etc...)

    GUI layer migration
    Previously, the inventories user interface was built using regular draw events. The idea was to keep things as simple as possible in order for the developer to customize to fit. Being able though to display the inventory regardless of the GUI resolution and view settings is by far the most requested feature since the first version of exINV, so I'm happy to announce that as of version 1.6 you get this out of the box.

    UI rework
    The objects for the user interface have been rebuilt from scratch (but keeping the same structure) in order to fit the new event system. As a result, objects code is cleaner and better organized.

    Tags management
    Lastly, there have been a few changes to the management of item tags. Until now, you could retrieve the tags ds_map of an item directly by using ex_item_get_tags. This caused a lot of problems since that ds_map was managed internally by the system, and allowing the developer to access it directly led to very confusing issues. As of version 1.6, it is no longer possible to access this data directly, but only as a copy that can be used and altered freely without worrying about the original data.
    Due to this change, if you now use ex_item_get_tags to get the tags ds_map, you should remember to destroy it when finished!


    This is it for this update, remember to look at the updated documentation for the latest version (link in the open post).

    If you encounter any problem, as always feel free to contact me.
     
  18. Posh Indie

    Posh Indie Member

    Joined:
    Dec 5, 2016
    Posts:
    180
    I see a lot of mouse related conversation in this thread. How easy would it be to adapt this system to other inputs (Keyboard keys, gamepad buttons/sticks, etc)?
     
  19. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    484
    I’d say not a problem, but consider that this is an asset for building grid based inventories (think minecraft), that are generally used with mouse input.

    Everything can be done without the mouse as well though, and in fact disabling it requires simply removing the line of code that creates its controller instance.

    The demo project shows how you can select slots in a toolbar using the number keys for example.
     
  20. Pizuar

    Pizuar Member

    Joined:
    Jan 11, 2019
    Posts:
    1
    Thanks a lot for this system, was really worth buying it. Don't know how long It would've taken me to learn systems like this without project posts like these, the use guide is a good help as well. :)
     
    Catan likes this.
  21. Morsayou

    Morsayou Member

    Joined:
    Apr 23, 2018
    Posts:
    7
    Hello, im trying since 2 days to make something happen when i press enter while a carrod is in my selected slow of my toolbar.

    Code:
    if (keyboard_check_pressed(vk_enter)){
        if (obj_inv_slot.index + 1 == obj_inv_panel_toolbar.selected_slot){
            if (obj_inv_slot.key != -1){
                var _removeItem = true;
                switch (obj_inv_slot.key){
                    case "food_carrot":
                    
                        show_message("Ate a carrot!");
                                    
                    break;
                    default: _removeItem = false; break;
                }             
                if (_removeItem) ex_item_remove(global.inv_toolbar,key, 1);
            }       
        }
    }
    I would like to know what i did wrong. Thanks for ur help.
     
  22. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    3,682
    Is adding "out of the box" support for full gamepad / keyboard navigation of inventories something you might consider adding?

    Keep up the good work, I forgot I'd bought this asset (doh!) and you've added some nice stuff since I last checked it out.

    I'm going to be adding inventory / UI stuff soon so I'm glad I remembered I own this and can take another look and see if it will be suitable. I don't need any crafting or recipes etc so it may be overkill unless it's easy enough to strip out.
     
    Last edited: Mar 16, 2019 at 11:16 AM
  23. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    484
    @Morsayou

    You can't refer to a specific slot by using the object name (obj_inv_slot), you need to get the right instance. I'm not really sure what you are trying to check with that condition honestly. If you want to get the item key of the currently selected slot in the toolbar, you can simply do something like this:

    Code:
    var _key = obj_inv_panel_toolbar.selected_slot.key;
    if(_key == "food_carrot") { do_something(); }
    
    Please note that this assumes your toolbar is always visible. If that's not the case, ensure you have a instance of the toolbar beforehand.

    @rIKmAN

    I don't have plans for adding gamepad / keyboard support, I think it's too project specific to be useful out of the box. Should be easy enough to implement though, the number keys for the toolbar are just a few lines of code for example.

    Crafting is totally optional, and it's initialised separately from the rest. It's enough to remove (or never call) the crafting initialisation script. You can optionally remove the crafting panel and relative script folder if you want to. Even the mouse interaction is optional, if you simply don't open a mouse panel, everything still works.
     
    Last edited: Mar 17, 2019 at 7:29 PM
  24. Morsayou

    Morsayou Member

    Joined:
    Apr 23, 2018
    Posts:
    7
    Oh ye thank you very much... À last thing how to check the type of the object?? Or the category. Like : if categoryofitem is food {can eat }

    Thank u very much
     
  25. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    484
    If you have that info in the CSV file, it's just an item property. You can get the item properties ds_map in two ways:

    1. Directly from the slot objects, by using slot.item
    2. Using ex_item_get_item (I know, sounds redundant, but didn't want to break compatibility with older versions)

    In both cases you get a ds_map holding the item data, so you can just use item[? "type"] or item[? "whatever"] as long as you defined that property in the CSV
     
  26. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    3,682
    Yeah it won't be too hard to add myself, just thought I'd ask if it was planned so I didn't spend time implementing something that you were going to be adding anyway.

    That's great about being able to easily remove elements of the system, I'll take a proper look sometime this week but that sounds promising, thanks.
     
    Catan likes this.
  27. Morsayou

    Morsayou Member

    Joined:
    Apr 23, 2018
    Posts:
    7
    Sorry, i will look very idiot but im pretty newbie. I tried something like :
    Code:
    var _item = obj_inv_panel_toolbar.selected_slot.item;
    draw_text(32, 96, string_hash_to_newline("var " + string(_item[? "type"])));
    But ofc it not work because i dont even know what im doing...
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice