B
BabyBlueJeff
Guest
I'm currently making a dungeon crawler and working on the inventory system. On my map, I have two trash cans in different locations, but both are technically using the same object. As the character walks through the dungeon, it will create an instance of a trash can object if detected on the map and destroy the instance of that trash can object when walking too far away from it (because it will be out of view).
I have another object that's basically a list/directory of the trash cans and the items within them like so:
What I'm having an issue with is upon clicking a trash can, I want that specific trash can to only grab the item from the trash_can_1 and if I click a different trash can, that one should only grab the item from trash_can_2. I can't use the instance id with the way we're creating and destroying the trash cans because the id keep changing.
In my trash can object, I have a Left Pressed event that takes the item from the trash can and adds it to the player's inventory. (Obviously, the example below is only grabbing from trash_can_1 at the moment.)
How do I make it so that each trash can instance grabs a specific item?
I have another object that's basically a list/directory of the trash cans and the items within them like so:
Code:
trash_can_1 = ds_list_create();
ds_list_add(trash_can_1, "Item A");
trash_can_2 = ds_list_create();
ds_list_add(trash_can_2, "Item B");
In my trash can object, I have a Left Pressed event that takes the item from the trash can and adds it to the player's inventory. (Obviously, the example below is only grabbing from trash_can_1 at the moment.)
Code:
var item_in_trash_can = ds_list_find_value(trash_can_1, 0); // grabs "Item A"
ds_list_add(player.inventory, item_in_trash_can); // adds "Item A" to player's inventory list
ds_list_clear(trash_can_1); // empties trash can
Last edited by a moderator: