TheNegroShoddy
Member
I'm trying to make an inventory using the ds_map function that will contain the cards that the player doesn't have in their deck. At the start of the game I want the player to have three cards already in their inventory (Barrier, Bomb, and Snipe Shot as you'll see in the code below). I seem to keep getting this error every time I try running the code in game:
This the code I'm using in my inventory_controller object:
Any ideas as to why this isn't working for me?
Code:
___________________________________________
############################################################################################
FATAL ERROR in
action number 2
of Create Event
for object inventory_controller:
Push :: Execution Error - Variable Index [0,1] out of range [1,1] - -1.inv_card(100024,1)
at gml_Object_inventory_controller_CreateEvent_2 (line 23) - ds_map_add(global.inventory, inv_card[inv_card_num], "Bomb"); // This card will be added to the next position in the array and stored in the inventory
############################################################################################
Code:
// This code will set up the player's bag/inventory for the start of the game
global.total_inv_slots = 200
//
global.inventory = ds_map_create()
// Use an array to allow for more flexiablity...
inv_card[0] = 0; // have to initalize the key value before using it
inv_card_num = 0; // use "inv_card_num" as a variable instead of just "i" to be more specfic
// Note that a "card name" should be assigned to the "inventory card"
// The following code adds Snipe Shot card to the player's bag/inventory
ds_map_add(global.inventory, inv_card[inv_card_num], "Snipe Shot"); // I chose inv_card instead of card1 as the variable cause I have assigned card1 already
// map id key value
inv_card_num++ // increase the variable so that the next card added to the player's inventory will be added to the next position in the array
ds_map_add(global.inventory, inv_card[inv_card_num], "Bomb"); // This card will be added to the next position in the array and stored in the inventory
inv_card_num++ // increase the variable so that the next card added to the player's inventory will be added to the next position in the array
ds_map_add(global.inventory, inv_card[inv_card_num], "Barrier");