Hotspot labels

Started by CodeJunkie, Thu 26/02/2004 22:12:07

Previous topic - Next topic

CodeJunkie

I've had a skim around the tutorials and the help manual but I couldn't find how to fix my problem, sorry if it was in there and I've missed it.
I want to make text labels that hover near the mouse cursor when it is over a hotspot, like in the Discworld games (and others I'm sure).
I've made the program run a script when 'Mouse moves over hotspot'.  Here's what I have:

DisplaySpeechAt(mouse.x+10, mouse.y-10, 300, JAMES, "Maintenance Door");

I've noticed that while this is near the mouse cursor, you have to click the mouse button to make it disappear, and then it will promptly reappear.  I would also assume that the character's talking animation will run when I use this (I haven't reached that stage yet).  I've seen that DisplaySpeechBackground won't interrupt the game and it won't start the talking animation, but there aren't any parameters for mouse.x and mouse.y
Thanks in advance.

Darth Mandarb

Here's how I do this (though I've found it clunky)

I set up the hotspots how I want them, then I put an all surrounding hotspot (usually white, 15) that fills the whole screen (except where the other hotspots are of course)

Then I set up a GUI that contains a text label.  Let's say it's GUI(5) and the lable is object(0).

Then, in the mouse moves over hotspot, I run script:
[color=00aa00]// mouse moves over hotspot[/color]
EnableHotspot(15);
SetLabelText(5,0,"Description Here");
SetGUIPosition(5,mouse.x,(mouse.y-15));
GUIOn(5);[color=00AA00]
// line 1 turns on the surrounding Hotspot
// line 2 sets the text label to whatever you want
// line 3 positions the GUI relative the mouse's position
// line 4 turns on the GUI[/color]

Then, in the mouse over for hotspot 15 (or whatever hotspot you used to surround the rest)
[color=00aa00]// mouse moves over hotspot[/color]
GUIOff(5);
DisableHotspot(15);[color=00aa00]
// line 1 shuts off the description GUI
// line 2 disables the surrounding hotspot[/color]

This does work, but as I said it can have it's drawbacks.  But maybe it'll show you a way to do it and you can improve on it.

Good luck and I hope it helped.

~ d

Alynn

Why not just make a small transparent non clickable gui that is always on and in your repeatadly execute

SetGUIPosition(GUI, mouse.x + 10, mouse.y + 10);

In the GUI have a single label with text as @overhotspot@ it may take some working with it to get the gui moved to a position you like... but it should work for you (it worked for me)

CodeJunkie

OK, another 2 pretty basic problems concerning the label:

1) How do I 'fill' the inside of a font with a colour (like LucasArts text)?  I can set the colour of the font itself, but I can't see any command for setting the inside colour.  If this isn't possible then how is the LucasArts style text done for the player?

2) For the hovering label I use this in the 'repeatedly_execute':

 SetGUIPosition(LABEL, mouse.x+5, mouse.y-10);

It works great, but the problem is that when the label drawing co-ordinated exceed the screen width or height the game crashes.  Because the label co-ordinates are drawn slightly away from the cursor this can happen when the cursor nears the edge of the screen.

I've tried using 'while' loops to only display the text when the mouse isn't near the edge of the screen:

function repeatedly_execute() {
 //put anything you want to happen every game cycle here
 while (mouse.x <= 235) {
   while (mouse.y >= 10) {
     SetGUIPosition(LABEL, mouse.x+5, mouse.y-10);
   }
 }
}


This however makes the game crash upon loading with this message:

(...)
(ACI version 2.60.698)

Error: run_text_script1: error -6 (Error (line 15): Script appears to be hung (150001 while loop iterations without an update)) running function 'repeatedly_execute'


Using positive numbers for the label position in accordance to the mouse position doesn't work, and neither does:

SetMousePosition(160, 120);


I can't think what else to do with these problems.  Sorry if some of the information is totally useless, I just want to make sure that people reading this know what I've already tried so that they don't post with an unhelpful solution.

Again, thanks in advance

Alynn

#4
While can confuse some people at first... while is a loop statement, so with what you have above you basicly said

if mouse.x is less than or equal to 235 keep repeating the following: if mouse.y is greater than or equal to 10...

BUT you are kinda on the right track

try this

Global Script
int guiX;
int guiY;

in rep ex
guiX = mouse.x + 5;
guiY = mouse.y - 10;
if (guiX >=  235) guiX = mouse.x - 5;
if (guiY >= 10) guiY = mouse.y + 10;
SetGUIPosition(LABEL, guiX, guiY);

as you can see by default it will place the label at mouse.x+5, mouse.y-10... UNLESS the label will be placed off screen, at which point, it will be reversed and placed on the other side of the pointer, keeping it on screen.

CodeJunkie

Hooray, no crashes anymore!
But I've got more problems still.  Maybe I'm not looking hard enough for the answer.  Anyway, here are my questions:

1) The LucasArts hotspot labels (at start of previous post)

2) While the inventory window is on, the hotspots still show up beneath it.  The only useful thing I can find in the help file is DisableHotspot, but it seems very inefficient and would probably slow the game down to disable every hotspot in the game and re-enable them after each time the inventory window is toggled.

Thanks for the replies.  Sorry for all of the newbie questions!

CodeJunkie

Sorry to seem rude by dragging this topic up again, but I was afraid that it would disappear down the list without being answered.  Thanks again though for the replies.

Darth Mandarb

Quote from: SimB on Sun 29/02/2004 11:11:121) The LucasArts hotspot labels (at start of previous post)
I'm sorry, I can't help you with this one and ...

Quote from: SimB on Sun 29/02/2004 11:11:122) While the inventory window is on, the hotspots still show up beneath it.
... I'm afraid I can't help you here either.  But I have this same problem with my game.  At one part, when the inventory GUI is open, you trigger a hotspot under it and the cursor changes and you have to click on Select Item again to get it to actually work!  It's very annoying.

Is there some command to disable ALL hotspots while a GUI is on?  Or a parameter to enter somewhere?  I'd like to know as well.

~ d

Alynn

put this in front of your previous code for the floating labels..

if (IsGUIOn(OTHERGUI) != 1) {//if the gui is off then
GUIOn(LABEL);
//Do all that other code stuff for the label
}
else {// if the other gui is on
GUIOff(LABEL);
}

Now you could just add the GUIOn(LABEL) to the closing of the GUI that you want the labels to turn off on. (In addation for all other guis you just add || (IsGUIOn(STILLANOTHERGUI)!=1) and so on and so forth) but basicly if the gui is on it turns off the label gui (so you will no longer see it)  if the gui is not on it turns on the gui (in case it was off) then does the display stuff that I outlined earlier...

Now as far as the first goes, I don't konw

SMF spam blocked by CleanTalk