again problem with removing and creating!

Posted By: Schloder87

again problem with removing and creating! - 03/30/10 21:44

got a problem again.

following problem: i coded a inventory, if i pick the shield from the inventory an klick on mouse middle, the shield should fall down on the floor. this works, but if the shield already lies on the floor an i press mouse middle, a new one gets created!


Quote:


function pick_shield()
{
my.enable_click = on;

if (mouse_map != pointer_pcx) {return;} // don't pick the item if the mouse pointer isn't the cursor
if (vec_dist (player.x, my.x) > 100) {return;} // if the player is far away ignore it

player.shield = 1; // the player has got the shield
show_pointer = 1; // show the mouse pointer
mouse_map = shield_pcx;


if (mouse_map == shield_pcx)
{
on_mouse_middle= delete_shield;
// wegwerfen des schildes bei rechter maustaste ///////////////
}
}


//// WIRF DEN SCHILD WEG//////////

action delete_shield()
{
mouse_map=pointer_pcx;
my = ent_create(shield_mdl,player.x,NULL);
show_pointer=0;
player.shield =0;
while (player == null) {wait (1);}


my.enable_click = on;
my.event = shield_init;

}


Posted By: Superku

Re: again problem with removing and creating! - 03/30/10 22:34

Why do you open a new topic ?!?!

Change
if (mouse_map == shield_pcx)
{
on_mouse_middle= delete_shield; // wegwerfen des schildes bei rechter maustaste ///////////////
}

to:

if (mouse_map == shield_pcx)
{
if(mouse_middle) {
delete_shield();
while(mouse_middle) { wait(1); }
}
}
Posted By: Schloder87

Re: again problem with removing and creating! - 03/30/10 22:43

still doesn`t work. now nothing happens anymore...
Posted By: Pappenheimer

Re: again problem with removing and creating! - 03/30/10 23:20

Shouldn't you ask first whether the player still has the shield?
Like this:

action delete_shield()
{
if(layer.shield == 1)
{
mouse_map=pointer_pcx;
my = ent_create(shield_mdl,player.x,NULL);
show_pointer=0;
player.shield =0;
}
while (player == null) {wait (1);}


my.enable_click = on;
my.event = shield_init;

}
© 2024 lite-C Forums