Displaying name on curser over hotspot

Started by Revan, Thu 09/02/2006 12:32:40

Previous topic - Next topic

Revan

Hi, was just wondering how you would be able to place the curser over a hotspot or object and make it display a msg under the curser with the name of the object etc. and how to make it so it doesn't pause the gameplay.... thanks

Khris

Please search the forums before asking a question that has been answered 1000 times before.

Revan

#2
ok i searched the forums and manuel, found out to make a GUI with the lable
@OverHotspot@ , that I have done... I am writing the code for it to be displayed by the curser....

Code: ags
function repeatedly_execute() {
Ã,  // put anything you want to happen every game cycle here
 GUI3.SetPosition(mouse.x, mouse.y);
}


allthough it says that is invalid code, and I'm not sure what else to do...

It says expeted semi colon after ] but I have done that havn't I?


EDIT: ok I'm using different code,

Code: ags
function repeatedly_execute() {
Ã,  // put anything you want to happen every game cycle here
Ã,  if (Game.GetLocationName(mouse.x, mouse.y) != "")
Ã,  Ã,  overhotspot.Text = Game.GetLocationName(mouse.x, mouse.y);
Ã,  else overhotspot.Text = " ";
}


It displays what I want but it isn't folowing the mouse around, it's up in the top corner... how do i get it to folloe the mouse (I thought it was in the code that was writen)

strazer

Just add some code to place the GUI at the mouse coordinates, it's not that hard:

Code: ags

  overhotspot.OwningGUI.SetPosition(mouse.x, mouse.y);


Make sure to remove the "Clickable" checkbox from the GUI so it doesn't interfere with mouse clicks.

You can also try the OverHot module: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23328.0

Revan

ok done Thankyou... Just one little thing;Ã,  if an object is close to the ground how do i make it so the lable shows above the curser (But as a standard for items at cretain coordanates... (It would hapen to hotspots top right aswell...) By the way I'm no coder, at all! lol

strazer

Code: ags

  if ((YourGUI.Y + YourGUI.Height) > system.viewport_height)
    YourGUI.Y = system.viewport_height - YourGUI.Height;

  if ((YourGUI.X + YourGUI.Width) > system.viewport_width)
    YourGUI.X = system.viewport_width - YourGUI.Width;


Have you tried the OverHot module?

Revan

#6
Quote from: strazer on Thu 09/02/2006 15:27:54
Have you tried the OverHot module?

yeah i downloaded it but it said that string was not used anymore or something... so I didn't use it........

added your latest code but it justs moves all @overhotspot@ gui's to the left of the screen (They moove up and down with the mouse, but stay at the left)

strazer

What's your GUI's width?

And are you sure you've used the latest version (1.12) of the OverHot module? I have clarified the announcement post a bit.

Revan

lol no i didnt lol, downloaded it now.... it's good, just 1 thing.... the message displays under my inventory GUI....

strazer

Hm, yeah, that's because it uses an overlay and those are covered up by GUIs. But looking at the module's script (menu "Script" -> "Module manager...") should at least give you a few hints.

As for your GUI approach, please post the complete rep_ex script you're using.

SMF spam blocked by CleanTalk