Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: on Mon 16/02/2004 16:27:42

Title: Code script when mouse is over hotspot
Post by: on Mon 16/02/2004 16:27:42
Hey guys! Can you help me with my game. I want to know how i can get a text when mouse goes over a hotspot. Can you tell!?!  :-\
Title: Re:Code script when mouse is over hotspot
Post by: Akumayo on Mon 16/02/2004 18:01:01
After you have drawn your hotspot.  Click on interactions.  Then select "mouse moves over hotspot".  Click on the down arrow to open the menu.  Select "Game-Display a Message" Click "Change", then enter the message number. Click "Edit Message", and there type in the message text. Click "Okay", then "Close".  Now when you move the mouse over the hotspot it will say "(whatever you told it to)".  


Title: Re:Code script when mouse is over hotspot
Post by: Kweepa on Mon 16/02/2004 18:28:40
I presume he wanted to know how to write the name of the hotspot next to the mouse pointer or in a status line.
There are a bunch of threads like this - try a search.

Put this in repeatedly execute:
string name;
GetLocationName(mouse.x, mouse.y, name);
SetLabelText(STATUSLINE, 0, name);
Title: Re:Code script when mouse is over hotspot
Post by: Ben on Mon 16/02/2004 20:32:14
Why doesn't anyone ever do anything the easy way?  :P

Just create a new GUI and add a label, then enter @OVERHOTSPOT@ for the text.
Title: Re:Code script when mouse is over hotspot
Post by: Kweepa on Mon 16/02/2004 22:28:07
And then you want to position the text...
And then you want to add "Walk to", "Talk to"...
:)
Title: Re:Code script when mouse is over hotspot
Post by: SSH on Tue 17/02/2004 12:37:45
I know this works becuase its what is in my game...

You'll need a GUI called TOOLTIP with object 0 a text label...

int ttt; // tooltip transparency
string oldloc;

function repeatedly_execute() {

 // Set tooltip
 string locname;
 GetLocationName(mouse.x, mouse.y, locname);
 if (StrLen(locname)==0) {
   int invat=GetInvAt(mouse.x, mouse.y);
   if (invat>0) GetInvName(invat, locname);
 }

 if (StrComp(locname, oldloc)==0) {
   if (ttt>0) ttt--;
 } else {
   ttt=200;
 }  
 StrCopy(oldloc, locname);
 
 if ((ttt>100) || StrLen(locname)==0) {
   GUIOff(TOOLTIP);
 } else {
   int ttx,tty;
   ttx=mouse.x+10;
   tty=mouse.y-10;
   GUIOn(TOOLTIP);
   if (mouse.y<50) {
     tty=mouse.y+10;
   }
   if (mouse.x>260) {
     ttx=mouse.x-30;
   }
   SetGUIPosition(TOOLTIP, ttx, tty);
   SetLabelText(TOOLTIP, 0, locname);
   SetGUITransparency(TOOLTIP,ttt);
 }



hmmm, needs some more comments!
Title: Re:Code script when mouse is over hotspot
Post by: on Tue 17/02/2004 15:53:45
Hey that works! Thanks Guys ;D