Author Topic: Change Hotspot Name?  (Read 854 times)

Ali

  • What will become of the baron?
    • Ali worked on a game that was nominated for an AGS Award!
      Ali worked on a game that won an AGS Award!
Change Hotspot Name?
« on: 11 Dec 2013, 17:49 »
I can't find any recent posts about this, but - is it still not possible to change a hotspot's name?

I'm aware that I could use an object, but in this instance hotspots would be preferable.

Scavenger

  • Cavefish
  • In Four Glorious Colours!
    • I can help with animation
    •  
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with scripting
    •  
    • Scavenger worked on a game that was nominated for an AGS Award!
      Scavenger worked on a game that won an AGS Award!
Re: Change Hotspot Name?
« Reply #1 on: 11 Dec 2013, 18:08 »
I did this in my last game - you basically have to hijack the text marker while the cursor is over the hotspot (or whatever you're using) and return it to @OVERHOTSPOT@ when it's not. It depends on what interface you have - it could be as simple as putting a couple of lines of code into rep_exec or as complex as creating a proxy string for each hotspot to display instead of the name.

It is unfortunately not possible to directly change the hotspot name yet, but it is possible to fool the player into thinking you have.

Ali

  • What will become of the baron?
    • Ali worked on a game that was nominated for an AGS Award!
      Ali worked on a game that won an AGS Award!
Re: Change Hotspot Name?
« Reply #2 on: 11 Dec 2013, 18:10 »
Unfortunately, the reason I wanted to do this was in order to compare the hotspot name with another string in the script. So that wouldn't work, but thanks for the suggestion.

Scavenger

  • Cavefish
  • In Four Glorious Colours!
    • I can help with animation
    •  
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with scripting
    •  
    • Scavenger worked on a game that was nominated for an AGS Award!
      Scavenger worked on a game that won an AGS Award!
Re: Change Hotspot Name?
« Reply #3 on: 11 Dec 2013, 18:44 »
Ok, that should be easy enough to do. Something like this maybe:

Code: Adventure Game Studio
  1. #define AGS_ROOM_COUNT 30 //Or however many rooms you have in your game.
  2. String hotspot_name[];
  3. bool hotspotnameinit [AGS_ROOM_COUNT];
  4. function game_start ()
  5. {
  6.     hotspot_name = new String [AGS_ROOM_COUNT * AGS_MAX_HOTSPOTS];
  7. }
  8.  
  9. function on_event (EventType event, int data)
  10. {
  11.     if (event == eEventEnterRoomBeforeFadein)
  12.         {
  13.          if (!hotspotnameinit[player.Room])
  14.             {
  15.                 int i;
  16.                 while (i < AGS_MAX_HOTSPOTS)
  17.                     {
  18.                         hotspot_name [(player.Room * AGS_ROOM_COUNT) + i] = hotspot[i].Name;
  19.                         i++;
  20.                     }
  21.                 hotspotnameinit[player.Room] = true;
  22.             }  
  23.         }
  24. }
  25.  
  26. function SetName (this Hotspot*, String name)
  27. {
  28.     hotspot_name [(player.Room * AGS_ROOM_COUNT) + this.ID] = name;
  29. }
  30.  
  31. function GetName (this Hotspot*)
  32. {
  33.     return hotspot_name [(player.Room * AGS_ROOM_COUNT) + this.ID];
  34. }
  35.  

Whenever you need the hotspot's name, use Hotspot.GetName () instead.

Ali

  • What will become of the baron?
    • Ali worked on a game that was nominated for an AGS Award!
      Ali worked on a game that won an AGS Award!
Re: Change Hotspot Name?
« Reply #4 on: 11 Dec 2013, 19:44 »
Oh, thanks for that! But I'm, afraid I have already resorted to using objects instead. Good of you to come up with it, though. I will definitely turn to it if using objects doesn't work.