HOTSPOTNAME on cursor

Started by guybrush, Tue 05/07/2005 18:40:01

Previous topic - Next topic

guybrush

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.
SPY FUNCTION-- My first game
C O M I N G   S O O N !

monkey0506

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.

hedgefield

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 :)

guybrush

Thanks. So, I just copy this to global script or what?
SPY FUNCTION-- My first game
C O M I N G   S O O N !

monkey0506

Well it's a lot easier to just use a label.

BorisZ

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.

guybrush

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.
SPY FUNCTION-- My first game
C O M I N G   S O O N !

hedgefield

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

monkey0506

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.

guybrush

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.)
SPY FUNCTION-- My first game
C O M I N G   S O O N !

BorisZ

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 ([{...

guybrush

HOLY COW! It works. I just tried again and it works perfectly. Thank both of you, It looks perfect! ohhh i'm so cool.
SPY FUNCTION-- My first game
C O M I N G   S O O N !

guybrush

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?
SPY FUNCTION-- My first game
C O M I N G   S O O N !

guybrush

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.
SPY FUNCTION-- My first game
C O M I N G   S O O N !

strazer

Which of the two suggested solutions are you using?

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

guybrush

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?
SPY FUNCTION-- My first game
C O M I N G   S O O N !

strazer

No, put it in the "Player enters screen (before fadein)" interaction of the room ("i" button -> "Player enters..." -> "Run script" -> "Edit script...").

guybrush

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.
SPY FUNCTION-- My first game
C O M I N G   S O O N !

hedgefield

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

strazer

Or try this:

Code: ags

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);
  }

}

SMF spam blocked by CleanTalk