Replies: 0 (Who?), Viewed: 187 times.
#1 12th Jul 2020 at 10:47 PM
How to round a number in a tuning fileI posted this on S4S as well (https://sims4studio.com/thread/2148...er-tuning-file), but am reposting here to hopefully reach more people:
Hey there - I'm working on this mod that involves adding and removing followers from a sim's social media. I've got adding followers working, but I've run into a problem with removing them and have been trying to resolve it all day.
Basically, I want the follower removals to be proportionate to the current amount of followers, let's say 5% for example. So, if you have 100 followers and lose 5%, you're left with 95. The issue is when this proportion is not a full number, for example if you have 102 followers. 5% of 102 is 5.1, so it will remove 5.1 followers, leaving you with 96.9, which makes no sense. Your followers should always be an integer.
Here is the relevant code snippet from the tuning file (this appears in a <L n="loot_actions"></L> tag):
<V t="statistics"> <V n="statistics" t="statistic_change"> <U n="statistic_change"> <T n="stat">3235795689834682419<!--frankkulak:statistic_FollowerChange_Actual--></T> <T n="amount">0.05</T> <L n="statistic_multipliers"> <U> <V n="multiplier" t="raw_value"> <T n="raw_value"></T> </V> <T n="statistic">31167<!--statistic_Object_Computer_SocialNetwork_Followers--></T> </U> </L> <L n="tests"> <L> <V t="statistic"> <U n="statistic"> <T n="stat">31167<!--statistic_Object_Computer_SocialNetwork_Followers--></T> <V n="threshold" t="value_threshold"> <U n="value_threshold"> <T n="value">100</T> </U> </V> </U> </V> </L> </L> </U> </V> </V>
What this does is takes 5% of `statistic_Object_Computer_SocialNetwork_Followers` and stores it in my own statistic called `frankkulak:statistic_FollowerChange_Actual` (so, if the former is 102, the latter will be 5.1), but only if there are at least 100 followers. This works, but I want it to round `frankkulak:statistic_FollowerChange_Actual` to the nearest integer. I searched the `LootActions.tdesc` file and was only able to find mention of rounding numbers in a money_loot, but nowhere else, so I don't know if this is possible.
Does anyone know how I can do this? If rounding numbers isn't possible, do you have any suggestions for a workaround?
Thanks in advance!