Text over hotspot

Started by Bender86, Thu 22/05/2003 11:58:44

Previous topic - Next topic

Bender86

I had a nice idea that i've seen in a game once before, which is that when the mouse hovers over a hotspot, text appears over that hotspot. When the mouse moves away, the text dissappears.

I've tried CreateTextOverlay (2,91,100,1,2,"Umbrella");
kind commands, but haven't had much look.

Has anyone done this kind of thing before and now an easy way to achieve it?

Thanx :)
-This message will self destruct in 5 seconds-

Ishmael

I havent seen this system, but

I think 1 way to get this done is to create a GUI, lets say now we have it GUI 4, make it say 50 wide and 13 high, put a label into it that fills the whole area, and set the align to centre. Then in the global rep_ex:

if (GetHotspotAt(mouse.x,mouse.y)>0) {
 SetLabelText(4,0,GetLocationName(mouse.x,mouse.y));
 SetGUIPositon(mouse.x-30,mouse.y);
 GUIOn(4);
} else {
 GUIOff(4);
}

Any chance?
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

AJA

#2
Spyros has made a plugin for this. It's very simple, but it works... Though I guess you can't find it anywhere anymore. At least it can't be found on the plugins page.

But....

CreateTextOverlay (int x, int y, int width, int font, int color, string text);
GetLocationType (int x, int y);
GetLocationName (int x, int y, string buffer);

So, what if (to the repeatedly_execute function of the room/global script*)...

string buffer;    // Put this to the top of the room/global script
if (GetLocationType(mouse.x,mouse.y)>0){  //if the mouse is over something
   GetLocationName(mouse.x,mouse.y,buffer);
   CreateTextOverlay(mouse.x+10,mouse.y+10,50,1,15,buffer);
}

*) Choose repeatedly_execute of the global script if you want the text to appear anywhere in the game, room script if you want it to appear only in a single room

-EDIT-

Okay, forget that... here's the working one (to the repeatedly_execute function):

if (GetLocationType(mouse.x,mouse.y)>0){  //if the mouse is over something
 if (checker == 0){
   GetLocationName(mouse.x,mouse.y,buffer);
   overlay = CreateTextOverlay(mouse.x+15,mouse.y+15,50,1,15,buffer);
   checker = 1;
   removed = 0;
 }
 MoveOverlay(overlay,mouse.x,mouse.y);
} else if (removed==0) {
   checker = 0;
   RemoveOverlay(overlay);
   removed = 1;
}

Remember to put these to the global/room scripts top:
int removed, checker, overlay;
string buffer;

Scorpiorus

QuoteSpyros has made a plugin for this. It's very simple, but it works... Though I guess you can't find it anywhere anymore. At least it can't be found on the plugins page.
It was Sylpher I think :)

AJA

#4
Whoops in that case... my mistake... Too similar names... :)

Spyros

I have made a system like this for the maps in BOS4, but with scripting, no plugin :)

Bender86

Hmm..I've added that code and sorted out the strings and integers, but no text is appearing.. ??? I don't know what the problem could be...
-This message will self destruct in 5 seconds-

Ishmael

#7
if (GetLocationType(mouse.x,mouse.y)>0) {
 SetLabelText(4,0,"@OVERHOTSPOT@");
 SetGUIPositon(mouse.x+13,mouse.y);
 GUIOn(4);
} else {
 GUIOff(4);
}
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

AJA

http://koti.mbnet.fi/dima/downloads/example.zip

There's an example. It's a fixed version of the one I posted here.

Bender86

I've sorted it now, using Tk's method, which is very effective. Thanx a lot guys for the help :)
-This message will self destruct in 5 seconds-

SMF spam blocked by CleanTalk