M
MeanLikeCharlieSheen
Guest
Okay so my inventory system is based off of friendlycosmonauts farming rpg series - long story short i've been trying to get a little crafting system going were when i press the craft campfire button it checks inventory for enough wood then removes the wood and drops a forge item on the ground- been playing around with it for a few days managed to get it working in a few different ways just not as intended. with the code provided below i am only able to craft the campfire if woodenlogs was the last slot i was touching as (ss_item) = selected slot
So how would i go about looping through the inventory and finding the right slot
<3 Sheen
So how would i go about looping through the inventory and finding the right slot
GML:
var inv_grid = ds_inventory;
var ss_item = inv_grid[# 0, selected_slot];
//Crafting Test
if(mouse_check_button_pressed(mb_left)){
if(craft1 = true){ //Toggled true by pressing the craft button
if(ss_item = item.woodenlogs){
if (inv_grid[# 1, selected_slot] >= 5){
inv_grid[# 1, selected_slot] -= 5;
craft1 = false;
//item crafted to drop
var inst = instance_create_layer(obj_player.x,obj_player.y, "Instances", obj_item);
with (inst){
item_num = item.campfire;
x_frame = item_num mod (spr_width/cell_size);
y_frame = item_num div (spr_width/cell_size);
}
}
show_debug_message("crafted a campfire");
}
}
}
<3 Sheen