Help on displaying text as mouse moves over hotspot

Started by Paoul, Sat 21/03/2009 19:51:38

Previous topic - Next topic

Paoul

I want the text of what the object or hotspot is to display at the bottom and then disappear once the mouse moves away. Any ideas?

Thanks and sorry if this is easy and obvious

GarageGothic

It's very easy in fact, but somewhat hidden in the manual. Simply make a GUI with a label on it and set the label text to "@OVERHOTSPOT@" (without quotation marks). In-game this will be substituted with the name of whatever the cursor is hovering over.

Paoul


magintz

On a side note you can also use this with a formatted String if you later wish to have the status line be updated with a context sensitive action such as this:

Code: ags

if (mouse.Mode == 4 && (GetLocationType(mouse.x,  mouse.y) == eLocationHotspot)
  label.Text = String.Format("Use %s with @OVERHOTSPOT@", player.ActiveInventory.Name);
else if(mouse.Mode == 4 && GetLocationType(mouse.x,  mouse.y) == eLocationNothing)
  label.Text = "";


This is just checking to see whether the user is holding an inventory item (mouse.Mode == 4) and if the cursor is over a hotspot (eLocationHotspot). GetLocationType can be an object or a character as well and for these you could also set these for "Give item to character". The else if statement just clears the label if the mouse isn't over anything.

While I'm at it I'll let you know that String.Format let's you mix variables in with a string. The %s is used as a substitute for a string and %d can be used for digits etc... It will substitute the %s with items listed after commas. String.Format("%s %s %s", "one", "two", "three") will print "one two three".

I doubt it will help but thought it might be an interesting thing to post if you should need to do anything further with @overhotspot@ or other over hotspot commands which would need a manual script. Got nothing else to do this evening so I'm sure it might help someone eventually :)
When I was a little kid we had a sand box. It was a quicksand box. I was an only child... eventually.

SMF spam blocked by CleanTalk