Thread Tools Display Modes
10-21-23, 01:20 PM   #1
Yukka
A Theradrim Guardian
 
Yukka's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2020
Posts: 60
How to say the target health?

Hello there I would like a macro that says "Target Name health: X%" so in the macro I write things like this: "%t health: " but I dont know what to write for the health %... can anyone please help? Thanks.
  Reply With Quote
10-21-23, 02:09 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,832
Something like:
Lua Code:
  1. /run if UnitExists("target") then local h,m = UnitHealth("target"),UnitHealthMax("target") print(format("%s's Health: %3.1f%%", UnitName("target"),(h/m)*100)) else print("No Target") end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 10-21-23 at 02:20 PM.
  Reply With Quote
10-21-23, 02:44 PM   #3
Yukka
A Theradrim Guardian
 
Yukka's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2020
Posts: 60
Originally Posted by Fizzlemizz View Post
Something like:
Lua Code:
  1. /run if UnitExists("target") then local h,m = UnitHealth("target"),UnitHealthMax("target") print(format("%s's Health: %3.1f%%", UnitName("target"),(h/m)*100)) else print("No Target") end
Nice, but how can I say that in the chat? /s for example.
  Reply With Quote
10-21-23, 03:17 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,832
Replace the print with SendChatMessage:
Lua Code:
  1. /run if UnitExists("target") then local h,m = UnitHealth("target"),UnitHealthMax("target") SendChatMessage(format("%s's Health: %3.1f%%", UnitName("target"),(h/m)*100), "SAY") else print("No Target") end

See the docs for restrictions on using SendChatMessage.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
10-21-23, 04:31 PM   #5
Yukka
A Theradrim Guardian
 
Yukka's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2020
Posts: 60
Thanks a lot
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » Macro Help » How to say the target health?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off