Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public override void OnLateUpdate()
- {
- GameObject playerInteractor = GameObject.Find("Player/PlayerInteractor");
- if (playerInteractor != null)
- {
- PlayerHealth playerHealth = playerInteractor.GetComponent<PlayerHealth>();
- if (playerHealth != null)
- {
- string healthPip = "<img src=\"HealthPip.png\">";
- string healthPipCracked = "<img src=\"HealthPipCracked.png\">";
- int currentHealth = (int)Math.Ceiling(playerHealth.CurrentHealth);
- int maxHealth = (int)Math.Ceiling(playerHealth.MaxHealth);
- int emptyHealth = maxHealth - currentHealth;
- if (playerHealth.MaxHealth.ToString() != File.ReadAllText(MelonUtils.UserDataDirectory + "\\MaxHealth.txt"))
- {
- File.WriteAllText(MelonUtils.UserDataDirectory + "\\MaxHealth.txt", playerHealth.MaxHealth.ToString());
- 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>");
- }
- if (playerHealth.CurrentHealth.ToString() != File.ReadAllText(MelonUtils.UserDataDirectory + "\\CurrentHealth.txt"))
- {
- File.WriteAllText(MelonUtils.UserDataDirectory + "\\CurrentHealth.txt", playerHealth.CurrentHealth.ToString());
- 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>");
- }
- //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>");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement