Ok. My personal two favorite adventure games are Discworld 1 and 2. In them, when you rolled over a thing you could look at or interact with (even a person or item) it would display a piece of text over the object (like if I were looking at a house, rolling the mouse over the house would make the words "house" appear in the middle of the house hotspot)
I want to emulate this. How? ???
Create a new GUI, put a Label control on it, change the label's text to @OVERHOTSPOT@, uncheck the GUI's "Clickable" checkbox and put
SetGUIPosition(THENEWGUISNAME, mouse.x, mouse.y);
in the repeatedly_execute function (menu "Script" -> "repeatedly_execute").
This has been asked many times before, try a forum search (http://www.adventuregamestudio.co.uk/yabb/index.php?action=search) next time.
Oh, and Welcome to the forums! :)
That's not really what I asked for. I want to have the text at a specific place on the hot spot when I roll over it, not moving with the mouse.
And I did search. I found nothing so I posted. :)
Ah, I didn't know Discworld does it like that.
Ok, then I would do all of the above except the rep_ex part, then:
Create two custom number properties, for example "descx" and "descy" where you can enter where the GUI should appear for each hotspot/character/object, then in repeatedly_execute:
//...
int newguix, newguiy; // declare variables that will hold the GUI's new position
int overwhat = GetLocationType(mouse.x, mouse.y); // get what the mouse cursor is over
if (overwhat == 1) { // if mouse is over a hotspot
// get this hotspot's gui position values from its properties:
newguix = GetHotspotProperty(GetHotspotAt(mouse.x, mouse.y), "descx");
newguiy = GetHotspotProperty(GetHotspotAt(mouse.x, mouse.y), "descy");
}
else if (overwhat == 2) { // if mouse is over a character
newguix = GetCharacterProperty(GetCharacterAt(mouse.x, mouse.y), "descx");
newguiy = GetCharacterProperty(GetCharacterAt(mouse.x, mouse.y), "descy");
}
else if (overwhat == 3) { // if mouse is over an object
newguix = GetObjectProperty(GetObjectAt(mouse.x, mouse.y), "descx");
newguiy = GetObjectProperty(GetObjectAt(mouse.x, mouse.y), "descy");
}
SetGUIPosition(THENEWGUISNAME, newguix, newguiy);
//...
Edit: Fixed typos, added indentation.
How do I get it to display OVER the hotspot rather than at the top-left of the screen?
EDIT:
I've done it. Just modify the two numbers on the box after you click off the "properties box, right? Thanks a million. ;D
Hm, since objects and characters can move around, it's probably better not to use fixed positions for the gui but rather use descx/descy as offsets from the object's/character's current position, i.e.:
//...
else if (overwhat == 2) { // if mouse is over a character
int charid = GetCharacterAt(mouse.x, mouse.y);
newguix = character[charid].x + (GetCharacterProperty(thechar, "descx"));
newguiy = character[charid].y + (GetCharacterProperty(GetCharacterAt(mouse.x, mouse.y), "descy"));
}
else if (overwhat == 3) { // if mouse is over an object
int objid = GetObjectAt(mouse.x, mouse.y);
newguix = GetObjectX(objid) + (GetObjectProperty(objid, "descx"));
newguiy = GetObjectY(objid) + (GetObjectProperty(objid, "descy"));
}
//...
Edit: Added code for objects.
So, In total:
int newguix, newguiy; // declare variables that will hold the GUI's new position
int overwhat = GetLocationType(mouse.x, mouse.y); // get what the mouse cursor is over
if (overwhat == 1) { // if mouse is over a hotspot
// get this hotspot's gui position values from its properties:
newguix = GetHotspotProperty(GetHotspotAt(mouse.x, mouse.y), "descx");
newguiy = GetHotspotProperty(GetHotspotAt(mouse.x, mouse.y), "descy");
}
else if (overwhat == 2) { // if mouse is over a character
int charid = GetCharacterAt(mouse.x, mouse.y);
newguix = character[charid].x + (GetCharacterProperty(GetCharacterAt(mouse.x, mouse.y), "descx"));
newguiy = character[charid].y + (GetCharacterProperty(GetCharacterAt(mouse.x, mouse.y), "descy"));
}
else if (overwhat == 3) { // if mouse is over an object
int objid = GetObjectAt(mouse.x, mouse.y);
newguix = GetObjectX(objid) + (GetObjectProperty(objid, "descx"));
newguiy = GetObjectY(objid) + (GetObjectProperty(objid, "descy"));
}
SetGUIPosition(THEGUINAME, newguix, newguiy);
Also, the Description module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26306.0) now does something liek this with its "Sticky" mode. If anyone would like a different functionality to be more Discworldly, please let me know details...