Create custom statistic
How to create a custom statistic.
The only limitation with custom statistics is your imagination. :)
Let see how it works and what we can do with it, with some simple examples.
Enter a name and click "Create", names are unique.
After clicking create it will add a new section below the "Add New" one. Here it is named "Exemple". When overing an option it will display an explanation tooltip.
Display the value of "Savage Defense" shield
The code used:
local name,_,_,_,_,_,_,_,_,_,_,_,_, val = UnitBuff("player", "Savage Defense"); if ( name ) then return val; else return "0"; end
The result
Display the server time
The code used:
local h, m = GetGameTime(); if ( strlen(h) == 1 ) then h = "0"..h; end if ( strlen(m) == 1 ) then m = "0"..m; end return h, m
The result
Conclusion
The code need to return a value, if the code got an error it will tell you in the chat window the error string and the custom statistic name.
When using "Round" be sure to return numbers or it will spam your chat.