// when the mouse is released check if the inventory is still open and that there is an item selected (999 means no item)
if (global.gamepause == 1) && (global.onmouse != 999) {
blockcheck = collision_point(window_view_mouse_get_x(0),window_view_mouse_get_y(0),obj_invblock,1,0);
//check if the item is released on another obj_invblock
if (blockcheck != -4) {
if (blockcheck.content == 0){
blockcheck.content = global.onmouse
ds_grid_set(global.inventory,blockcheck.dsx,blockcheck.dsy,global.onmouse);
global.onmouse = 999;
global.oldx = 999;
global.oldy = 999;
} else {
show_message("You broke it!!!");
}
// If the item is released somewhere else put it back in its original position
} else if (global.onmouse != 999)&& (blockcheck = -4){
ds_grid_set(global.inventory,global.oldx,global.oldy,global.onmouse);
global.onmouse = 999;
global.oldx = 999;
global.oldy = 999;
}
}
this is all in an inventory controller object and in the global mouse release event.
The code works fine when i release it in an open slot. The problem is that I want it to return to it's old position when you drop it somewhere else (so not on object_invblock).
When I debug it the variables oldx and oldy have the right values in them. I also tried changing the ds_grid_set to:
ds_grid_set(global.inventory,real(global.oldx),real(global.oldy),global.onmouse);
Could someone help me out here?



Find content
Not Telling

