<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ASwimming_calculator</id>
	<title>Module:Swimming calculator - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ASwimming_calculator"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Swimming_calculator&amp;action=history"/>
	<updated>2026-05-12T17:21:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://wiki.runerealm.org/index.php?title=Module:Swimming_calculator&amp;diff=35176&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;local p = {} local levelAtXp = require(&#039;Module:Experience&#039;).level_at_xp_unr local xpAtLevel = require(&#039;Module:Experience&#039;).xp_at_level_unr  function p.main(frame)  	local args = frame:getParent().args  	thievingXP = tonumber(args.thievingXP)  	thievingLvl = tonumber(args.thievingLvl)  	thievingType = args.thievingType  	agilityXP = tonumber(args.agilityXP)   	agilityLvl =tonumber(args.agilityLvl)  	agilityType = args.agilityType  	tearsHr = tonumber(args.Tears)  	goalTog...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Swimming_calculator&amp;diff=35176&amp;oldid=prev"/>
		<updated>2024-10-16T23:13:13Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local p = {} local levelAtXp = require(&amp;#039;Module:Experience&amp;#039;).level_at_xp_unr local xpAtLevel = require(&amp;#039;Module:Experience&amp;#039;).xp_at_level_unr  function p.main(frame)  	local args = frame:getParent().args  	thievingXP = tonumber(args.thievingXP)  	thievingLvl = tonumber(args.thievingLvl)  	thievingType = args.thievingType  	agilityXP = tonumber(args.agilityXP)   	agilityLvl =tonumber(args.agilityLvl)  	agilityType = args.agilityType  	tearsHr = tonumber(args.Tears)  	goalTog...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
local levelAtXp = require(&amp;#039;Module:Experience&amp;#039;).level_at_xp_unr&lt;br /&gt;
local xpAtLevel = require(&amp;#039;Module:Experience&amp;#039;).xp_at_level_unr&lt;br /&gt;
 function p.main(frame)&lt;br /&gt;
 	local args = frame:getParent().args&lt;br /&gt;
 	thievingXP = tonumber(args.thievingXP)&lt;br /&gt;
 	thievingLvl = tonumber(args.thievingLvl)&lt;br /&gt;
 	thievingType = args.thievingType&lt;br /&gt;
 	agilityXP = tonumber(args.agilityXP) &lt;br /&gt;
 	agilityLvl =tonumber(args.agilityLvl)&lt;br /&gt;
 	agilityType = args.agilityType&lt;br /&gt;
 	tearsHr = tonumber(args.Tears)&lt;br /&gt;
 	goalToggle = args.goalToggle&lt;br /&gt;
 	goal =tonumber(args.goal)&lt;br /&gt;
 	leagueMultiplier = tonumber(args.leagueMultiplier)&lt;br /&gt;
	&lt;br /&gt;
	-----Handle 200m exception----&lt;br /&gt;
	if goal == 127 then goalXP = 200000000 else goalXP = xpAtLevel({args = {goal}}) end&lt;br /&gt;
	if thievingType == &amp;quot;Level&amp;quot; then &lt;br /&gt;
		if thievingLvl == 127 then thievingXP = 200000000 else&lt;br /&gt;
		thievingXP = xpAtLevel({args = {thievingLvl}}) end end&lt;br /&gt;
	if agilityType == &amp;quot;Level&amp;quot; then &lt;br /&gt;
		if agilityLvl == 127 then agilityXP = 200000000 else&lt;br /&gt;
		agilityXP = xpAtLevel({args = {agilityLvl}}) end end&lt;br /&gt;
	&lt;br /&gt;
	tears = 0&lt;br /&gt;
	initialAgility = agilityXP&lt;br /&gt;
	initialThieving = thievingXP&lt;br /&gt;
	thieving = levelAtXp({args = {thievingXP}})&lt;br /&gt;
	agility = levelAtXp({args = {agilityXP}})&lt;br /&gt;
&lt;br /&gt;
    if goalToggle == &amp;quot;Thieving&amp;quot; then&lt;br /&gt;
    	if thievingXP &amp;gt;= goalXP then&lt;br /&gt;
    		return &amp;quot;Your target must be higher than your level&amp;quot; end&lt;br /&gt;
		 tears = calculateTears(thievingXP, goalXP, thieving, 11)&lt;br /&gt;
		 thievingXP = goalXP&lt;br /&gt;
		time = tears / tearsHr&lt;br /&gt;
		agilityXP = calculateXp(agilityXP, agility, tears, 3)&lt;br /&gt;
		secondaryXP = agilityXP&lt;br /&gt;
		secondary = &amp;quot;Agility&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
	    if agilityXP &amp;gt;= goalXP then&lt;br /&gt;
    		return &amp;quot;Your target must be higher than your level&amp;quot; end&lt;br /&gt;
		tears = calculateTears(agilityXP, goalXP, agility, 3)&lt;br /&gt;
		agilityXP = goalXP&lt;br /&gt;
		time = tears / tearsHr&lt;br /&gt;
		thievingXP = calculateXp(thievingXP, thieving, tears, 11)&lt;br /&gt;
		secondaryXP = thievingXP&lt;br /&gt;
		secondary = &amp;quot;Thieving&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	------EHP (TempleOsrs) ----will probably need updating every now and then-----&lt;br /&gt;
	agilityEhp = getAgilityEHP(0,13363,6000) + getAgilityEHP(13363,41171,15000) + getAgilityEHP(41171,449428,44000) + getAgilityEHP(449428,2192818,50000) + getAgilityEHP(2192818,6000000,55000) + getAgilityEHP(6000000,6517253,59000) + getAgilityEHP(6517253,200000000,95000)&lt;br /&gt;
	&lt;br /&gt;
	thievingEhp = getThievingEHP(0,61512,15000) + getThievingEHP(61512,166636,60000) + getThievingEHP(166636,449428,100000) + getThievingEHP(449428,5902831,220000) + getThievingEHP(5902831,13034431,255000) + getThievingEHP(13034431,200000000,280000)&lt;br /&gt;
	&lt;br /&gt;
		----Leagues----&lt;br /&gt;
	if (leagueMultiplier == null) then leagueMultiplier = 1 end&lt;br /&gt;
	time = time / leagueMultiplier&lt;br /&gt;
	agilityEhp = agilityEhp / leagueMultiplier&lt;br /&gt;
	thievingEhp = thievingEhp / leagueMultiplier&lt;br /&gt;
	------------------&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	if (secondaryXP == 200000000) then secondaryLvl = 127 else&lt;br /&gt;
	secondaryLvl = levelAtXp({args = {secondaryXP}}) end&lt;br /&gt;
	ehp = (agilityEhp + thievingEhp) / time&lt;br /&gt;
	timeSave = (agilityEhp + thievingEhp) - time&lt;br /&gt;
	if timeSave &amp;lt; 0 then &lt;br /&gt;
		gain = &amp;quot;slower&amp;quot; &lt;br /&gt;
		timeSave = timeSave * -1&lt;br /&gt;
		else gain = &amp;quot;faster&amp;quot; end&lt;br /&gt;
		&lt;br /&gt;
	-----Output Formatting----&lt;br /&gt;
	agilityXP = tonumber(string.format(&amp;quot;%.0f&amp;quot;, agilityXP))&lt;br /&gt;
	thievingXP = tonumber(string.format(&amp;quot;%.0f&amp;quot;, thievingXP))&lt;br /&gt;
	time = tonumber(string.format(&amp;quot;%.2f&amp;quot;, time))&lt;br /&gt;
	agilityEhp = tonumber(string.format(&amp;quot;%.2f&amp;quot;, agilityEhp))&lt;br /&gt;
	thievingEhp = tonumber(string.format(&amp;quot;%.2f&amp;quot;, thievingEhp))&lt;br /&gt;
	ehp = tonumber(string.format(&amp;quot;%.2f&amp;quot;, ehp))&lt;br /&gt;
	timeSave = tonumber(string.format(&amp;quot;%.2f&amp;quot;, timeSave))&lt;br /&gt;
	secondaryXP = tonumber(string.format(&amp;quot;%.0f&amp;quot;, secondaryXP))&lt;br /&gt;
	&lt;br /&gt;
	return &amp;quot;It will take you &amp;quot; .. time .. &amp;quot; hours to reach your goal of level &amp;quot; .. goal .. &amp;quot; &amp;quot;.. goalToggle.. &amp;quot; (&amp;quot;..goalXP..&amp;quot; xp). &amp;lt;br/&amp;gt; This will get you to level &amp;quot; .. secondaryLvl ..&amp;quot; &amp;quot; .. secondary .. &amp;quot; (&amp;quot;..secondaryXP..&lt;br /&gt;
	&amp;quot; xp). &amp;lt;br/&amp;gt; Doing the most efficient Agility training method to gain that xp would take &amp;quot;..agilityEhp.. &amp;quot; hours. &amp;lt;br/&amp;gt; Doing the most efficient Thieving training method to gain that xp would take &amp;quot;.. thievingEhp .. &amp;quot; hours.&amp;quot;..&lt;br /&gt;
	&amp;quot;&amp;lt;br/&amp;gt; This makes swimming &amp;quot;..timeSave..&amp;quot; hours &amp;quot;..gain..&amp;quot;, and puts swimming at &amp;quot;.. ehp.. &amp;quot; EHP.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
--Alternative output (less wordy)&lt;br /&gt;
--	return &amp;quot;Final Agility XP: &amp;quot;  .. agilityXP.. &amp;quot;&amp;lt;br/&amp;gt; Final Thieving XP: &amp;quot; .. thievingXP .. &amp;quot;&amp;lt;br/&amp;gt; Time taken: &amp;quot; .. time .. &amp;quot; hours &amp;lt;br/&amp;gt; Agility EHP: &amp;quot; .. agilityEhp.. &amp;quot; &amp;lt;br/&amp;gt; Thieving EHP: &amp;quot; .. thievingEhp ..  &amp;quot;&amp;lt;br/&amp;gt; Swimming EHP: &amp;quot; .. ehp&lt;br /&gt;
 end&lt;br /&gt;
 ----Find amount of tears to reach goalXP-----&lt;br /&gt;
  function calculateTears(currentxp, goalXP, level, multiplier)&lt;br /&gt;
	while (currentxp &amp;lt; goalXP) do&lt;br /&gt;
		level = levelAtXp({args = {currentxp}})&lt;br /&gt;
		if level &amp;gt;= 99 then &lt;br /&gt;
			xpreq = goalXP - currentxp&lt;br /&gt;
			level = 99&lt;br /&gt;
			else&lt;br /&gt;
			xpreq = xpAtLevel({args = {level + 1}}) - currentxp&lt;br /&gt;
			if xpAtLevel({args = {level + 1}}) &amp;gt; goalXP then&lt;br /&gt;
				xpreq = goalXP - currentxp end&lt;br /&gt;
		end&lt;br /&gt;
		tears = tears + xpreq / (multiplier * level * level * 9/1500)&lt;br /&gt;
		currentxp = currentxp + xpreq&lt;br /&gt;
	end&lt;br /&gt;
	return tears&lt;br /&gt;
 end&lt;br /&gt;
 ----Find how much xp you will get with that amount of tears-----&lt;br /&gt;
 function calculateXp(xp, level, tears, multiplier)&lt;br /&gt;
	while (tears &amp;gt; 0) do&lt;br /&gt;
		level = levelAtXp({args = {xp}})&lt;br /&gt;
		if level &amp;gt; 99 then level2 = 99 else level2 = level end&lt;br /&gt;
		xpPerTear = (multiplier * level2 * level2 * 9 /1500)&lt;br /&gt;
		if level &amp;gt;= 99 then break end&lt;br /&gt;
		xpreq = xpAtLevel({args = {level + 1}}) - xp&lt;br /&gt;
		tear2 = xpreq / xpPerTear&lt;br /&gt;
		if tear2 &amp;lt; tears then&lt;br /&gt;
			tears = tears - tear2&lt;br /&gt;
			xp = xp + tear2 * xpPerTear&lt;br /&gt;
		else break end &lt;br /&gt;
	end&lt;br /&gt;
	xp = xp + tears * xpPerTear&lt;br /&gt;
	if xp &amp;gt; 200000000 then xp = 200000000 end&lt;br /&gt;
	return xp&lt;br /&gt;
 end&lt;br /&gt;
 ----Calculate EHP----&lt;br /&gt;
 function getAgilityEHP(low, high, rate)&lt;br /&gt;
 	if initialAgility &amp;lt;= high and initialAgility &amp;gt;= low and agilityXP &amp;lt;= high and agilityXP &amp;gt;= low then return (agilityXP - initialAgility)/rate end&lt;br /&gt;
	if initialAgility &amp;lt;= high and initialAgility &amp;gt;= low and agilityXP &amp;gt;= high then return (high - initialAgility)/rate end&lt;br /&gt;
	if initialAgility &amp;lt;= low and agilityXP &amp;lt;= high and agilityXP &amp;gt;= low then return (agilityXP - low)/rate end&lt;br /&gt;
	if initialAgility &amp;lt;= low and agilityXP &amp;gt;= high then return (high - low)/rate end&lt;br /&gt;
	return 0&lt;br /&gt;
 end&lt;br /&gt;
  function getThievingEHP(low, high, rate)&lt;br /&gt;
 	if initialThieving &amp;lt;= high and initialThieving &amp;gt;= low and thievingXP &amp;lt;= high and thievingXP &amp;gt;= low then return (thievingXP - initialThieving)/rate end&lt;br /&gt;
	if initialThieving &amp;lt;= high and initialThieving &amp;gt;= low and thievingXP &amp;gt;= high then return (high - initialThieving)/rate end&lt;br /&gt;
	if initialThieving &amp;lt;= low and thievingXP &amp;lt;= high and thievingXP &amp;gt;= low then return (thievingXP - low)/rate end&lt;br /&gt;
	if initialThieving &amp;lt;= low and thievingXP &amp;gt;= high then return (high - low)/rate end&lt;br /&gt;
	return 0&lt;br /&gt;
 end&lt;br /&gt;
 return p&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>