Jibble

Author Topic: How to refresh the hotspot label?  (Read 545 times)

How to refresh the hotspot label?
« on: 02 Oct 2018, 22:21 »
Hello!

I realised when I have the character use an inventory item that results in the inventory item being removed, the label hotspot I have with floating text still says "Use (item) with (object)" when I no longer have the inventory item. I suppose I could tell AGS to relocate the cursor, but that would likely annoy the player.

Both of these codes do not fix the problem:

player.ActiveInventory = null;
mouse.Mode=eModeInteract;

I suppose it's not the mouse, but the label not refreshing. You have to move the cursor off the object and then the label behaves as it should. Is there a nice simple piece of code to tell it to refresh this? I'm not using the newest version of AGS, and I'm using a verb coin system.

I can't find any solutions for some reason, on the forum. Maybe I'm typing the wrong words. Help please!
« Last Edit: 02 Oct 2018, 22:22 by ManicMatt »

Matti

Re: How to refresh the hotspot label?
« Reply #1 on: 03 Oct 2018, 00:41 »
Shouldn't HotspotLabel.Text = ""; do the trick?

Re: How to refresh the hotspot label?
« Reply #2 on: 03 Oct 2018, 09:15 »
Woop! Thanks!

In my case it's

Code: Adventure Game Studio
  1. overhotspot.Text = ""

So the object doesn't show its text until you move off and back on to it, which isn't perfect but a million times better than having it still say the item command! Thanks!

Khris

  • partook in silencing a crtitc despite facts
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: How to refresh the hotspot label?
« Reply #3 on: 03 Oct 2018, 11:24 »
The code that sets the label text should be inside repeatedly_execute. That way it is updated as soon as the blocking interaction finishes.
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: How to refresh the hotspot label?
« Reply #4 on: 03 Oct 2018, 11:43 »
The code that sets the label text should be inside repeatedly_execute. That way it is updated as soon as the blocking interaction finishes.

Ah, this actually reminded me, I answered similar question not long ago:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=55979.msg636584576#msg636584576
might be somewhat related too.

Re: How to refresh the hotspot label?
« Reply #5 on: 03 Oct 2018, 13:29 »
You mean this text? If so, it already is. (The last two lines aren't relevant.)

Code: Adventure Game Studio
  1. function repeatedly_execute()
  2. {
  3.    
  4.   gOverhotspot.Visible = true;
  5.     // calculate coordinates assuming for now that GUI doesn't have to be moved
  6.   int Posx = mouse.x - gOverhotspot.Width / 2;
  7.   int Posy = mouse.y + 40;
  8.   // horizontal check
  9.   if (Posx < 0) Posx = 0;
  10.   if (Posx + gOverhotspot.Width > System.ViewportWidth) Posx = System.ViewportWidth - gOverhotspot.Width;
  11.   // vertical check
  12.   if (Posy < 0) Posy = 0;
  13.   if (Posy + gOverhotspot.Height > System.ViewportHeight) Posy = System.ViewportHeight - gOverhotspot.Height;
  14.   // finally, actually move GUI there
  15.   gOverhotspot.SetPosition(Posx, Posy);
  16.   if (mouse.y>320) gVerbCoin.Transparency=50;
  17.   if (mouse.y<320) gVerbCoin.Transparency=0;
  18.  
  19. }

Re: How to refresh the hotspot label?
« Reply #6 on: 03 Oct 2018, 13:37 »
ManicMatt, I now remember we had a talk about this gOverhotspot before, but I still do not understand how exactly do you set the description text, because it is nowhere in the script you posted. In the above fragment you set its size and position, but not the text itself, which means that it is set somehow and somewhere else.

PS. For the reference here is an old discussion we had: http://www.adventuregamestudio.co.uk/forums/index.php?topic=22152.msg636585518#msg636585518
« Last Edit: 03 Oct 2018, 13:50 by Crimson Wizard »

Khris

  • partook in silencing a crtitc despite facts
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: How to refresh the hotspot label?
« Reply #7 on: 03 Oct 2018, 13:57 »
Yeah, I'm talking about the label text, which I guess is composed from strings using mouse.Mode etc.
Where and how is it set?
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: How to refresh the hotspot label?
« Reply #8 on: 03 Oct 2018, 14:17 »
Ah, it's been many months since I even looked at the overhotspot stuff, I think it's not in my global script, but in the Scumm Verbcoin GUI script, in which I think I left that well alone.

In any case, I just put that empty text line in wherever an inventory item was lost and it seems fine now. :)

Khris

  • partook in silencing a crtitc despite facts
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: How to refresh the hotspot label?
« Reply #9 on: 03 Oct 2018, 15:27 »
The problem is indeed in the main VerbCoin script (as usual (roll)). It should've never become an official template, given how buggy it is.
Fixing this is extremely tedious I'm afraid, so unless you have to do this for dozens of hotspots it's probably more efficient to manually reset the label text.
I'd reset it to @overhotspot@ though.

Edit: move the cursor to the right of the closing brace on line 589, then press enter. In the now empty line 590, put
Code: Adventure Game Studio
  1. overhotspot.Text = "@overhotspot@";
That should fix it.
« Last Edit: 03 Oct 2018, 15:56 by Khris »
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: How to refresh the hotspot label?
« Reply #10 on: 03 Oct 2018, 20:24 »
Thanks! That did the trick! I added the code for characters and objects too because they have the same issue.

I noticed it would after blocking, be still seen for a brief flicker. But by having the overhotspot.Text = "" code after the inventory item has been removed in place too, it now perfectly shows the correct label text instantly.

Provided I haven't messed this up elsewhere, perfection has been achieved here! Thank you very much!