Disable all hotspots if GUI Visible

Started by subspark, Wed 26/09/2007 02:06:08

Previous topic - Next topic

subspark

How would I go about this?

My pseudo code:
Code: ags
function repeatedly_execute() {
  // put anything you want to happen every game cycle here
int hotspot_ANY=GetHotspotAt(mouse.x,mouse.y);
  if (IsGUIOn(1)==true) {
  hotspot_ANY.Enabled = false;
  }
  else {
    hotspot_ANY.Enabled = true;
  }
}


Problem is, '.Enabled' obviously can't be applied to integers, naturally, and I'm not sure what property I need to define hotspot_ANY under. It's not int and string doesn't work either.

Cheers,
Paul.

Khris

#1
You're mixing old and new code.
Dis/enabling hotspots was done with Dis/EnableHotspot(int);

With current code, it's done this way:
Code: ags
  Hotspot*h=Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  if (gui[1].Visible) h.Enabled=false;
  else h.Enabled=true;


However, it's easier to simply intercept mouse clicks in on_mouse_click.

And, before I forget: RTFM ;)

subspark

Thanks but are you referring to the manual incuded with ags 2.8 betas or do you mean the online one. I've been searching for a number of things in the offline manual and apart from the occasional, badly referenced code example, h.Enabled didn't come up at all. How am i supposed to find that in the darn manual if it simply does not exist. You know what, I've said it before and I'll say it again, the AGS help manual is in desperate need of a re-write. A beter search algorithm would be nice along with all the new script functions and everything else that has been inconveniently left out.

Khris

#3
Wow, chill.

It's right there in the (offline) AGS2.72 manual, called ags-help.chm.

And really easy to find due to it being conveniently located at:
Scripting -> Hotspot functions and properties -> Enabled property

I mean, where else would it be?
And why would you search for "h.Enabled"? h is a variable declared by ME.
You wouldn't search the manual for "hotspot_ANY", would you?

I don't mean to be rude, but it seems to me you're bashing the manual to cover your own ???-ness.

PS: the very very few things that have actually been left out are meant for advanced users only.
And there's a good reason for that, obviously.

subspark

#4
Sorry pal. I didn't mean to be rude. It's just that all this stuff confuses me and it's even more irritating when I've spend 4 days going through manuals not to find a thing that gives me any clue how to write the code. Naturally, I'm asking on the forums because anything in the manual isn't enough for me to problem solve my way through it. I'm pretty good at simple things, like global ints and basic code however writing functions that aren't specifically made an example of in the manual are not my strong points.

Did you say the 2.72 manual? Why should I be reading that if I'm using 2.8? That doesn't make any sense. Is the 2.8 manual not complete? That WOULD make sense.
Terms like 'RTFM' aren't particuarly popular with artists making a good attempt at writing code. Especially after spending days in the manual to no avail.

EDIT: Oops I can see how you got the idea that I was using 2.72. I've imported a 2.72 game in 2.8 and am reworking the code. Sorry for the confusion there, Khris.

Please, no hard feelings. I'm sure it read twice as bad as I meant it. Apologies.

Cheers,
Paul.

Khris

It doesn't matter which manual; the major changes from 2.72 to 2.8 were all made to the editor, the code is still the same, apart from a few additions.
So the newest manual is even more complete than the 2.72 one, plus the whole tutorial section was rewritten.

The thing is, the AGS manual doesn't teach you how to program. It's as simple as that. And that's fine, because it doesn't try and it isn't meant to.

Knowing what every function of Photoshop does won't make you a great artist.
It takes time and practice. It's the same with programming. AGS provides the tools and explains what every one of them does, but it's up to you to know how and when to use them.

subspark

#6
Sure thing. I understand which is why I am posting for help. And I thankyou kindly for offering yours.

BTW, Hotspot*h=Hotspot.GetAtScreenXY(mouse.x, mouse.y); didn't seem to work in my case. It said hotspot h doesn't exist.

Basically I'm writing a small game prototype in AGS so that when I have a few programmers on board we can tackle the really major stuff. Right now I'm simply working on a small piece of what should later be a great adventure. I appreciate any help you can give me.

Thanks, Khris.

Paul.

Khris

Where did you put this code?
What was the exact wording of the error message?

subspark

I think I found a better way to handle this using GetLocationType:
Code: ags
function repeatedly_execute() {
  // put anything you want to happen every game cycle here
  if (gInventory.Visible == true) { // If the Inventory is visible.
    if (GetLocationType(mouse.x,mouse.y)==eLocationHotspot) { // If the mouse if over a hotspot, do nothing.
    }
    else if (mouse.x > 300) { // If the mouse moves off the right hand side of the inventory GUI, fade it out.
      FadeGuiOut_NoBlock(gInventory,100,-15);
      FadeGuiOut_NoBlock(gInventoryback,100,-15);
    }
    else if (mouse.x < 20) { // If the mouse moves off the left hand side of the inventory GUI, fade it out.
      if (mouse.y < 140) {
        FadeGuiOut_NoBlock(gInventory,100,-15);
        FadeGuiOut_NoBlock(gInventoryback,100,-15);
      }
    }
    else if (mouse.y < 10) { // If the mouse moves off top of the inventory GUI, fade it out.
      FadeGuiOut_NoBlock(gInventory,100,-15);
      FadeGuiOut_NoBlock(gInventoryback,100,-15);
    }
  }
}


What do you think Khris?

Paul.

Khris

It's easier if you tell me what you want to achieve.
Why did you want to disable all hotspots in the first place?
What about objects and characters?

And btw, to check if the mouse isn't over gInventory, you can use
Code: ags
  if (GUI.GetAtScreenXY(mouse.x, mouse.y)!=gInventory)

subspark

QuoteAnd btw, to check if the mouse isn't over gInventory, you can use...

Thanks, Khris but i've done it that way so that theres a small gap between the gui and the room in the background in case the mouse slips while trying to use one inventory item with another. Always good to have a bit of mouse freedom in this case. The other reason is so that the mouse can be moved to the bottom left of the screen where the inventory acivator (i) button is without repetedly closing the inventory. Because the inventory doesn't take up the entire screen and only uses a small portion of the middle of the screen then checking to see if the mouse is whithin the gui would not be the best choice in my case.

To answer your first question, what I want to happen is simple. I want the hospots disabled while the inventory is showing because, again, the inventory only takes up a small portion of the middle of the screen. If i move the mouse into the 'grace area' outside of the GUI, hotspots in that area, if any, should not be enabled.

Sorry if was a little too vague before.
Does that clear things up a bit?

Cheers,
Paul.

Ashen

#11
Could you make the 'grace area' a second, transparent (as in, no background colour or image) GUI. Set it's z-order to be less that gInv, make it clickable, and turn it off/on at the same time as you turn the Inventory on. Since it's transparent, it won't effect how the game looks around the Inventory GUI (No big thick border, or anything), and since it's clickable, it'll block any attempts to use Hotspots, etc, under it. Just make sure about the z-order - if it's higher than the Inventory, it'll block clicks on that, too.

Or, you could just make the Inventory GUI slightly bigger, and give it a background image with a transparent border. Same effect, no dummy GUI needed.

Corrected typo. Although, a 'background mage' would've been pretty cool too.
I know what you're thinking ... Don't think that.

subspark

You know what, your right! I thought this might complicate things but not if i make the GUI big enough to encompass the grace area AND the lower left part of the screen where the (i) button is.
Thanks, Khris, and Ashen.

Paul.

SMF spam blocked by CleanTalk