HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Converting real values into strings question

01-02-2003, 05:35 PM#1
Guest
I have a trigger to display a text message to a player on a certain hero's current health. I do this by using Real-->String command in the text message trigger. But, I noticed it displas it a little over-accurate. It shows the health as: 8000.00. What I need is no decimals. But then again, I think it has to be an integer for that...

Im not too sure, any help?

EDIT: Aha, I think I might have it. I think I can use Real-->Formatted String. Time to test it...
01-02-2003, 05:56 PM#2
Ari
you need to make nestled functions, like this: string(integer(health)).
In custom text, it would be I2S(R2I(health))

Keep in mind, though, that health is stored as a real in WC3 (try using a trigger that adds .5 hp's twice), but I've noticed some weird behavior in the way wc3 converts that real into the displayed integer (the behavior is different than the generic real --> integer function; I think one rounds up and the other rounds down). You might want to test it once or twice to make sure there's no discrepancy between what you want displayed, and what actually is displayed.

Btw, though I haven't ever played around with it, the function "convert real to formatted string" may be an easier way of doing what you're trying to do. I believe it allows you to specifiy the number of decimal places displayed.