Help strings localized to Text events

Version:

1.0

Added on:

04 Nov 2021 18: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.
class HelpString {
  int HelpID = -1;
  int Timer = -200;
}
array<HelpString> HelpStrings(jjLocalPlayerCount);

bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
  HelpString@ helpString = HelpStrings[player.localPlayerID];
  const uint xTile = uint(player.xPos) / 32, yTile = uint(player.yPos) / 32;
  if (jjEventGet(xTile,yTile) == AREA::TEXT && jjParameterGet(xTile,yTile, 8,10) == 0) {
    const int helpID = jjParameterGet(xTile,yTile, 0,8);
    if (helpID >= 100 && helpID <= 115) {
      if (helpID - 100 != helpString.HelpID) {
        helpString.Timer = jjGameTicks + 70;
        helpString.HelpID = helpID - 100;
      } else if (helpString.Timer < jjGameTicks) {
        helpString.Timer = jjGameTicks;
      }
    }
  }
  
  const int time = helpString.Timer - jjGameTicks;
  if (time > -70) {
    canvas.drawString(
      0x8000 + time * int(abs(time)) / 10,
      10,
      jjHelpStrings[helpString.HelpID],
      STRING::SMALL,
      STRING::SPIN,
      uint(abs(time)) * 3
    );
  } else
    helpString.HelpID = -1;
    
  return false;
}