Asset - Scripts exINV - Inventory System

O

oudin.chen

Guest
If that's the case, you are right, you probably want something like and equipment inventory with named slots you can refer to. The sample project shows just that. The only thing you'll need to consider is differentiating a left/right click used for attacking / using an item from a click used for moving stuff around in your inventory (or using any other UI element).
How to use the arrow keys to select the obj_inv_panel_backpack item
 
H

Homunculus

Guest
@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.
 
O

oudin.chen

Guest
@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.
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
 
O

oudin.chen

Guest
@Catan, I want 2 breads plus 3 radishes to synthesize a blood bag, can give an example of me?
 
O

oudin.chen

Guest
@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.
I want 2 breads plus 3 radishes to synthesize a blood bag, can give an example of me?
 
H

Homunculus

Guest
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");
 
O

oudin.chen

Guest
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");
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);
 
H

Homunculus

Guest
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
 
O

oudin.chen

Guest
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
I can't find your email. My email : [email protected] . Can you send your email to this email?
 

SkyKnight

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

Homunculus

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

SkyKnight

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

Homunculus

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

SkyKnight

Member
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!
 
H

Homunculus

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

Homunculus

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

Posh Indie

That Guy
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)?
 
H

Homunculus

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

Pizuar

Member
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. :)
 

Morsayou

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

rIKmAN

Member
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.
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:
H

Homunculus

Guest
@Morsayou

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.
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 by a moderator:

Morsayou

Member
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
 
H

Homunculus

Guest
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
 

rIKmAN

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

Morsayou

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

Homunculus

Guest
Quick but important update. I just released version 1.6.1 that fixed a problem related to ex_item_test_ext, that was causing crafted items to behave abnormally when taken from the crafting inventory. Please download the new version and replace the script at ex/core /ex_item/ex_item_test_ext in your existing exinv 1.6.0 project in order to upgrade.
 
G

Gaaronhoff

Guest
Hello! Is development ongoing for this asset? I've just purchased and am really happy with it, but was curious if future releases are planned.
 
Last edited by a moderator:

SkyKnight

Member
Just updated my GMS2 and I can no longer equip items in the equipment panel. Tried on my own project to figure out what the problem might be and also just importing exINV in a project to test if it would work. Anyone have this problem or a fix? Might be just something simple, I kinda miss little things sometimes in code. I will come back fresh tomorrow and see if I can fix it myself. But if anyone finds something I would love to know or if I figure it out and don't see a post I'll share what fixed it. Good luck all.
 
D

Deleted member 54458

Guest
same issue, it doesnt work right since 2.3.0 beta release, and i really cannot find the reason. Im sending email to Homunkulus about this.
 
D

Deleted member 54458

Guest
lol i find the problem. "In 2.3 other now returns a struct for the other instance, so you can't compare your id number with a struct"

in user event of inv_panel_eqipment you just need to replace
var _slot = other;
to
var _slot = other.id;
 

SkyKnight

Member
You are a hero slon230 - Side note, this also will fix a problem with crafting where mats used to craft an item would not be consumed in the process. Also in the User Event, this time of "obj_inv_panel_craft". Not sure of any other place this is used, I am sure I will find them when I get to them but thank you! Good luck.
 
D

Deleted member 54458

Guest
Btw SkyKnight did you figured out how to add tags to items in exinv1.6.0?
im using
ex_item_add( inv, key, amount, [slot], [tags] )
and typing, for example
ex_item_add( my_inv, "sword", 1, -1, [? "fire_damage"] = 1)
but no tags seems to be added
 
H

Halas

Guest
Since the new update - I have been getting this error.

GML:
script_execute argument 1 incorrect type (undefined) expecting a Number (YYGI32)
Does anyone know what must be done?
It related to the Script ex_ev_notify
 
Sorry to bother you, but I'm having an issue with exInv...
For some reason (and I cannot figure out why) the mouse slot is being rendered twice, once at the normal position and once in the top left of every room.
Is there something I can do to fix this?
 
Sorry to bother you, but I'm having an issue with exInv...
For some reason (and I cannot figure out why) the mouse slot is being rendered twice, once at the normal position and once in the top left of every room.
Is there something I can do to fix this?
Never mind, the slot was rendering itself because the render event was not specified.
 
Top