status line setup

Started by Lazarus, Wed 08/03/2006 10:05:28

Previous topic - Next topic

Lazarus

I'm in the process of making a new template and I'm having problems with defining between the use and give inventory items, in that I can get one or the other to work but not both.
here's what I have so far:
Code: ags
function SetActionText(){Ã,  
Ã,  string text;
Ã,  if (mouse.Mode==eModeWalkto) StrCopy(text, "Walk to ");
Ã,  else if (mouse.Mode==eModeLookat) StrCopy(text, "Look at ");
Ã,  else if (mouse.Mode==eModePickup) StrCopy(text, "Pick up ");
Ã,  else if (mouse.Mode==eModeInteract) StrCopy(text, "Use ");
Ã,  else if (mouse.Mode==eModeTalkto) StrCopy(text, "Talk to ");
Ã,  
Ã,  else if (mouse.Mode==eModePull) StrCopy(text, "Pull ");
Ã,  else if (mouse.Mode==eModePush) StrCopy(text, "Push ");
Ã,  else if (mouse.Mode==eModeOpen) StrCopy(text, "Open ");
Ã,  else if (mouse.Mode==eModeClose) StrCopy(text, "Close ");
Ã,  
Ã,  else if (mouse.Mode==eModeGive) {
Ã,  Ã, mouse.Mode = eModeUseInv;
Ã,  Ã,  string invname;
Ã,  Ã,  StrCopy(text, "Give ");
Ã,  Ã,  player.ActiveInventory.GetName(invname); 
Ã,  Ã,  StrCat(text, invname);
Ã,  Ã,  StrCat(text, " to ");
Ã,  }
//Ã,  else if (mouse.Mode==eModeUseInv){// If using an inventory item on something
Ã,  else if (mouse.Mode==eModeInteract){
Ã,  Ã, mouse.Mode = eModeUseInv;
Ã,  Ã,  string invname;
Ã,  Ã,  StrCopy(text, "Use ");
Ã,  Ã,  player.ActiveInventory.GetName(invname); 
Ã,  Ã,  StrCat(text, invname);
Ã,  Ã,  StrCat(text, " with ");
Ã,  }

Ã,  Ã,  StrCat(text, "@OVERHOTSPOT@");
		
Ã,  Ã,  gActionStatus.SetText(text);
}


Any help would be grateful

Also while I think about it I can't seem to get these

Code: ags
Ã,  else if (mouse.Mode==eModePull) StrCopy(text, "Pull ");
Ã,  else if (mouse.Mode==eModePush) StrCopy(text, "Push ");
Ã,  else if (mouse.Mode==eModeOpen) StrCopy(text, "Open ");
Ã,  else if (mouse.Mode==eModeClose) StrCopy(text, "Close ");


working quite right in that they don't reset the statusline back to walk to command when used.

*Currently using AGS Editor 2.70 (Build 2.70.601)*

Gilbert

I'm too tired to explain but this may give you ideas (not tested):

function SetActionText(){Ã,  
Ã,  string text;
Ã,  if (mouse.Mode==eModeWalkto) StrCopy(text, "Walk to ");
Ã,  else if (mouse.Mode==eModeLookat) StrCopy(text, "Look at ");
Ã,  else if (mouse.Mode==eModePickup) StrCopy(text, "Pick up ");
Ã,  else if (mouse.Mode==eModeInteract) {
    StrCopy(text, "Use ");
    if (player.ActiveInventory!=null) {
   Ã,  Ã, mouse.Mode = eModeUseInv;
  Ã,  Ã,  string invname;
  Ã,  Ã,  player.ActiveInventory.GetName(invname); 
  Ã,  Ã,  StrCat(text, invname);
  Ã,  Ã,  StrCat(text, " with ");
    }
  } else if (mouse.Mode==eModeTalkto) StrCopy(text, "Talk to ");Ã,  
Ã,  else if (mouse.Mode==eModePull) StrCopy(text, "Pull ");
Ã,  else if (mouse.Mode==eModePush) StrCopy(text, "Push ");
Ã,  else if (mouse.Mode==eModeOpen) StrCopy(text, "Open ");
Ã,  else if (mouse.Mode==eModeClose) StrCopy(text, "Close ");
Ã,  else if (mouse.Mode==eModeGive) {
Ã,  Ã, mouse.Mode = eModeUseInv;
Ã,  Ã,  string invname;
Ã,  Ã,  StrCopy(text, "Give ");
Ã,  Ã,  player.ActiveInventory.GetName(invname); 
Ã,  Ã,  StrCat(text, invname);
Ã,  Ã,  StrCat(text, " to ");
Ã,  }
//Ã,  else if (mouse.Mode==eModeUseInv){// If using an inventory item on something
/*Ã,  else if (mouse.Mode==eModeInteract){
Ã,  Ã, mouse.Mode = eModeUseInv;
Ã,  Ã,  string invname;
Ã,  Ã,  StrCopy(text, "Use ");
Ã,  Ã,  player.ActiveInventory.GetName(invname); 
Ã,  Ã,  StrCat(text, invname);
Ã,  Ã,  StrCat(text, " with ");
Ã,  }
*/
Ã,  Ã,  StrCat(text, "@OVERHOTSPOT@");
      
Ã,  Ã,  gActionStatus.SetText(text);
}


Lazarus

Okay I tried your suggestion and it doesn't quite work,
when I click "use" then on inventory item the status line shows the "use" then disappears leaving inventory item showing eg; "voodoo doll" , it also doesn't displayÃ,  "with" either.

And for some reason it doesn't clear the command as I can keep clicking on an object as if I was using an inventory item.

And I can't get the other mouse modes to change back after use for:
Code: ags
Ã,  else if (mouse.Mode==eModePull) StrCopy(text, "Pull ");
Ã,  else if (mouse.Mode==eModePush) StrCopy(text, "Push ");
Ã,  else if (mouse.Mode==eModeOpen) StrCopy(text, "Open ");
Ã,  else if (mouse.Mode==eModeClose) StrCopy(text, "Close ");

when the other commands work okay eg:
Code: ags
 else if (mouse.Mode==eModeLookat) StrCopy(text, "Look at ");
else if (mouse.Mode==eModePickup) StrCopy(text, "Pick up ");
 else if (mouse.Mode==eModeInteract) StrCopy(text, "Use ");
else if (mouse.Mode==eModeTalkto) StrCopy(text, "Talk to ");
*Currently using AGS Editor 2.70 (Build 2.70.601)*

Lazarus

I had another idea with these cursors, am I supposed to define them?
All I have done is create new cursors

mouse.Mode=eModePush - cursor 10
mouse.Mode=eModePull - cursor 11
mouse.Mode=eModeOpen - cursor 12
mouse.Mode=eModeClose - cursor 13
mouse.Mode=eModeGive - cursor 14

*Currently using AGS Editor 2.70 (Build 2.70.601)*

Pumaman

You probably need to replace this:

  else if (mouse.Mode==eModeInteract) {

with this:

  else if (mouse.Mode==eModeUseInv) {

so that it does the "Use XXX with YYY" thing in Use Inventory mode, not Interact mode.

Lazarus

I have tried your suggestion and added a new command for eMode.mouse == Interact which works ok.

The problem I have now is getting the Give command to work properly, I first had a Null pointer reference so I have changed this so it is similar to the mouse.Mode==eModeUseInv function which seemed to solve that problem.

The problem I have is that the Give function doesn't display "Give (inventory item) to" it displays the normal "Use (inventory item) with".

Also when using the Give mode it seems to remember the last inventory item used, it doesn't seem to clear if you can understand What I mean.

Here's what I have so far:
Code: ags
function SetActionText(){
Ã,  Ã,  string text;Ã,  
Ã,  if (mouse.Mode==eModeWalkto) StrCopy(text, "Walk to ");
Ã,  else if (mouse.Mode==eModeLookat) StrCopy(text, "Look at ");
Ã,  else if (mouse.Mode==eModePickup) StrCopy(text, "Pick up ");
Ã,  else if (mouse.Mode==eModeInteract) StrCopy(text, "Use ");// added

Ã,  else if (mouse.Mode==eModeUseInv) {
Ã,  Ã,  Ã,  StrCopy(text, "Use ");
Ã,  Ã,  if (player.ActiveInventory!=null) {
Ã,  Ã,  Ã,  mouse.Mode = eModeUseInv;
Ã,  Ã,  Ã,  string invname;
Ã,  Ã,  Ã,  player.ActiveInventory.GetName(invname);
Ã,  Ã,  Ã,  Ã, StrCat(text, invname);
Ã,  Ã,  Ã,  StrCat(text, " with ");
Ã,  Ã,  Ã, }
Ã,  Ã, }
Ã,  else if (mouse.Mode==eModeTalkto) StrCopy(text, "Talk to ");
Ã,  else if (mouse.Mode==eModePull) StrCopy(text, "Pull ");
Ã,  else if (mouse.Mode==eModePush) StrCopy(text, "Push ");
Ã,  else if (mouse.Mode==eModeOpen) StrCopy(text, "Open ");
Ã,  else if (mouse.Mode==eModeClose) StrCopy(text, "Close ");

Ã,  else if (mouse.Mode==eModeGive) {
Ã,  Ã,  StrCopy(text, "Give ");
Ã,  Ã,  if (player.ActiveInventory!=null) {
Ã,  Ã,  Ã,  mouse.Mode = eModeUseInv;
Ã,  Ã,  Ã,  string invname;Ã,  Ã,  
Ã,  Ã,  Ã,  player.ActiveInventory.GetName(invname);// was getting Null pointer error here
Ã,  Ã,  Ã,  StrCat(text, invname);
Ã,  Ã,  Ã,  StrCat(text, " to ");
Ã,  Ã,  Ã, }
Ã,  Ã, }

Ã,  Ã,  StrCat(text, "@OVERHOTSPOT@");
Ã,  Ã,  gActionStatus.SetText(text);
 }


Thanks again
*Currently using AGS Editor 2.70 (Build 2.70.601)*

Ashen

#6
QuoteThe problem I have is that the Give function doesn't display "Give (inventory item) to" it displays the normal "Use (inventory item) with".

Depending on where/when you call SetActionText() (and I'd guess it's in rep_ex), that's probably because you're changing the mode to eModeUseInv:

  else if (mouse.Mode==eModeGive) {
    StrCopy(text, "Give ");
    if (player.ActiveInventory!=null) {
      mouse.Mode = eModeUseInv;
      string invname;   
      player.ActiveInventory.GetName(invname);// was getting Null pointer error here
      StrCat(text, invname);
      StrCat(text, " to ");
     }
   }

Removing that line might solve it. If not, it might also be down to how you're handling inventory clicks - using eModeGive on an item might be changing the mode (I think it automatically changes to eModeUseInv when a new ActiveInventory item is set?).

QuoteAlso when using the Give mode it seems to remember the last inventory item used, it doesn't seem to clear if you can understand What I mean.
Possibly the ActiveInventory item hasn't been deselected? Try adding player.ActiveInventory = null; when you set the cursor mode (for eModeGive, and possibly eModeUseInv).
I know what you're thinking ... Don't think that.

Lazarus

Yes it is in the repeatedly exec

and no that didn't work when I removed the line "mouse.Mode = eModeUseInv;"

Adding "player.ActiveInventory = null;" command seems to work ok now.

With regards to mouse inventory clicks I have:
Code: ags
 else if (button == eMouseLeftInv) {
Ã,  Ã,  player.ActiveInventory = inventory[game.inv_activated];
Ã,  Ã,  }
 else if (button == eMouseRightInv) {
Ã,  Ã,  inventory[game.inv_activated].RunInteraction(eModeLookat);
Ã,  Ã,  }
*Currently using AGS Editor 2.70 (Build 2.70.601)*

Ashen

#8
Then I think it's what I said - setting the ActiveInventory will change the mode to eModeUseInv. Perhaps adding a check of the mode before setting the active inv, then changing it back if needed, would work? E.g.:
Code: ags

 else if (button == eMouseLeftInv) {
    int temp;
    if (mouse.Mode == eModeGive) temp = 1;
    player.ActiveInventory = inventory[game.inv_activated];
    if (temp == 1) mouse.Mode = eModeGive;
    }


If needed, you could also use this to filter the other modes so that, for example, "Push (InvItem)" won't change the cursor mode.
I know what you're thinking ... Don't think that.

Lazarus

That sort of works, but when selecting an inventory item and then using it on nothing the give mode doesn't change back to the walk mode or if I right clicked on an object say to look at something.

Also on another note is there a way of setting up the unhandled events for if mouse modes were used for example:
Code: ags
	string locname;
	string invname;
GetLocationName(mouse.x,mouse.y,locname);
Ã,  Ã, 

 if (mouse.Mode==eModeInteract) {
Ã,  Ã, Display("I can't use that");
Ã,  Ã, }
 else if ((mouse.Mode==eModeUseInv)&&(type==3)) {
Ã,  Ã, Display("I can't use the %s with the %s.", invname, locname);
Ã,  Ã, }
 else if ((mouse.Mode==eModeGive)&&(type==3)) {
Ã,  Ã, Display("I rather keep it.");
Ã,  Ã, }

 else if ((mouse.Mode==eModeLookat)&&(type==0)) {
Ã,  Ã, Display("Nothing special with it.");
Ã,  Ã, }
 else if (mouse.Mode==eModePickup) {
Ã,  Ã, Display("I'm picking that up.");
Ã,  Ã, }
 else if (mouse.Mode==eModeTalkto) {
Ã,  Ã, Display("Speaking with %s is a waste of time.", locname);
Ã,  Ã, }
 else if (mouse.Mode==eModePull) {
Ã,  Ã, Display("Pulling that is a waste of time.");
Ã,  Ã, }
 else if (mouse.Mode==eModePush) {
Ã,  Ã, Display("Pushing hat is a waste of time.");
Ã,  Ã, }
 else if (mouse.Mode==eModeOpen) {
Ã,  Ã, Display("I can't open it.");
Ã,  Ã, }
 else if (mouse.Mode==eModeClose) {
Ã,  Ã, Display("I can't close it.");
Ã,  Ã, }


as I wanted different reactions between using an inventory item and giving an inventory item.
*Currently using AGS Editor 2.70 (Build 2.70.601)*

SMF spam blocked by CleanTalk