Hi there. Have searched through the forums and so far been unable to find a solution to my problem so thought I would make a new thread. I apologise if this has been answered, but I was personally unable to find the answer.
So I have a working inventory system, and I am able to drop items into the game world by clicking rmb.
What I would like to do, is also have the option of dropping an item when clicking the lmb outside of the inventory UI.
My code looks like this:
I realise there may be variables etc there from the create event that aren't explained, and can provide other parts of the code upon request. As mentioned above, pressing the rmb does work and drop the item into the game world, I just would also like to be able to drop the item into the game world by clicking lmb, when the cursor is outside the inventory UI.
I feel like the solution lies somewhere with game makers device_mouse_x/y_to_gui function... and then setting conditions for outside the coords of the inventory UI, but I just can't get it to work.
I really appreciate any time anyone spends looking at this, regardless of if you have a solution or not. I realise any help given is out of the kindness of your heart, and I am not expecting or demanding anything at all.
I am just hoping someone more experienced than myself may have a clever way of editing the code to achieve the desired effect... I sure haven't been able to work it out.
either way, thanks for your time
So I have a working inventory system, and I am able to drop items into the game world by clicking rmb.
What I would like to do, is also have the option of dropping an item when clicking the lmb outside of the inventory UI.
My code looks like this:
Code:
//drop item into game world
if(mouse_check_button_pressed(mb_right)){
inv_grid[# 1, selected_slot] -= 1;
//destroy item in inventory if it was the last one
if(inv_grid[# 1, selected_slot] == 0) {
inv_grid[# 0, selected_slot] = item.none;
}
//create the item
var inst = instance_create_layer(obj_player.x, obj_player.y, "Instances", obj_item);
with(inst){
item_num = ss_item;
x_frame = item_num mod (spr_width/cell_size);
y_frame = item_num div (spr_width/cell_size);
}
show_debug_message("dropped an item.")
}
I feel like the solution lies somewhere with game makers device_mouse_x/y_to_gui function... and then setting conditions for outside the coords of the inventory UI, but I just can't get it to work.
I really appreciate any time anyone spends looking at this, regardless of if you have a solution or not. I realise any help given is out of the kindness of your heart, and I am not expecting or demanding anything at all.
I am just hoping someone more experienced than myself may have a clever way of editing the code to achieve the desired effect... I sure haven't been able to work it out.
either way, thanks for your time