Jump to content

Module:Recipe: Difference between revisions

From MISERY wiki
imported>JarlHiemas
No edit summary
 
Created page with "local p = {} local param = { station = 'station', sort = 'sort', sortDelim = ';', sortDelim2 = '¤', time = 'time', output = 'output', yield = 'yield', page = 'page' } local function addRecipe(name, amt) if not name or not amt then return "" end return '' .. name .. ' x ' .. amt end function p.main(frame) local args = require('Module:Arguments').getArgs(frame) local t = mw.html.create('table') :addClass('fandom-table article-table sort..."
 
Line 1: Line 1:
local p = {}
local p = {}
local category = mw.html.create()


--Arguments for template
local param = {
local param = {
   sStationArg = 'station',
   station = 'station',
   sSortArg = 'sort',
   sort = 'sort',
   sSortDelim = ';', --Needs to be pattern
   sortDelim = ';',
   sSortDelim2 = '¤',
   sortDelim2 = '¤',
   sTimeArg = 'time',
   time = 'time',
   sOutputArg = 'output',
   output = 'output',
   sYieldArg = 'yield',
   yield = 'yield',
   sPage = 'page'
   page = 'page'
}
}
p.param = param


function addRecipe(sAmt, sName)
local function addRecipe(name, amt)
   local output = '[['..sName..']]'..' x '..sAmt
   if not name or not amt then return "" end
  category:wikitext('[[Category:Uses ', sName, ']]')
  return '[[' .. name .. ']] x ' .. amt
  return output
end
end


function p.main(frame)
function p.main(frame)
   local args = require('Module:Arguments').getArgs(frame, {
   local args = require('Module:Arguments').getArgs(frame)
    parentFirst = true,
 
    wrapper = { 'Template:Recipe' }
  local t = mw.html.create('table')
  })
    :addClass('fandom-table article-table sortable alternating-colors-table')
  return p._main(args,frame)
 
end
  local inputText = ""


function p._main(args,frame)
  for k, v in pairs(args) do
local _table = mw.html.create('table'):addClass('fandom-table article-table sortable alternating-colors-table')
    local isReserved = false
local inputText = ''
    for sKey,sVal in pairs(args) do


      local restricted = false
    for _, key in pairs(param) do
      for _, keyParam in pairs(param) do
      if k == key then
        if keyParam == sKey then
        isReserved = true
          restricted = true
         break
         end
       end
       end
    end


      if not(restricted) then
    if not isReserved then
        inputText = inputText..addRecipe(sVal, sKey)..'</br>'
      inputText = inputText .. addRecipe(k, v) .. "<br/>"
      end
     end
     end
  end
local tr = _table:tag('tr')
 
tr:tag('td'):wikitext(inputText or " - ")
  t:tag('tr')
    :tag('td'):wikitext(inputText ~= "" and inputText or "-")
if args[param.sStationArg] then
 
category:wikitext('[[Category:Uses ', args[param.sStationArg], ']]')
  t:tag('tr'):tag('td'):wikitext(args.station and ('[[' .. args.station .. ']]') or "-")
end
 
tr:tag('td'):wikitext(args[param.sStationArg] and '[['..args[param.sStationArg]..']]' or " - ")
  t:tag('tr'):tag('td'):wikitext(args.time or "-")
 
tr:tag('td'):wikitext(args[param.sTimeArg] or " - ")
  t:tag('tr'):tag('td'):wikitext(args.output and ('[[' .. args.output .. ']] x ' .. (args.yield or 1)) or "-")


tr:tag('td'):wikitext('[['..args[param.sOutputArg]..']]'.." x "..(args[param.sYieldArg] or 1))
  return t
return _table
end
end


return p
return p

Latest revision as of 23:36, 28 June 2026

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

local p = {}

local param = {
  station = 'station',
  sort = 'sort',
  sortDelim = ';',
  sortDelim2 = '¤',
  time = 'time',
  output = 'output',
  yield = 'yield',
  page = 'page'
}

local function addRecipe(name, amt)
  if not name or not amt then return "" end
  return '[[' .. name .. ']] x ' .. amt
end

function p.main(frame)
  local args = require('Module:Arguments').getArgs(frame)

  local t = mw.html.create('table')
    :addClass('fandom-table article-table sortable alternating-colors-table')

  local inputText = ""

  for k, v in pairs(args) do
    local isReserved = false

    for _, key in pairs(param) do
      if k == key then
        isReserved = true
        break
      end
    end

    if not isReserved then
      inputText = inputText .. addRecipe(k, v) .. "<br/>"
    end
  end

  t:tag('tr')
    :tag('td'):wikitext(inputText ~= "" and inputText or "-")

  t:tag('tr'):tag('td'):wikitext(args.station and ('[[' .. args.station .. ']]') or "-")

  t:tag('tr'):tag('td'):wikitext(args.time or "-")

  t:tag('tr'):tag('td'):wikitext(args.output and ('[[' .. args.output .. ']] x ' .. (args.yield or 1)) or "-")

  return t
end

return p