• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ Healthticks show seconds in Look Item.

Fabi Marzan

Well-Known Member
Joined
Aug 31, 2020
Messages
135
Solutions
6
Reaction score
67
Greetings, I have a problem that I can't understand, it's about placing Healthticks and Manaticks as a description.

By placing the manaticks or healthticks attributes, it shows the seconds that it will be healed.
Lua:
<attribute key="manaGain" value="20" />
<attribute key="manaTicks" value="1000" />

So it would be displayed like this:
Screenshot_2.png

So in Item.cpp
I have it like this


C++:
if (it.abilities->manaGain) {
                if (begin) {
                    begin = false;
                    s << " (";
                }
                else {
                    s << ", ";
                }

                s << "Mana Recovery +" << std::showpos << it.abilities->manaGain << std::noshowpos << " each/" << std::showpos << it.abilities->manaTicks / 1000 << std::noshowpos << "s";
            }
I try to set it to display the decimals of the milliseconds, that is, if I set 1100, then it should show 1.1s, if I set 1200, then it would show 1.2s.
So I put it like this:

C++:
if (it.abilities->manaGain) {
                if (begin) {
                    begin = false;
                    s << " (";
                }
                else {
                    s << ", ";
                }

                s << "Mana Recovery +" << std::showpos << it.abilities->manaGain << std::noshowpos << " each/" << std::showpos << it.abilities->manaTicks / 1000 << std::noshowpos << "." << it.abilities->manaTicks / 1000 * 1 << std::noshowpos << "s";
            }

From what I see that every 1000 would simplify it by 1.
But it doesn't work for me, even if I have it at 1000 it shows me 1.1s and if I set it to 1200 it still shows me 1.1s.
Screenshot_3.png

I got this code from this post:
 

Attachments

Solution
C++:
s << "Mana Recovery +" << it.abilities->manaGain << std::noshowpos << " each/" << it.abilities->manaTicks / 1000. << "s";

or

C++:
s << "Mana Recovery +" << it.abilities->manaGain << " each/" << std::fixed << std::setprecision(1) << it.abilities->manaTicks / 1000. << "s";
C++:
s << "Mana Recovery +" << it.abilities->manaGain << std::noshowpos << " each/" << it.abilities->manaTicks / 1000. << "s";

or

C++:
s << "Mana Recovery +" << it.abilities->manaGain << " each/" << std::fixed << std::setprecision(1) << it.abilities->manaTicks / 1000. << "s";
 
Solution
C++:
s << "Mana Recovery +" << it.abilities->manaGain << std::noshowpos << " each/" << it.abilities->manaTicks / 1000. << "s";

or

C++:
s << "Mana Recovery +" << it.abilities->manaGain << " each/" << std::fixed << std::setprecision(1) << it.abilities->manaTicks / 1000. << "s";
how can i use this in canary distro?
 
C++:
s << "Mana Recovery +" << it.abilities->manaGain << std::noshowpos << " each/" << it.abilities->manaTicks / 1000. << "s";

or

C++:
s << "Mana Recovery +" << it.abilities->manaGain << " each/" << std::fixed << std::setprecision(1) << it.abilities->manaTicks / 1000. << "s";
Perfect, thanks.
 
Back
Top