Difference between revisions of "Template:Rest Hours Per Day/doc"

From RimWorld Wiki
Jump to navigation Jump to search
m (Improved the documentation. There are 2 values I do not understand: 0.65857 - lowest work % of a day AND 0.9207 - highest work % of a day. Will submit this anyway as it is an improvement.)
Line 1: Line 1:
[[Rest#Comparison_tables]]
+
This template calculates how much time, in both percentage and absolute terms, a pawn requires to fully rest per day. It's only mean to be used by [[Template:Rest Hours Per Day]], which itself is used in [[Rest#Comparison_tables]].
<code><nowiki>{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=1|color=1}}</nowiki></code>
 
{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=1|color=1}}
 
<code><nowiki>{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=0.8|color=1}}</nowiki></code>
 
{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=0.8|color=1}}
 
  
RE  = Rest Effectiveness
+
==Syntax==
RRM = Rest Rate Multiplier
+
:<code><nowiki>{{Rest Hours Per Day|RE|RRM|RFF|color}}</nowiki></code><br/>
RFF = Rest Fall Factor
+
RE  = Rest Effectiveness. Defaults to 1.<br/>
 +
RRM = Rest Rate Multiplier. Defaults to 1.<br/>
 +
RFF = Rest Fall Factor. Defaults to 1.<br/>
 +
color = Optional. It determines the alpha/transparency of hsla(110, 100%, 40%, color), which is ten applies to the "background". It goes from 0 to 1, with 0 being fully transparent and 1 fully opaque.
  
Where x = sleeping hours.
+
The formulas used by this template were obtained by solving the following equation (Where x = sleeping hours):
  
x * ~0.57143% * RE * RRM = (24-x) * 0.237% * RFR        <br>
+
:x * ~0.57143% * RE * RRM = (24-x) * 0.237% * RFR        <br>
x/(24-x) = (0.237% * RFR)/(~0.57143% * RE * RRM)        <br>
+
:x/(24-x) = (0.237% * RFR)/(~0.57143% * RE * RRM)        <br>
(24-x)/x = (~0.57143% * RE * RRM)/(0.237% * RFR)        <br>
+
:(24-x)/x = (~0.57143% * RE * RRM)/(0.237% * RFR)        <br>
(24/x)-1 = (~0.57143% * RE * RRM)/(0.237% * RFR)        <br>
+
:(24/x)-1 = (~0.57143% * RE * RRM)/(0.237% * RFR)        <br>
24/x    = ((~0.57143% * RE * RRM)/(0.237% * RFR))+1    <br>
+
:24/x    = ((~0.57143% * RE * RRM)/(0.237% * RFR))+1    <br>
x        = 24/((~0.57143% * RE * RRM)/(0.237% * RFR))+1 <br>
+
:x        = 24/((~0.57143% * RE * RRM)/(0.237% * RFR))+1 <br>
 +
The final value is then rounded to the second decimal place.
  
 
0.65857 - lowest work % of a day
 
0.65857 - lowest work % of a day
 
0.9207 - highest work % of a day
 
0.9207 - highest work % of a day
  
hsla(120, 100%, 50%,
+
==Examples:==
 +
<code><nowiki>{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=1|color=1}}</nowiki></code>
 +
{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=1|color=1}}
 +
<code><nowiki>{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=0.8|color=1}}</nowiki></code>
 +
{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=0.8|color=1}}

Revision as of 17:21, 27 February 2025

This template calculates how much time, in both percentage and absolute terms, a pawn requires to fully rest per day. It's only mean to be used by Template:Rest Hours Per Day, which itself is used in Rest#Comparison_tables.

Syntax

{{Rest Hours Per Day|RE|RRM|RFF|color}}

RE = Rest Effectiveness. Defaults to 1.
RRM = Rest Rate Multiplier. Defaults to 1.
RFF = Rest Fall Factor. Defaults to 1.
color = Optional. It determines the alpha/transparency of hsla(110, 100%, 40%, color), which is ten applies to the "background". It goes from 0 to 1, with 0 being fully transparent and 1 fully opaque.

The formulas used by this template were obtained by solving the following equation (Where x = sleeping hours):

x * ~0.57143% * RE * RRM = (24-x) * 0.237% * RFR
x/(24-x) = (0.237% * RFR)/(~0.57143% * RE * RRM)
(24-x)/x = (~0.57143% * RE * RRM)/(0.237% * RFR)
(24/x)-1 = (~0.57143% * RE * RRM)/(0.237% * RFR)
24/x = ((~0.57143% * RE * RRM)/(0.237% * RFR))+1
x = 24/((~0.57143% * RE * RRM)/(0.237% * RFR))+1

The final value is then rounded to the second decimal place.

0.65857 - lowest work % of a day 0.9207 - highest work % of a day

Examples:

{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=1|color=1}}

7.93%
(1.9 hrs)

{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=0.8|color=1}}

6.45%
(1.55 hrs)