How to refresh the hotspot label?

Started by ManicMatt, Tue 02/10/2018 22:21:24

Previous topic - Next topic

ManicMatt

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!

Matti

Shouldn't HotspotLabel.Text = ""; do the trick?

ManicMatt

Woop! Thanks!

In my case it's

Code: ags
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

The code that sets the label text should be inside repeatedly_execute. That way it is updated as soon as the blocking interaction finishes.

Crimson Wizard

Quote from: Khris on Wed 03/10/2018 11:24:22
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.

ManicMatt

You mean this text? If so, it already is. (The last two lines aren't relevant.)

Code: ags

function repeatedly_execute()
{
    
  gOverhotspot.Visible = true;
    // calculate coordinates assuming for now that GUI doesn't have to be moved
  int Posx = mouse.x - gOverhotspot.Width / 2; 
  int Posy = mouse.y + 40;
  // horizontal check
  if (Posx < 0) Posx = 0;
  if (Posx + gOverhotspot.Width > System.ViewportWidth) Posx = System.ViewportWidth - gOverhotspot.Width;
  // vertical check
  if (Posy < 0) Posy = 0;
  if (Posy + gOverhotspot.Height > System.ViewportHeight) Posy = System.ViewportHeight - gOverhotspot.Height;
  // finally, actually move GUI there
  gOverhotspot.SetPosition(Posx, Posy);
  if (mouse.y>320) gVerbCoin.Transparency=50;
  if (mouse.y<320) gVerbCoin.Transparency=0;
  
}

Crimson Wizard

#6
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

Khris

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?

ManicMatt

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

#9
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: ags
overhotspot.Text = "@overhotspot@";

That should fix it.

ManicMatt

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!

SMF spam blocked by CleanTalk