Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Dudeman Thingface on Mon 10/11/2008 22:01:39

Title: Hotspot Text Hover (SOLVED)
Post by: Dudeman Thingface on Mon 10/11/2008 22:01:39
I'm attempting to make hotspots whose names appear in the style of COMI; that is, there is one location (usually bottom center of the screen) which the names for hotspots/items etc. appear when the mouse rolls over them.

I've been looking in the manual and searching the forums but I lack the technical experience with AGS to fully comprehend how to script what I want. I do, but I don't know what to do, allow me to explain;

I understand (or, at the very least, am aware) that I will need to use these commands, or the concept of these commands:

1) String Label.Text;

Gets/sets the text displayed in the specified label. This allows you to change the text during the game, for example to create a Lucasarts-style status line.

Example:

lblStatus.Text = Game.GetLocationName(mouse.x, mouse.y);
will display the name of the location the cursor is over on label 'lblStatus'

2) Interface text

You can easily display static text on interfaces. For example, the Sierra-style interface displays the score in the status bar.
To add text to a GUI, you add a label. Click the "Add label" button, then drag out a rectangle like you did when adding a button. You can change the text displayed in the label by editing the "Text" property. Notice that the text automatically wraps around to fit inside the rectangle you drew.
As well as typing normal text into the label, you can add some special markers which allow the text to change during the game. The following tokens will be replaced with the relevant values in the game:

@GAMENAME@ The game's name, specified on the Game Settings pane
@OVERHOTSPOT@ Name of the hotspot which the cursor is over
@SCORE@ The player's current score (number only)
@SCORETEXT@ The text "Score: X of Y" with the relevant numbers filled in.

@TOTALSCORE@ The maximum possible score, specified on the Game Settings pane
Example: You have @SCORE@ out of @TOTALSCORE@ possible points.

The Properties window also allows you to align the text to the left, right, or centre, as well as change its font and colour.

I may understand the concept of these ideas, but I don't their implementation. I don't know where to put them (Global or room script) or how to make it work (namely, which function will make it go when I want it to). In particular, for number 2, I have no idea where to put @OVERHOTSPOT@, or refer back to the interface text.

I thought that maybe the Description (http://www.americangirlscouts.org/agswiki/Description_Module) module may help. Unfortunantly, once looking at the documentation for it, I came to the same problem of where (Global or room) and how (function use).

Although I personally believe I've exhausted all other ways of trying to fix this myself, if there is a tutorial that explains how to do this for me, or there a few manual topics that will clear it up completley, please direct me to them. I don't want you to waste your time repeating something I could've very easily found in the manual.

Otherwise, please help.
Title: Re: Hotspot Text Hover
Post by: Trent R on Mon 10/11/2008 22:06:23
Have you tried looking at the Verbcoin template that comes with AGS?

~Trent
Title: Re: Hotspot Text Hover
Post by: Dudeman Thingface on Mon 10/11/2008 22:39:21
I did look at the verbcoin template, just then.

I now understand where you put the @hotspot@, however, I'm still rather confused as to how it all comes together in the global script.

Must I make a seperate script to the global script and make hotspot text hover ... somehow, from there (as per the VerbCoin template)?

Why is it that the VerbCoin template needs no reference to hotspot hover text in the room script?
Is there one (or a few) very simple lines of text that I missed in the other scripts?
Title: Re: Hotspot Text Hover
Post by: monkey0506 on Mon 10/11/2008 22:50:39
You could simply use a GUI Label and in the Properties window set its text property to @OVERHOTSPOT@.

To do it from the script (which you can do at any time within a function be it in the global or the room script) reference the label's name and text property:

// must be inside a function!
lblHotspot.Text = "@OVERHOTSPOT@";


Where lblHotspot is the name of your label.

It's not necessary to create a separate script, this is available primarily to prevent any one script getting cluttered. The global script is a fine place for this line to go. ;)

Specifically, the game_start function would be a reasonable place for the script. But really you can just set it in the properties window.

The Description module does automatically handle a lot of other things such as using inventory items as well. For that you could do this:

Description.Location = eDescLocationSticky;
Description.VerbMode = eDescVerbModeUseOnly;
Description.OLColor = 65000;
Description.OverlayMode();


Again, in the game_start function. ;)
Title: Re: Hotspot Text Hover
Post by: Dudeman Thingface on Tue 11/11/2008 01:36:25
 ;DAhahahahahaaaaaa!

Thank you both muchlyness. You've both been a big help, I will remember this.