Advertisement
joerkig

Untitled

Apr 13th, 2021
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.51 KB | None | 0 0
  1.         public override void OnLateUpdate()
  2.         {
  3.             GameObject playerInteractor = GameObject.Find("Player/PlayerInteractor");
  4.             if (playerInteractor != null)
  5.             {
  6.                 PlayerHealth playerHealth = playerInteractor.GetComponent<PlayerHealth>();
  7.                 if (playerHealth != null)
  8.                 {
  9.                     string healthPip = "<img src=\"HealthPip.png\">";
  10.                     string healthPipCracked = "<img src=\"HealthPipCracked.png\">";
  11.                     int currentHealth = (int)Math.Ceiling(playerHealth.CurrentHealth);
  12.                     int maxHealth = (int)Math.Ceiling(playerHealth.MaxHealth);
  13.                     int emptyHealth = maxHealth - currentHealth;
  14.                     if (playerHealth.MaxHealth.ToString() != File.ReadAllText(MelonUtils.UserDataDirectory + "\\MaxHealth.txt"))
  15.                     {
  16.                         File.WriteAllText(MelonUtils.UserDataDirectory + "\\MaxHealth.txt", playerHealth.MaxHealth.ToString());
  17.                         File.WriteAllText(MelonUtils.UserDataDirectory + "\\Health.html", "<center>" + String.Concat(Enumerable.Repeat(healthPip, currentHealth)) + String.Concat(Enumerable.Repeat(healthPipCracked, emptyHealth)) + "</center><script>function timedRefresh(timeoutPeriod) {setTimeout(\"location.reload(true); \",timeoutPeriod);} window.onload = timedRefresh(2000);</script>");
  18.                     }
  19.                     if (playerHealth.CurrentHealth.ToString() != File.ReadAllText(MelonUtils.UserDataDirectory + "\\CurrentHealth.txt"))
  20.                     {
  21.                         File.WriteAllText(MelonUtils.UserDataDirectory + "\\CurrentHealth.txt", playerHealth.CurrentHealth.ToString());
  22.                         File.WriteAllText(MelonUtils.UserDataDirectory + "\\Health.html", "<center>" + String.Concat(Enumerable.Repeat(healthPip, currentHealth)) + String.Concat(Enumerable.Repeat(healthPipCracked, emptyHealth)) + "</center><script>function timedRefresh(timeoutPeriod) {setTimeout(\"location.reload(true); \",timeoutPeriod);} window.onload = timedRefresh(2000);</script>");
  23.                     }
  24.                     //File.WriteAllText(MelonUtils.UserDataDirectory + "\\Health.html", "<center>" + String.Concat(Enumerable.Repeat(healthPip, currentHealth)) + String.Concat(Enumerable.Repeat(healthPipCracked, emptyHealth)) + "</center><script>function timedRefresh(timeoutPeriod) {setTimeout(\"location.reload(true); \",timeoutPeriod);} window.onload = timedRefresh(2000);</script>");
  25.                 }
  26.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement