Disabling OverHotspot (Solved)

Started by Volcan, Tue 11/06/2013 17:12:44

Previous topic - Next topic

Volcan

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?

Phemar

I'm not entirely sure what you're asking. Could you perhaps clarify a bit more?

Ryan Timothy B

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
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).

Crimson Wizard

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

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

Ryan Timothy B

Don't forget your i++ Crimson.  :-D

Crimson Wizard

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.

Volcan

#6
To Ryan:
Hover.Visible = false; works fine.

To Crimson Wizard:
I got DisableHotspot: invalid Hotspot specified



Here the code:
Code: AGS
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.

Phemar

This could work.

Code: AGS
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;
}

Volcan

#8
Phemar. Your code is not working. I still get the same message.

Code: AGS

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.

Crimson Wizard

#9
Oh my.
It should start with 1. :) Hotspot 0 is "no hotspot".

Code: ags

 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).

Khris

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.

Volcan

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

 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.

Ryan Timothy B

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.

Volcan

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.

Crimson Wizard

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.

Volcan

Changing the label? Yeah! I can do that.

Thank you.

Ryan Timothy B

That's really funny, I swear I suggested that already...

Quote from: Ryan Timothy on Tue 11/06/2013 17:50:49
Code: ags
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.

Volcan

#17
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
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
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
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
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.

Ryan Timothy B

IsInterfaceEnabled still returns true when the game is paused? AGS, you are odd. Alright, try this instead then:

Code: ags
function repeatedly_execute_always() {
  if (IsInterfaceEnabled() && !IsGamePaused()) Hover.Visible = true;
    else Hover.Visible = false;
}

Volcan

It works!!!!!!!

I checked all the guis availables. Your code works.


Thank you

SMF spam blocked by CleanTalk