Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: guybrush on Tue 05/07/2005 18:40:01

Title: HOTSPOTNAME on cursor
Post by: guybrush on Tue 05/07/2005 18:40:01
I'm really sorry if this thread allready exists, but i really need help(really).
I want to make cursor on which will be displayed Hotspot or object name when it moves over hotspot/object, such as used in 7 days a sceptic. Thnx.
Title: Re: HOTSPOTNAME on cursor
Post by: monkey0506 on Tue 05/07/2005 18:48:32
Labelname.SetText("@OVERHOTSPOT@");

"@OVERHOTSPOT@" is replaced with the object/hotspot/character name that the mouse is over.  And if you want it to follow the mouse, you could just add (in rep_ex):

if (mouse.Mode == eModeHotspot) {
  Labelname.X = mouse.X + 5;
  Labelname.Y = mouse.Y + 5;
  Labelname.Visible = true;
  }
else Labelname.Visible = false;

Of course that's mostly just some pseudo-code, but I think you should be able to get the drift of it.
Title: Re: HOTSPOTNAME on cursor
Post by: hedgefield on Tue 05/07/2005 18:57:17
I use:
----------------------------------------------------------------------------------------------------
int Over;string Name;int CharId, Direction, dx, dy;

#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE

function repeatedly_execute() {
// put anything you want to happen every game cycle here

    if (IsOverlayValid(Over)){
      GetLocationName(mouse.x,mouse.y,Name);
      SetTextOverlay(Over,mouse.x-25,mouse.y-18,100,1,15,Name);}
                  //mouse.x/mouse.y=position, 100=width, 1=?font?, 15=color

#sectionstart on_event   // DO NOT EDIT OR REMOVE THIS LINE

function on_event (int event,int data) { 
    if (event==ENTER_ROOM) {
      GetLocationName (mouse.x,mouse.y,Name);
      Over=CreateTextOverlay(mouse.x-25,mouse.y-18,100,1,15,Name);}
                       //mouse.x/mouse.y=position, 100=width, 1=?font?, 15=color
    else if (event==LEAVE_ROOM) {   
      RemoveOverlay (Over);}
      //Needs additional script to remove the overlay during the actual interaction.
}
------------------------------------------------------------------------------------------------------
A bit more complicated, but it gets the job done :)
Title: Re: HOTSPOTNAME on cursor
Post by: guybrush on Wed 06/07/2005 19:21:13
Thanks. So, I just copy this to global script or what?
Title: Re: HOTSPOTNAME on cursor
Post by: monkey0506 on Wed 06/07/2005 19:34:04
Well it's a lot easier to just use a label.
Title: Re: HOTSPOTNAME on cursor
Post by: BorisZ on Wed 06/07/2005 22:18:30
Quote from: monkey_05_06 on Wed 06/07/2005 19:34:04
Well it's a lot easier to just use a label.

Yes it is, but there are some problems with it. When blocking event starts, label does not dissapear. With overlay you can make it dissapear on blocking actions.
Title: Re: HOTSPOTNAME on cursor
Post by: guybrush on Fri 08/07/2005 19:42:51
Uhm, Guys? I still have one question. Where should I put this lines? In global script? I really am a beginner, so sorry for beeing so... Can't think of the word, but you get what I mean.
Title: Re: HOTSPOTNAME on cursor
Post by: hedgefield on Sat 09/07/2005 10:33:15
Yes the global script. The first line goes way at the top, the second chunk under repeatedly_execute and the last bit under sectionstart_on_event

Do please note the

function repeatedly_execute() {
// put anything you want to happen every game cycle here


and the

function on_event (int event,int data) { 

Which should already be in the script.
Title: Re: HOTSPOTNAME on cursor
Post by: monkey0506 on Sat 09/07/2005 23:01:00
Actually I don't think on_event is in the global script by default is it?  If not you can consult the manual on how to create it.  Unless of course I'm just completely wrong.
Title: Re: HOTSPOTNAME on cursor
Post by: guybrush on Sun 10/07/2005 19:22:27
Yeah. I've copyed it to global script just like (where) you said, but there's always some error messages I don't wanna. Could you explain it to me how exactly it's suposed to be (yeah, I know, I'm dumb.)
Title: Re: HOTSPOTNAME on cursor
Post by: BorisZ on Sun 10/07/2005 22:02:41
Quote from: guybrush on Sun 10/07/2005 19:22:27
Yeah. I've copyed it to global script just like (where) you said, but there's always some error messages I don't wanna. Could you explain it to me how exactly it's suposed to be (yeah, I know, I'm dumb.)

What error message? Check your braces ([{...
Title: Re: HOTSPOTNAME on cursor
Post by: guybrush on Tue 12/07/2005 19:06:53
HOLY COW! It works. I just tried again and it works perfectly. Thank both of you, It looks perfect! ohhh i'm so cool.
Title: Re: HOTSPOTNAME on cursor
Post by: guybrush on Thu 14/07/2005 18:46:02
OK, now I have a new problem. Is there some script function that will remove that hotspot name after entering a room? Because I have some guys in the car, in which the player can't move or anything, just talk. And there's a big characher name next to him, guess that's because cursor is on him when the room loads. Soo?
Title: Re: HOTSPOTNAME on cursor
Post by: guybrush on Wed 20/07/2005 19:36:33
Everything is quite good with your all that and all. That. But now i need some kind of function which will remove hotspot name, because it stays, even in the cutscene. And it gets mixed up with character text, so you know.
Title: Re: HOTSPOTNAME on cursor
Post by: strazer on Thu 21/07/2005 01:26:29
Which of the two suggested solutions are you using?

If you use largopredator's overlay, doesn't
  RemoveOverlay(Over);
work?
Title: Re: HOTSPOTNAME on cursor
Post by: guybrush on Fri 22/07/2005 19:02:57
Quote from: strazer on Thu 21/07/2005 01:26:29
Which of the two suggested solutions are you using?

If you use largopredator's overlay, doesn't
Ã,  RemoveOverlay(Over);
work?

Yes, largopredator's.
Don't know, I didn't try. Is this a function for global script?
Title: Re: HOTSPOTNAME on cursor
Post by: strazer on Fri 22/07/2005 19:08:48
No, put it in the "Player enters screen (before fadein)" interaction of the room ("i" button -> "Player enters..." -> "Run script" -> "Edit script...").
Title: Re: HOTSPOTNAME on cursor
Post by: guybrush on Sat 23/07/2005 11:51:17
OK, but is there a global script function which will remove the name automaticly when "Wait" is on? I mean, so i don't have to turn it off every time player enters the room. If not, thanks anyway.
Title: Re: HOTSPOTNAME on cursor
Post by: hedgefield on Sat 23/07/2005 12:56:44
I still haven't figured it out completely, but what might help you along is this script:
-------------------------------------------------------------------------------------------------------
#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(int button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == LEFT) {
    RemoveOverlay (Over);
    ProcessClick(mouse.x, mouse.y, GetCursorMode() );
GetLocationName (mouse.x,mouse.y,Name);
Over=CreateTextOverlay(mouse.x-25,mouse.y-18,100,1,15,Name);
  }
-------------------------------------------------------------------------------------------------------
The italic lines have to be added, the rest should already be there.

It's not exactly what you meant, but it's very useful during interactions. I've seen this only fixes the issue(aka removes the overlay) for hotspots that rely on room messages. With objects, characters, global messages and scripted interactions it doesn't work. I'm still working on it...

What Strazer suggested should help your particular problem though. Just remember to re-enable the overlay once the sequence is finished, like I did in the script above.
Title: Re: HOTSPOTNAME on cursor
Post by: strazer on Sat 23/07/2005 16:51:13
Or try this:


function repeatedly_execute() {

  if (IsOverlayValid(Over)) {
    if (IsInterfaceEnabled()) GetLocationName(mouse.x, mouse.y, Name);
    else StrCopy(Name, "");
    SetTextOverlay(Over, mouse.x-25, mouse.y-18, 100, 1, 15, Name);
  }

}
Title: Re: HOTSPOTNAME on cursor
Post by: guybrush on Sun 24/07/2005 10:22:38
Quote from: strazer on Sat 23/07/2005 16:51:13
Or try this:


function repeatedly_execute() {

Ã,  if (IsOverlayValid(Over)) {
Ã,  Ã,  if (IsInterfaceEnabled()) GetLocationName(mouse.x, mouse.y, Name);
Ã,  Ã,  else StrCopy(Name, "");
Ã,  Ã,  SetTextOverlay(Over, mouse.x-25, mouse.y-18, 100, 1, 15, Name);
Ã,  }

}


Hmm, I've tried that, but I'm afraid it doesn't work.
Largopredator, I'll try yours too.
Title: Re: HOTSPOTNAME on cursor
Post by: hedgefield on Sun 24/07/2005 10:58:20
Didn't work for me either. I've tried different versions, even checking the getmousecursor() == 7. No dice.

Guess I'll just have to add the extra lines in every script in my game aswell. It's the only way to disable the overlay during every interaction. That or rescripting the entire thing some other way.
Title: Re: HOTSPOTNAME on cursor
Post by: guybrush on Sun 24/07/2005 15:08:07
Thnx a lot guys! You've been really helpful.
Title: Re: HOTSPOTNAME on cursor
Post by: strazer on Sun 24/07/2005 17:06:07
Oh yeah, sorry, the repeatedly_execute function doesn't run when the game is blocked, only repeatedly_execute_always does.
So just try changing
  function repeatedly_execute() {
to
  function repeatedly_execute_always() {
Title: Re: HOTSPOTNAME on cursor
Post by: hedgefield on Sun 24/07/2005 18:29:47
with the _always addition, the overlay only updates when you switch cursor mode. It doesn't follow the mouse anymore. It does remove it during interactions though.
Title: Re: HOTSPOTNAME on cursor
Post by: strazer on Mon 25/07/2005 00:41:43
Strange, works great for me together with the code from your first post.