Changing the Actionbar text

Started by Language Adventure, Mon 07/03/2022 10:58:29

Previous topic - Next topic

Language Adventure

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!






AndreasBlack

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.

Language Adventure

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.






Cassiebsg

#3
Place the code inside an if condition.

Code: ags

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)
There are those who believe that life here began out there...

Language Adventure

Thank you so much, that's what I'm looking for.
You have no idea how awesome you are!!!

THANK YOU!

Khris

#5
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):


Now open the main VerbCoin Script and replace line 506 (the one that sets action_label.Text) with this:
Code: ags
        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
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.

Language Adventure

This is perfect!
Thank you so much!


Language Adventure

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
        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);



Khris

A switch block works like this: https://www.adventuregamestudio.co.uk/manual/ags43.htm#switchstatement

You need to add a case:
Code: ags
        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
        }

Language Adventure

You've saved me from going mad!

Thank you so much Khris!!!

Khris


SMF spam blocked by CleanTalk