Mouse inventory mode

Started by Lazarus, Wed 12/04/2006 11:55:42

Previous topic - Next topic

Lazarus

Hi at present I'm using:
Code: ags
 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
*Currently using AGS Editor 2.70 (Build 2.70.601)*

SSH

put in some code to do mouse.Mode=eModeWalkto?
12

Ashen

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.
I know what you're thinking ... Don't think that.

Lazarus

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:
Code: ags
 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
Code: ags
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.
*Currently using AGS Editor 2.70 (Build 2.70.601)*

Ashen

#4
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:
Code: ags

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?
I know what you're thinking ... Don't think that.

Lazarus

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.
*Currently using AGS Editor 2.70 (Build 2.70.601)*

Scorpiorus

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...

SMF spam blocked by CleanTalk