Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Language Adventure on Mon 07/03/2022 10:58:29

Title: Changing the Actionbar text
Post by: Language Adventure on Mon 07/03/2022 10:58:29
Hi guys!

I'm trying to change what the Action line says...ie.
Change "Look at Door" to "Peek through keyhole".

This seems so simple but there's no obvious way to do it.

Any help is much appreciated!





Title: Re: Changing the Actionbar text
Post by: AndreasBlack on Mon 07/03/2022 11:29:24
I think you should be able to search for the line, it should be in the global script probably. Click Edit then Find all and click "currect document" and search for it. If you find it, change it to your liking.
Title: Re: Changing the Actionbar text
Post by: Language Adventure on Mon 07/03/2022 11:54:41
Thank you for the reply but I'm so confused!
I'm probably missing something. I'm not sure what you mean by "search for the line".

Do you mean I look for this
  VerbCoin.RegisterButton(btnLook, eVerbCoinPositionNorth, eModeLookat, "Look at");
And change "Look at" to "Peek"?

I'm not trying to change it globally just on specific objects.





Title: Re: Changing the Actionbar text
Post by: Cassiebsg on Mon 07/03/2022 19:24:55
Place the code inside an if condition.

Code (ags) Select

if (can_peek) VerbCoin.RegisterButton(btnLook, eVerbCoinPositionNorth, eModeLookat, "Peek through"); // I'm assuming the keyhole is a hotspot/object.
else VerbCoin.RegisterButton(btnLook, eVerbCoinPositionNorth, eModeLookat, "Look at");


can_peek is a bool, just set it up where needed. (probably better to use custom variables for this though - change the code appropriately)
Title: Re: Changing the Actionbar text
Post by: Language Adventure on Mon 07/03/2022 20:33:10
Thank you so much, that's what I'm looking for.
You have no idea how awesome you are!!!

THANK YOU!
Title: Re: Changing the Actionbar text
Post by: Khris on Tue 08/03/2022 01:09:12
If you want to do this for a bunch of interactions, you can use custom properties.

Here's the one for looking at stuff (you need to create this):
(https://i.imgur.com/drlrN4y.png)

Now open the main VerbCoin Script and replace line 506 (the one that sets action_label.Text) with this:
Code (ags) Select
        String actionString = String.Format("%s %%s", actionmap[control.ID]);       
        switch(modemap[control.ID]) {
        case eModeLookat:
          actionString = GetPropertyText(context_x, context_y, "look_at");
        }
        action_label.Text = String.Format(actionString, context_text);


Now scroll up a bit and put this right above the function repeatedly_execute:
Code (ags) Select
String GetPropertyText(int sx, int sy, String property) {
  gVerbCoin.Clickable = false;
  LocationType lt = GetLocationType(sx, sy);
  Hotspot* h = Hotspot.GetAtScreenXY(sx, sy);
  Object* o = Object.GetAtScreenXY(sx, sy);
  Character* c = Character.GetAtScreenXY(sx, sy);
  gVerbCoin.Clickable = true;
  if (lt == eLocationNothing) return "";
  if (lt == eLocationCharacter) return c.GetTextProperty(property);
  if (lt == eLocationHotspot) return h.GetTextProperty(property);
  if (lt == eLocationObject) return o.GetTextProperty(property);
}


To actually use this, open the properties for the door and change "Look at %s" to "Peek through keyhole".
To change actions other than look you need to add the property to the Schema and an according case to the switch block.
Title: Re: Changing the Actionbar text
Post by: Language Adventure on Tue 08/03/2022 16:34:10
This is perfect!
Thank you so much!

Title: Re: Changing the Actionbar text
Post by: Language Adventure on Tue 08/03/2022 17:33:54
Sorry to be a pain!
If I want to change the interact verb do I need to edit this part? I'm not sure what you mean by switch block...

Code (ags) Select
        String actionString = String.Format("%s %%s", actionmap[control.ID]);       
        switch(modemap[control.ID]) {
        :X case eModeLookat: :X
          actionString = GetPropertyText(context_x, context_y, "look_at");
        }
        action_label.Text = String.Format(actionString, context_text);


Title: Re: Changing the Actionbar text
Post by: Khris on Thu 10/03/2022 00:22:37
A switch block works like this: https://www.adventuregamestudio.co.uk/manual/ags43.htm#switchstatement

You need to add a case:
Code (ags) Select
        switch(modemap[control.ID]) {
        case eModeLookat:
          actionString = GetPropertyText(context_x, context_y, "look_at");
          break;  // <-- don't forget this
        case eModeInteract:
          actionString = GetPropertyText(context_x, context_y, "interact"); // <-- custom property must exist
        }
Title: Re: Changing the Actionbar text
Post by: Language Adventure on Thu 10/03/2022 10:11:22
You've saved me from going mad!

Thank you so much Khris!!!
Title: Re: Changing the Actionbar text
Post by: Khris on Thu 10/03/2022 16:10:36
You're welcome :D