Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Volcan on Tue 11/06/2013 17:12:44

Title: Disabling OverHotspot (Solved)
Post by: Volcan on Tue 11/06/2013 17:12:44
I noted that HOVERHOTSPOT still enabled when guis are displayed.

Is there a better way to disable hotspots than this?

hotspot[1].Enabled = false;
hotspot[2].Enabled = false;
hotspot[3].Enabled = false;
...


And how to disable when a cursor points to characters?
Title: Re: Disabling Hotspots
Post by: Phemar on Tue 11/06/2013 17:45:41
I'm not entirely sure what you're asking. Could you perhaps clarify a bit more?
Title: Re: Disabling Hotspots
Post by: Ryan Timothy B on Tue 11/06/2013 17:50:49
Are you asking why the @OVERHOTSPOT@ still shows when the game is blocking or pausing GUI's are shown? You have to disable it yourself.

The easiest method in rep ex always:
Code (ags) Select
function repeatedly_execute_always() {
  if (IsInterfaceEnabled()) Hover.Visible = true;
    else Hover.Visible = false;
}

Where "Hover" is the name of either the Label with @OVERHOTSPOT@ or the GUI containing it (whatever works best for your game).
Title: Re: Disabling Hotspots
Post by: Crimson Wizard on Tue 11/06/2013 17:54:46
Quote from: Volcan on Tue 11/06/2013 17:12:44
Is there a better way to disable hotspots than this?

hotspot[1].Enabled = false;
hotspot[2].Enabled = false;
hotspot[3].Enabled = false;
...
If you mean - disable them all, or certain amount at once, then you are looking for Loops:
Code (ags) Select

int i = 0;
while (i < 50) // since there are 50 hotspots max
{
  hotspot[i].Enabled = false;
  i++;
}
Title: Re: Disabling Hotspots
Post by: Ryan Timothy B on Tue 11/06/2013 17:55:35
Don't forget your i++ Crimson.  :-D
Title: Re: Disabling Hotspots
Post by: Crimson Wizard on Tue 11/06/2013 17:56:48
Quote from: Ryan Timothy on Tue 11/06/2013 17:55:35
Don't forget your i++ Crimson.  :-D

Argh, I wasn't fast enough :P.
I keep forgetting this, because I use "for" loops in C++, and they have ++ part in the header.
Title: Re: Disabling Hotspots
Post by: Volcan on Tue 11/06/2013 19:28:10
To Ryan:
Hover.Visible = false; works fine.

To Crimson Wizard:
I got DisableHotspot: invalid Hotspot specified

(http://www.atariage.com/forums/gallery_ips/gallery/album_185/gallery_1196_185_5986.png)

Here the code:
Code (AGS) Select
function btnIconExit_Click(GUIControl *control, MouseButton button) {
gIconbar.Visible = false;
int i = 0;
while (i < 50) // since there are 50 hotspots max
{
  hotspot[i].Enabled = false;
  i++;
}
gQuitter.Visible = true;
}


Hover.Visible = false; seems to disable hotspots anyway.
Title: Re: Disabling Hotspots
Post by: Phemar on Tue 11/06/2013 19:54:14
This could work.

Code (AGS) Select
function btnIconExit_Click(GUIControl *control, MouseButton button) {
gIconbar.Visible = false;
int i = 0;
while (i < 50) // since there are 50 hotspots max
{
  if (hotspot[i])
    hotspot[i].Enabled = false;
  i++;
}
gQuitter.Visible = true;
}
Title: Re: Disabling Hotspots
Post by: Volcan on Tue 11/06/2013 20:21:28
Phemar. Your code is not working. I still get the same message.

Code (AGS) Select

function btnIconExit_Click(GUIControl *control, MouseButton button) {
gIconbar.Visible = false;
int i = 0;
while (i < 50) // since there are 50 hotspots max
{
  if (hotspot[i]) // <--- Doublehotspot: invalid hotspot specified
   hotspot[i].Enabled = false;
  i++;
}
gQuitter.Visible = true;
}


Please check the line 6.
Title: Re: Disabling Hotspots
Post by: Crimson Wizard on Tue 11/06/2013 20:56:03
Oh my.
It should start with 1. :) Hotspot 0 is "no hotspot".

Code (ags) Select

int i = 1;
while (i < 50) // since there are 50 hotspots max
{
  hotspot[i].Enabled = false;
  i++;
}


PS. No "if (hotspot[ i ])" check is not needed, because there's always 50 (49) hotspots in 3.2.1 (even though most could be unused).
Title: Re: Disabling Hotspots
Post by: Khris on Tue 11/06/2013 21:01:14
Volcan, could you explain what you're trying to do?
I imagine there's a situation like the character's being tied to a chair and can't interact with anything or something of that sort.
Whatever it is, I'm positive that there is a MUCH better way to handle this.
Title: Re: Disabling Hotspots
Post by: Volcan on Tue 11/06/2013 21:10:58
Quote from: Crimson Wizard on Tue 11/06/2013 20:56:03
Oh my.
It should start with 1. :) Hotspot 0 is "no hotspot".

Code (ags) Select

int i = 1;
while (i < 50) // since there are 50 hotspots max
{
  hotspot[i].Enabled = false;
  i++;
}


PS. No "if (hotspot[ i ])" check is not needed, because there's always 50 (49) hotspots in 3.2.1 (even though most could be unused).

It works. Thank you.

To Khris:
Nevermind. Everything is fine. Thanks anyway.
Title: Re: Disabling Hotspots (Solved)
Post by: Ryan Timothy B on Wed 12/06/2013 00:34:38
Everything is fine, yes, but if you would like the best solution to your problem then you should tell us what you're doing.

But from reading your code, you're pressing the exit button and have a Quit GUI pop up. Therefore you're using the wrong solution.

You want to set the GUI as pause game when shown. That should be the only solution you need. You wouldn't need to disable hotspots, objects, or characters.
Title: Re: Disabling OverHotspot (Solved)
Post by: Volcan on Wed 12/06/2013 14:22:18
Quote from: Ryan Timothy on Wed 12/06/2013 00:34:38
Everything is fine, yes, but if you would like the best solution to your problem then you should tell us what you're doing.

But from reading your code, you're pressing the exit button and have a Quit GUI pop up. Therefore you're using the wrong solution.

You want to set the GUI as pause game when shown. That should be the only solution you need. You wouldn't need to disable hotspots, objects, or characters.

You're right. I made a custom Quit gui. Even if the gui has "Pause game whem showed" selected (Quitter means Quit in French), overhotspot is still working and I want to disable it. I will apply with other guis as well.
Title: Re: Disabling OverHotspot (Solved)
Post by: Crimson Wizard on Wed 12/06/2013 14:27:07
Ah, so you need a label which displays hotspot name to be hidden when gui is shown?
In such case you may simply hide the label overhotspost information is printed on, and show it again later when gui was closed.
Title: Re: Disabling OverHotspot (Solved)
Post by: Volcan on Wed 12/06/2013 14:45:27
Changing the label? Yeah! I can do that.

Thank you.
Title: Re: Disabling Hotspots
Post by: Ryan Timothy B on Wed 12/06/2013 15:34:38
That's really funny, I swear I suggested that already...

Quote from: Ryan Timothy on Tue 11/06/2013 17:50:49
Code (ags) Select
function repeatedly_execute_always() {
  if (IsInterfaceEnabled()) Hover.Visible = true;
    else Hover.Visible = false;
}


Always inform us what you're attempting to do because there's generally always a better way than what a beginner scripter thinks they need to do.
Title: Re: Disabling OverHotspot (Solved)
Post by: Volcan on Wed 12/06/2013 16:50:30
Quote from: Ryan Timothy on Wed 12/06/2013 15:34:38
That's really funny, I swear I suggested that already...

Quote from: Ryan Timothy on Tue 11/06/2013 17:50:49
Code (ags) Select
function repeatedly_execute_always() {
  if (IsInterfaceEnabled()) Hover.Visible = true;
    else Hover.Visible = false;
}


Always inform us what you're attempting to do because there's generally always a better way than what a beginner scripter thinks they need to do.

I tried your code:

Code (AGS) Select
function repeatedly_execute_always() {
 
  // Put anything you want to happen every game cycle, even
  // when the game is blocked inside a command like a
  // blocking Walk().
  // You cannot run blocking commands from this function.
  if (IsInterfaceEnabled()) Testing.Visible = true;
   else Testing.Visible = false;
}


The custom Quit gui:
Code (AGS) Select
function btnIconExit_Click(GUIControl *control, MouseButton button) {
gIconbar.Visible = false;
gQuitter.Visible = true;
}


The Overhotspot still works.

Buf if I add a code to the custom Quit gui,

Code (AGS) Select
function btnIconExit_Click(GUIControl *control, MouseButton button) {
gIconbar.Visible = false;
Testing.Visible = false;
gQuitter.Visible = true;
}


The overhotspot is disabled until it's enabled again.

I don't even need to disable all hotspots I thought.
Title: Re: Disabling OverHotspot (Solved)
Post by: Ryan Timothy B on Wed 12/06/2013 17:04:13
IsInterfaceEnabled still returns true when the game is paused? AGS, you are odd. Alright, try this instead then:

Code (ags) Select
function repeatedly_execute_always() {
  if (IsInterfaceEnabled() && !IsGamePaused()) Hover.Visible = true;
    else Hover.Visible = false;
}
Title: Re: Disabling OverHotspot (Solved)
Post by: Volcan on Wed 12/06/2013 17:19:04
It works!!!!!!!

I checked all the guis availables. Your code works.


Thank you