Help strings localized to Text events

Version:

1.0

Added on:

04 Nov 2021 19:47

Tags:

Description:
Show a help string the entire time you're standing in front of a Text event, and stop showing it once you leave the event, instead of the normal behavior of displaying the string for a fixed period of time. This coexists with normal Text events: for the normal behavior, set the TextID event parameter to anything in the 0–15 range, and for this behavior, use 100–115.
  1. class HelpString {
  2.   int HelpID = -1;
  3.   int Timer = -200;
  4. }
  5. array<HelpString> HelpStrings(jjLocalPlayerCount);
  6.  
  7. bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
  8.   HelpString@ helpString = HelpStrings[player.localPlayerID];
  9.   const uint xTile = uint(player.xPos) / 32, yTile = uint(player.yPos) / 32;
  10.   if (jjEventGet(xTile,yTile) == AREA::TEXT && jjParameterGet(xTile,yTile, 8,10) == 0) {
  11.     const int helpID = jjParameterGet(xTile,yTile, 0,8);
  12.     if (helpID >= 100 && helpID <= 115) {
  13.       if (helpID - 100 != helpString.HelpID) {
  14.         helpString.Timer = jjGameTicks + 70;
  15.         helpString.HelpID = helpID - 100;
  16.       } else if (helpString.Timer < jjGameTicks) {
  17.         helpString.Timer = jjGameTicks;
  18.       }
  19.     }
  20.   }
  21.  
  22.   const int time = helpString.Timer - jjGameTicks;
  23.   if (time > -70) {
  24.     canvas.drawString(
  25.       0x8000 + time * int(abs(time)) / 10,
  26.       10,
  27.       jjHelpStrings[helpString.HelpID],
  28.       STRING::SMALL,
  29.       STRING::SPIN,
  30.       uint(abs(time)) * 3
  31.     );
  32.   } else
  33.     helpString.HelpID = -1;
  34.    
  35.   return false;
  36. }