What is the big deal behind this anyway guys??
Why don't you simply do this like this (this will works for 100%, cause this is how I've done it in my inventory):
// switch to toggle inventory:
void toggleInventory(){
// put some comperisions here:
// f.e. if we are dead, don't allow to toggle inventory:
if(player.health <= 0){ return; }
// toggle var:
invOpen += 1;
invOpen %= 2;
// if we've opened the intentory:
if(invOpen == 1){
// show the mouse pointer:
mouse_mode = 2;
}
else{
// hide the mouse:
mouse_mode = 0;
}
}
// players actions:
action heroDude(){
// toggle inventory:
on_i = toggleInventory;
// player's loop:
while(my.health > 0){
// .......
// .......
// .......
// if inventory closed:
if(invOpen == 0){
// allow to move:
force.x = 10 * (key_w - key_s) * time_step;
force.y = 10 * (key_a - key_d) * time_step;
force.z = 0;
}
else{
// if it was open, stop movement:
vec_set(force.x, nullvector);
}
// .......
// .......
// .......
// wait one frame:
wait(1);
}
}
// main game function:
void main(){
// .......
// .......
// .......
// main game loop:
while(1){
// .......
// .......
// .......
// if we've enabled the mouse:
if(mouse_mode > 0){
// move it's position with a cursor:
vec_set(mouse_pos.x, mouse_cursor.x);
}
// wait one frame:
wait(1);
}
}
Why are you trying to make things complicated? Make it easier instead

Greets