Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Recipe: Difference between revisions

From The Petit Planet Wiki
Created page with "local p = {} local Card = require('Module:Card') local category = mw.html.create() --Arguments for template local param = { sCharArg = 'character', sTypeArg = 'type', sSortArg = 'sort', sSortDelim = ';', --Needs to be pattern sSortDelim2 = '¤', sTimeArg = 'time', sYieldArg = 'yield', sPage = 'page' } p.param = param function padLeft(str, amt) return string.rep('0', amt - str:len()) .. str end function addRecipe(sAmt, sName) local cardNode = Card._m..."
 
Eleiyas (talk | contribs)
Replacing with my custom version from ZZZ, because it's better here.
 
Line 48: Line 48:
function p._main(args,frame)
function p._main(args,frame)
   local output = mw.html.create('div')
   local output = mw.html.create('div')
     :addClass('new_genshin_recipe_container')
     :addClass('recipe_container')
   if type(args[param.sTypeArg]) ~= 'string' then
   if type(args[param.sTypeArg]) ~= 'string' then
     output:tag('span'):addClass('error'):wikitext('Recipe type error. Must include recipe type.')
     output:tag('span'):addClass('error'):wikitext('Recipe type error. Must include recipe type.')
   else
   else
     local tArgsProcessed = {}
     local tArgsProcessed = {}
     local header = output:tag('div'):addClass('new_genshin_recipe_header')
     local header = output:tag('div'):addClass('recipe_header')


     --Type Parse
     --Type Parse
     local sType = args[param.sTypeArg]
     local sType = args[param.sTypeArg]
     header:tag('span'):addClass('new_genshin_recipe_header_main')
     header:tag('span'):addClass('recipe_header_main')
       -- Mobile Icon
       -- Mobile Icon
       :tag('span'):addClass('mobileHide'):wikitext('[[File:Icon_' .. sType .. '_Small.png|15x15px|link=' .. sType .. '|alt=Icon_' .. sType .. '_Small.png]]'):done()
       :tag('span'):addClass('mobileHide'):wikitext('<big>' .. sType .. '</big>'):done()
       -- Desktop Icon
       -- Desktop Icon
       :tag('span'):addClass('hidden'):wikitext('[[File:Icon_' .. sType .. '_Small.png|37x37px|link=' .. sType .. '|alt=Icon_' .. sType .. '_Small.png]]'):done()
       :tag('span'):addClass('mobileHide'):wikitext('<big>' .. sType .. '</big>'):done()
       -- Text
       -- Text
       :tag('span'):addClass('new_genshin_recipe_header_text'):wikitext('[[' ..  sType .. ']]'):done()
       :tag('span'):addClass('recipe_header_text'):wikitext('[[' ..  sType .. ']]'):done()
     category:wikitext('[[Category:' .. sType .. ']]')
     category:wikitext('[[Category:' .. sType .. ']]')


Line 121: Line 121:
           sTime = sTime .. each .. ' '
           sTime = sTime .. each .. ' '
       end
       end
       header:tag('span'):addClass('new_genshin_recipe_header_sub')
       header:tag('span'):addClass('recipe_header_sub')
         :tag('span'):addClass('mobileHide'):wikitext(' for '):done()
         :tag('span'):addClass('mobileHide'):wikitext(' for '):done()
         :tag('span'):addClass('hidden'):wikitext('[[File:Icon Clock.png|24x24px|link=Time]]'):done()
         :tag('span'):addClass('hidden'):wikitext(' for '):done()
         :tag('span'):addClass('new_genshin_recipe_header_text'):wikitext(sTime):done()
         :tag('span'):addClass('recipe_header_text'):wikitext(sTime):done()
     end
     end
     --Character Parse
     --Character Parse
     if type(args[param.sCharArg]) == 'string' then
     if type(args[param.sCharArg]) == 'string' then
       local sCharName = args[param.sCharArg]
       local sCharName = args[param.sCharArg]
       header:tag('span'):addClass('new_genshin_recipe_header_sub')
       header:tag('span'):addClass('recipe_header_sub')
         :tag('span'):addClass('mobileHide'):wikitext(' with '):done()
         :tag('span'):addClass('mobileHide'):wikitext(' with '):done()
         :tag('span'):addClass('hidden'):wikitext('[[File:' .. sCharName .. ' Icon.png|24x24px|link=' .. sCharName .. ']]'):done()
         :tag('span'):addClass('hidden'):wikitext('[[File:' .. sCharName .. ' Icon.png|24x24px|link=' .. sCharName .. ']]'):done()
         :tag('span'):addClass('new_genshin_recipe_header_text'):wikitext('[[' .. sCharName .. ']]'):done()
         :tag('span'):addClass('recipe_header_text'):wikitext('[[' .. sCharName .. ']]'):done()
     end
     end


local body = output:tag('div'):addClass('new_genshin_recipe_body')
local body = output:tag('div'):addClass('recipe_body')


--Check if sSortDelim2 exists in sSortArg
--Check if sSortDelim2 exists in sSortArg
Line 175: Line 175:
    }
    }
    body
    body
      :tag('div'):addClass('new_genshin_recipe_body_icon')
      :tag('div'):addClass('recipe_body_icon')
        :wikitext('[[File:Icon_' .. sType .. '_Recipe.png|35x35px|link=' .. sType .. ']]'):done()
        :wikitext(''):done()
      :tag('div'):addClass('new_genshin_recipe_body_yield')
      :tag('div'):addClass('recipe_body_yield')
        :node(yieldCard)
        :node(yieldCard)