Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Lazarus on Wed 12/04/2006 11:55:42

Title: Mouse inventory mode
Post by: Lazarus on Wed 12/04/2006 11:55:42
Hi at present I'm using:
if (button == eMouseLeftInv) {
Ã,  Ã,  Ã, InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
Ã,  Ã,  if (player.ActiveInventory == null) {
Ã,  Ã,  Ã,  if ((StrComp(verb, vGive) != 0) && (StrComp(verb, vUse) != 0)) {
Ã,  Ã,  Ã,  Ã,  if (item != null)
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  item.RunInteraction(mouse.Mode);
Ã,  Ã,  Ã,  Ã, }
Ã,  Ã,  Ã,  Ã, else {
Ã,  Ã,  Ã,  Ã,  Ã,  if (StrComp(verb, vUse) == 0)
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  if (item.IsInteractionAvailable(eModeInteract) == 1) {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  item.RunInteraction(mouse.Mode);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  return;
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, }
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, player.ActiveInventory = item;
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, mouse.Mode = eModeUseInv;
Ã,  Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã, else {
Ã,  Ã,  Ã,  Ã,  Ã, if (item != null)
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, item.RunInteraction(mouse.Mode);
Ã,  Ã,  }
} // function end


The problem I have is that when using an inventory item it doesn't return back to the walkto mode after use, you have to then click again somewhere else to return back to the walk mode.

Is there a way so this happens after the interaction has happened?

Thanks in advance
Title: Re: Mouse inventory mode
Post by: SSH on Wed 12/04/2006 12:49:29
put in some code to do mouse.Mode=eModeWalkto?
Title: Re: Mouse inventory mode
Post by: Ashen on Wed 12/04/2006 13:56:10
Also, and this might just be how you've copied the code here, there seems to be problems with the braces - specifically the line if (StrComp(verb, vUse) == 0) looks to be missing an opening brace, which would throw the following conditions off.
Title: Re: Mouse inventory mode
Post by: Lazarus on Thu 13/04/2006 08:31:44
I've tried your suggestion with "mouse.Mode=eModeWalkto" between each line and it didn't seem to work.

Also looking at the braces they all seem to be there, I've numbered them for ease to look at:
if (button == eMouseLeftInv) { //1
Ã,  Ã,  Ã, InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
Ã,  Ã,  if (player.ActiveInventory == null) { //2
Ã,  Ã,  Ã,  if ((StrComp(verb, vGive) != 0) && (StrComp(verb, vUse) != 0)) { //3
Ã,  Ã,  Ã,  Ã, if (item != null)
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  item.RunInteraction(mouse.Mode);
Ã,  Ã,  Ã,  Ã, } //3
Ã,  Ã,  Ã,  Ã, else { //4
Ã,  Ã,  Ã,  Ã,  if (StrComp(verb, vUse) == 0)
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  if (item.IsInteractionAvailable(eModeInteract) == 1) { //5
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  item.RunInteraction(mouse.Mode);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  return;
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, } //5
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, player.ActiveInventory = item;
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, mouse.Mode = eModeUseInv;
Ã,  Ã,  Ã,  Ã,  Ã,  } //4
Ã,  Ã,  Ã,  Ã,  } //2
Ã,  Ã,  Ã,  Ã, else { //6
Ã,  Ã,  Ã,  Ã,  Ã, if (item != null)
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, item.RunInteraction(mouse.Mode);
Ã,  Ã,  } //6
} // function end //1


If I put a brace at the end of
if (StrComp(verb, vUse) == 0) {
where would I then Put a closing brace? I tried putting the closing brace before closing brace number 4 which didn't work and if also stop the giving command to work.
Title: Re: Mouse inventory mode
Post by: Ashen on Thu 13/04/2006 11:00:19
If it works OK (apart from the 'Walkto' thing), then there's probably nothing wrong - it just seemed like that line needed a brace, and I was having difficultly figuring out the nesting of the conditions.  Personally, I'd combine that line with the else brace 4, as an else if (StrComp(verb, vUse) == 0) command:

if (button == eMouseLeftInv) { // 1
  InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  if (player.ActiveInventory == null) { // 2
    if ((StrComp(verb, vGive) != 0) && (StrComp(verb, vUse) != 0)) { //3
      if (item != null)
        item.RunInteraction(mouse.Mode);
    } // 3
    else if (StrComp(verb, vUse) == 0) { // 4
      if (item.IsInteractionAvailable(eModeInteract) == 1) { // 5
        item.RunInteraction(mouse.Mode);
        return;
      } // 5
      player.ActiveInventory = item;
      mouse.Mode = eModeUseInv;
    } // 4
  } // 2
  else if (item != null)
    item.RunInteraction(mouse.Mode);
} // function end 1


But like I said - if it works, just ignore me.



When (which condition) do you want to change to eModeWalkto? And does including mouse.Mode=eModeWalkto just not do anything, or does it actually stop it from working as it was?
Title: Re: Mouse inventory mode
Post by: Lazarus on Thu 13/04/2006 11:39:20
When using the "mouse.Mode=eModeWalkto" anywhere it didn't work in resetting to the walk command I still had to click else where on the screen for it to change back.
It seems to remember that its holding an inventory item after it's been used on an object or hotspot.
Title: Re: Mouse inventory mode
Post by: Scorpiorus on Tue 18/04/2006 02:09:38
AGS doesn't revert to "eModeWalkto" or any other mode automatically. You should do it manually by changing the mouse.Mode property or by deselecting player's active inventory item: player.ActiveInventory = null;

What if you put "mouse.Mode = eModeWalkto;" just after each "something.RunInteraction(eModeUseinv);" command?

item.RunInteraction (eModeUseinv);
mouse.Mode = eModeWalkto;

...

object.RunInteraction (eModeUseinv);
mouse.Mode = eModeWalkto;

...

hotspot.RunInteraction (eModeUseinv);
mouse.Mode = eModeWalkto;

etc...