Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - an4vy

#1
Hallo everybody and sorry for my very poor english.
I have a problem when i try to use an inventory item with any other thing (characters, hotspot, object...)
Seems like AGS doesn't recognise the item selected by the player.

For example, I try to give an apple to someone and I want him to answer "Thank you", otherwise,
if I give him any other inventory item, I'll have the answer written in unhandled event function,
for example "bad idea".


Code: ags


function cPescatore_UseInv()
{

if (cLaura.ActiveInventory==iApple){
cPescatore.Say("Thank you!");
cLaura.LoseInventory(iApple);
}
else unhandled_event(3, 3);
}
  


AGS always answer with the unhandled function "bad idea", even if I give the apple to the NPG...

I solved the problem adding, at the beginning of the function, the code:

player.ActiveInventory = inventory[game.inv_activated];

and it works fine now, but I don't understand why i have to write that line for every Use_Inv function
in order to make it works!

This is my code for on_mouse_click:

Code: ags


function on_mouse_click(MouseButton button) 
  {
 //....here there is the 'eMouseLeft and Right' button code, then:
else if ((button == eMouseLeftInv)&&(mouse.Mode != eModeLookat)&&(player.ActiveInventory == null)) { 
     player.ActiveInventory = inventory[game.inv_activated];
     Mouse.ChangeModeGraphic(eModeUseinv,inventory[game.inv_activated].Graphic);
    Mouse.Mode = eModeUseinv;
    }
     
    else if ((button == eMouseLeftInv)&&(mouse.Mode == eModeLookat)) { 
    inventory[game.inv_activated].RunInteraction(eModeLookat);
    }
   
     else if ((button == eMouseLeftInv)&&(mouse.Mode == eModeUseinv)&&(player.ActiveInventory != null)) {
      player.ActiveInventory.RunInteraction(eModeUseinv); 
     }

      else if ((button == eMouseRightInv)&&(player.ActiveInventory != null)) {
     player.ActiveInventory = null;
     }   
 
     else {
       //player.ActiveInventory = inventory[game.inv_activated];
      player.ActiveInventory=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
      mouse.Mode=eModeUseinv;
    } 
  } 



Can anyone help me?
SMF spam blocked by CleanTalk