W
Wild_West
Guest
I'm having trouble finding the solution to a question/answer error in this check for if an item is collected and your inventory is already full.
The top part works fine but the bottom half , the stuff for asking if you want to replace an item in your inventory is all wrong.
When I try to collide with an item , it asks me the question even when all my inventory slots are empty despite my != "" part. and it only terminates the question if I replace slot 0, not the slot of my choice, although at the end I DO actually get the item to appear in that slot too, but it's also in slot 0 every time no matter what which of course is wrong.
I can't see what's causing this s I need a more keen eye, thanks in advance.
Code in item collision with player
:This part works:
-----------------------
//Look through the items array
for( c = 0; c < 6; c ++; )
{
//and if any empty spaces exist place the name of this object in that space.
if(menu_object.held_items[c] == "")
{menu_object.held_items[c] = name;}
/*if the array slot already has this object's name set in it,
add 1 more of the item to the slot's supply
then break out of the loop search so it doesn't fill ALL the empty spaces.*/
if(menu_object.held_items[c] == name)
{menu_object.number_of_items[c] += 1; break;}
}
instance_destroy();
//-----------------------------------------------------------------------------------------------------
:This stuff doesn't work:
--------------------------------
//If there's no space ask if you want to replace an item
for( s = 0; s < 6; s ++; )
{
if(menu_object.held_items != "")
{
replace_item = show_question
("Inventory is full, would you like to replace an item?");
if(replace_item == true)
{
replacement_slot = get_integer
("Choose one of the 6 inventory slots to place this item in.
#(Once replaced the previous item will be lost forever.)", 0);
menu_object.held_items[replacement_slot] = name;
menu_object.number_of_items[replacement_slot] = 1;
instance_destroy();
}else{ exit; }
}
}
Just what the menu room looks like
The top part works fine but the bottom half , the stuff for asking if you want to replace an item in your inventory is all wrong.
When I try to collide with an item , it asks me the question even when all my inventory slots are empty despite my != "" part. and it only terminates the question if I replace slot 0, not the slot of my choice, although at the end I DO actually get the item to appear in that slot too, but it's also in slot 0 every time no matter what which of course is wrong.
I can't see what's causing this s I need a more keen eye, thanks in advance.
Code in item collision with player
:This part works:
-----------------------
//Look through the items array
for( c = 0; c < 6; c ++; )
{
//and if any empty spaces exist place the name of this object in that space.
if(menu_object.held_items[c] == "")
{menu_object.held_items[c] = name;}
/*if the array slot already has this object's name set in it,
add 1 more of the item to the slot's supply
then break out of the loop search so it doesn't fill ALL the empty spaces.*/
if(menu_object.held_items[c] == name)
{menu_object.number_of_items[c] += 1; break;}
}
instance_destroy();
//-----------------------------------------------------------------------------------------------------
:This stuff doesn't work:
--------------------------------
//If there's no space ask if you want to replace an item
for( s = 0; s < 6; s ++; )
{
if(menu_object.held_items
{
replace_item = show_question
("Inventory is full, would you like to replace an item?");
if(replace_item == true)
{
replacement_slot = get_integer
("Choose one of the 6 inventory slots to place this item in.
#(Once replaced the previous item will be lost forever.)", 0);
menu_object.held_items[replacement_slot] = name;
menu_object.number_of_items[replacement_slot] = 1;
instance_destroy();
}else{ exit; }
}
}
Just what the menu room looks like