Module:Skills: Difference between revisions

319 bytes removed ,  12 November 2021
Removed redundant references to getSkillID since that's now a Constants function
(Fixed Firemaking table calls)
(Removed redundant references to getSkillID since that's now a Constants function)
Line 14: Line 14:
local ItemData = mw.loadData('Module:Items/data')
local ItemData = mw.loadData('Module:Items/data')
local SkillData = mw.loadData('Module:Skills/data')
local SkillData = mw.loadData('Module:Skills/data')
local Constants = mw.loadData('Module:Constants/data')


local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Constants = require('Module:Constants')
local Items = require('Module:Items')
local Items = require('Module:Items')
local ItemSourceTables = require('Module:Items/SourceTables')
local ItemSourceTables = require('Module:Items/SourceTables')
Line 22: Line 22:


local MasteryCheckpoints = {.1, .25, .5, .95}
local MasteryCheckpoints = {.1, .25, .5, .95}
function p.getSkillID(skillName)
  for skName, ID in Shared.skpairs(Constants.skill) do
    if skName == skillName then
      return ID
    end
  end
  return nil
end
function p.getSkillName(skillID)
  for skName, ID in Shared.skpairs(Constants.skill) do
    if ID == skillID then
      return skName
    end
  end
  return nil
end


function p.getMasteryUnlockTable(frame)
function p.getMasteryUnlockTable(frame)
   local skillName = frame.args ~= nil and frame.args[1] or frame
   local skillName = frame.args ~= nil and frame.args[1] or frame
   local skillID = p.getSkillID(skillName)
   local skillID = Constants.getSkillID(skillName)
   if skillID == nil then
   if skillID == nil then
     return "ERROR: Failed to find a skill ID for "..skillName
     return "ERROR: Failed to find a skill ID for "..skillName
Line 64: Line 46:
function p.getMasteryCheckpointTable(frame)
function p.getMasteryCheckpointTable(frame)
   local skillName = frame.args ~= nil and frame.args[1] or frame
   local skillName = frame.args ~= nil and frame.args[1] or frame
   local skillID = p.getSkillID(skillName)
   local skillID = Constants.getSkillID(skillName)
   if skillID == nil then
   if skillID == nil then
     return "ERROR: Failed to find a skill ID for "..skillName
     return "ERROR: Failed to find a skill ID for "..skillName
Line 346: Line 328:
     table.insert(resultPart, '\r\n|-')
     table.insert(resultPart, '\r\n|-')
     table.insert(resultPart, '\r\n|style="text-align:center"|' .. Icons.Icon({token.name, type='item', size=50, notext=true}))
     table.insert(resultPart, '\r\n|style="text-align:center"|' .. Icons.Icon({token.name, type='item', size=50, notext=true}))
     table.insert(resultPart, '\r\n|' .. Icons.Icon({p.getSkillName(m['skillID']), type='skill'}))
     table.insert(resultPart, '\r\n|' .. Icons.Icon({Constants.getSkillName(m['skillID']), type='skill'}))
     table.insert(resultPart, '\r\n|style="text-align:right" data-sort-value="' .. denom .. '"|1/' .. Shared.formatnum(denom))
     table.insert(resultPart, '\r\n|style="text-align:right" data-sort-value="' .. denom .. '"|1/' .. Shared.formatnum(denom))
     table.insert(resultPart, '\r\n|style="text-align:right" data-sort-value="' .. denomCCI .. '"|1/' .. Shared.formatnum(denomCCI))
     table.insert(resultPart, '\r\n|style="text-align:right" data-sort-value="' .. denomCCI .. '"|1/' .. Shared.formatnum(denomCCI))