Module:Sandbox/FalterTest: Difference between revisions

From Melvor Idle
(Added testApostrophe)
No edit summary
Line 20: Line 20:
function p.testApostrophe(frame)
function p.testApostrophe(frame)
   local pageName = frame.args ~= nil and frame.args[1] or frame
   local pageName = frame.args ~= nil and frame.args[1] or frame
  local strArray = {}
   for i = 1, #pageName do
   for i = 1, #pageName do
     mw.log(string.sub(pageName, i, i)..' ['..pageName:byte(i)..']')
     local newStr = string.sub(pageName, i, i)..' ['..pageName:byte(i)..']'
    table.insert(strArray, newStr)
    mw.log(newStr)
   end
   end
  return table.concat(strArray, '\r\n')
end
end


return p
return p

Revision as of 19:52, 21 October 2020

Documentation for this module may be created at Module:Sandbox/FalterTest/doc

local p = {}

local Constants = mw.loadData('Module:Constants/data')
local MonsterData = mw.loadData('Module:Monsters/data')

function p.getMonsterStat(frame)
  local MonsterName = frame.args[1]
  local StatName = frame.args[2]
  local result = 'No monster found with that name'
  for key, value in pairs(MonsterData) do
    if(value.name == MonsterName) then
      --mw.logObject(value)
      mw.log(StatName)
      result = value[StatName]
    end
  end
  return result
end

function p.testApostrophe(frame)
  local pageName = frame.args ~= nil and frame.args[1] or frame
  local strArray = {}
  for i = 1, #pageName do
    local newStr = string.sub(pageName, i, i)..' ['..pageName:byte(i)..']'
    table.insert(strArray, newStr)
    mw.log(newStr)
  end
  return table.concat(strArray, '\r\n')
end

return p