<?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%3ASkill_calc%2FHelpers</id>
	<title>Module:Skill calc/Helpers - 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%3ASkill_calc%2FHelpers"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Skill_calc/Helpers&amp;action=history"/>
	<updated>2026-04-30T07:35:51Z</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:Skill_calc/Helpers&amp;diff=399&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;local p = {}  local yesNo = require(&#039;Module:Yesno&#039;) local xp = require(&#039;Module:Experience&#039;).xp_at_level local level = require(&#039;Module:Experience&#039;).level_at_xp_unr local commas = require(&#039;Module:Addcommas&#039;)._add  function p.filterData(data, method, dataCriteria, goalLevel) 	local methodData = {} 	local addRow = false  	for i, v in ipairs(data) do 		if dataCriteria ~= &#039;Hide&#039; or tonumber(v.level) &lt;= tonumber(goalLevel) then 			if method == &#039;All&#039; then 				table.insert(method...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Skill_calc/Helpers&amp;diff=399&amp;oldid=prev"/>
		<updated>2024-10-11T21:41:42Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local p = {}  local yesNo = require(&amp;#039;Module:Yesno&amp;#039;) local xp = require(&amp;#039;Module:Experience&amp;#039;).xp_at_level local level = require(&amp;#039;Module:Experience&amp;#039;).level_at_xp_unr local commas = require(&amp;#039;Module:Addcommas&amp;#039;)._add  function p.filterData(data, method, dataCriteria, goalLevel) 	local methodData = {} 	local addRow = false  	for i, v in ipairs(data) do 		if dataCriteria ~= &amp;#039;Hide&amp;#039; or tonumber(v.level) &amp;lt;= tonumber(goalLevel) then 			if method == &amp;#039;All&amp;#039; then 				table.insert(method...&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;
&lt;br /&gt;
local yesNo = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
local xp = require(&amp;#039;Module:Experience&amp;#039;).xp_at_level&lt;br /&gt;
local level = require(&amp;#039;Module:Experience&amp;#039;).level_at_xp_unr&lt;br /&gt;
local commas = require(&amp;#039;Module:Addcommas&amp;#039;)._add&lt;br /&gt;
&lt;br /&gt;
function p.filterData(data, method, dataCriteria, goalLevel)&lt;br /&gt;
	local methodData = {}&lt;br /&gt;
	local addRow = false&lt;br /&gt;
&lt;br /&gt;
	for i, v in ipairs(data) do&lt;br /&gt;
		if dataCriteria ~= &amp;#039;Hide&amp;#039; or tonumber(v.level) &amp;lt;= tonumber(goalLevel) then&lt;br /&gt;
			if method == &amp;#039;All&amp;#039; then&lt;br /&gt;
				table.insert(methodData, v)&lt;br /&gt;
			else&lt;br /&gt;
				for type in string.gmatch(v.type, &amp;#039;([^,]*)&amp;#039;) do&lt;br /&gt;
					local formatted = string.gsub(type, &amp;#039;^%s*(.-)%s*$&amp;#039;, &amp;#039;%1&amp;#039;)&lt;br /&gt;
					if formatted == method then&lt;br /&gt;
						table.insert(methodData, v)&lt;br /&gt;
					end&lt;br /&gt;
				end	&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Sort the data&lt;br /&gt;
	table.sort(methodData, function(a, b) return p.sortTable(a, b) end)&lt;br /&gt;
	&lt;br /&gt;
	return methodData&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.calculateCurrentGoalInformation(curr, currToggle, goal, goalToggle)&lt;br /&gt;
	local currLevel, currXP, goalLevel, goalXP&lt;br /&gt;
    &lt;br /&gt;
    if currToggle == &amp;#039;Level&amp;#039; and tonumber(curr) &amp;lt;= 99 then&lt;br /&gt;
    	if tonumber(curr) == 0 then&lt;br /&gt;
    		currLevel = 1&lt;br /&gt;
    		currXP = xp({args = {1}})&lt;br /&gt;
    	else&lt;br /&gt;
    		currLevel = curr&lt;br /&gt;
        	currXP = xp({args = {curr}})&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
    	currLevel = level({args = {curr}})&lt;br /&gt;
        currXP = curr&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    if goalToggle == &amp;#039;Level&amp;#039; and tonumber(goal) &amp;lt;= 99 then&lt;br /&gt;
    	if tonumber(goal) == 0 then&lt;br /&gt;
    		goalLevel = 1&lt;br /&gt;
    		goalXP = xp({args = {1}})&lt;br /&gt;
    	else&lt;br /&gt;
    		goalLevel = goal&lt;br /&gt;
        	goalXP = xp({args = {goal}})&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
    	goalLevel = level({args = {goal}})&lt;br /&gt;
        goalXP = goal&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Prevent negative values&lt;br /&gt;
    local remaining = math.ceil(goalXP - currXP)&lt;br /&gt;
    if remaining &amp;lt; 0 then&lt;br /&gt;
        remaining = 0&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    return { currentLevel = tonumber(currLevel), currentExperience = currXP, goalLevel = tonumber(goalLevel), goalExperience = goalXP, experienceRemaining = remaining }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.membersIcon(data)&lt;br /&gt;
	local icon&lt;br /&gt;
	if data then&lt;br /&gt;
		local membersOnly = yesNo(data, true)&lt;br /&gt;
		if membersOnly then&lt;br /&gt;
			icon = &amp;#039;[[File:Member icon.png|center|link=Members]]&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			icon = &amp;#039;[[File:Free-to-play icon.png|center|link=Free-to-play]]&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		icon = &amp;#039;[[File:Free-to-play icon.png|center|link=Free-to-play]]&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return icon	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.checkForBoostingSetSkill(skill)&lt;br /&gt;
  return not not ({&lt;br /&gt;
    Woodcutting = true, Farming = true, Fishing = true, Mining = true, Firemaking = true, Construction = true, Prayer = true&lt;br /&gt;
  })[skill]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.determineSetValue(pieces, skill)&lt;br /&gt;
	local isEverythingTrue = true&lt;br /&gt;
	local value = 0&lt;br /&gt;
	for _, v in ipairs(pieces) do&lt;br /&gt;
		if v[1] == &amp;#039;false&amp;#039; or v[1] == nil then&lt;br /&gt;
			isEverythingTrue = false&lt;br /&gt;
		else&lt;br /&gt;
			value = value + tonumber(v[2])&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if isEverythingTrue then&lt;br /&gt;
		return skill == &amp;#039;Prayer&amp;#039; and 0.05 or 0.025&lt;br /&gt;
	else&lt;br /&gt;
		return value&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.createMessage(skill, bulkData)&lt;br /&gt;
    return string.format(&amp;#039;To train %s from %s experience (level %s) to %s experience (level %s), %s experience is required.&amp;#039;, &lt;br /&gt;
    	skill, commas(bulkData.currentExperience), bulkData.currentLevel, commas(bulkData.goalExperience), bulkData.goalLevel, commas(bulkData.experienceRemaining))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.sortTable(a, b)&lt;br /&gt;
	local value = false&lt;br /&gt;
	&lt;br /&gt;
	if a.level == b.level then&lt;br /&gt;
		if a.xp == b.xp then&lt;br /&gt;
			if a.name == b.name then&lt;br /&gt;
				if a.title and b.title then&lt;br /&gt;
					value = a.title &amp;lt; b.title&lt;br /&gt;
				elseif a.title and not b.title then&lt;br /&gt;
					value = a.title &amp;lt; b.name&lt;br /&gt;
				elseif not a.title and b.title then&lt;br /&gt;
					value = a.name &amp;lt; b.title&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				value = a.name &amp;lt; b.name	&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			value = a.xp &amp;lt; b.xp&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		value = a.level &amp;lt; b.level&lt;br /&gt;
	end&lt;br /&gt;
    &lt;br /&gt;
    return value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.jagexFloor(num, numDecimalPlaces)&lt;br /&gt;
  local mult = 10 ^ (numDecimalPlaces or 0)&lt;br /&gt;
  return math.floor(num * mult) / mult&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.isRowGrey(actionLevel, currentLevel)&lt;br /&gt;
	local color = &amp;#039;&amp;#039;&lt;br /&gt;
	local aLevel = actionLevel and actionLevel or 1&lt;br /&gt;
	&lt;br /&gt;
	if aLevel &amp;gt; tonumber(currentLevel) then&lt;br /&gt;
		color = &amp;#039;table-bg-fade&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return color&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>