Bearbeiten von „Modul:CraftingParser

Aus Eco - Deutsches Wiki
Wechseln zu:Navigation, Suche

Deine Änderungen werden angezeigt, sobald ein dazu berechtigter Benutzer sie akzeptiert hat. (Hilfe)

Warnung: Du bist nicht angemeldet. Deine IP-Adresse wird bei Bearbeitungen öffentlich sichtbar. Melde dich an oder erstelle ein Benutzerkonto, damit Bearbeitungen deinem Benutzernamen zugeordnet werden. Ein eigenes Benutzerkonto hat eine ganze Reihe von Vorteilen.

Die Bearbeitung kann rückgängig gemacht werden. Bitte prüfe den Vergleich unten, um sicherzustellen, dass du dies tun möchtest, und veröffentliche dann unten deine Änderungen, um die Bearbeitung rückgängig zu machen.

Aktuelle Version Dein Text
Zeile 2: Zeile 2:
local p = {}
local p = {}


local Utils = require('Module:Utils')
-- Grabs args from the parent frame
local L = require('Module:Localization')
-- Trims and parses the args into a table, then returns the table
function norm( origArgs )
    origArgs = mw.getCurrentFrame():getParent().args
    local args = {}
   
    for k, v in pairs( origArgs ) do
        v = mw.text.trim( tostring( v ) )
        if v ~= '' then
            args[k] = v
        end
    end
   
    return args
end
 


-- Compares two recipes ( a < b ? true : false )
-- Compares two recipes ( a < b ? true : false )
function recipeCompare(a, b)
function recipeCompare(a, b)
 
   
     --not in v0.9
     --not in v0.9
     --if not a.efficiencySkills[1] and not b.efficiencySkills[1] then return false
     --if not a.efficiencySkills[1] and not b.efficiencySkills[1] then return false
Zeile 15: Zeile 29:
     --elseif a.efficiencySkills[1] > b.efficiencySkills[1] then return false
     --elseif a.efficiencySkills[1] > b.efficiencySkills[1] then return false
      
      
    if (a.skillNeeds[1] ~= nil and b.skillNeeds[1] ~= nil) then  
if (a.skillNeeds[1] ~= nil and b.skillNeeds[1] ~= nil) then  
        if a.skillNeeds[1][1] < b.skillNeeds[1][1] then  
if a.skillNeeds[1][1] < b.skillNeeds[1][1] then return true
            return true
elseif a.skillNeeds[1][1] > b.skillNeeds[1][1] then return false
        elseif a.skillNeeds[1][1] > b.skillNeeds[1][1] then  
elseif not a.skillNeeds[1][2] and b.skillNeeds[1][2] then return true
            return false
elseif a.skillNeeds[1][2] and not b.skillNeeds[1][2] then return false
        elseif not a.skillNeeds[1][2] and b.skillNeeds[1][2] then
elseif a.skillNeeds[1][2] and a.skillNeeds[1][2] < b.skillNeeds[1][2] then return true
            return true
elseif a.skillNeeds[1][2] and a.skillNeeds[1][2] > b.skillNeeds[1][2] then return false
        elseif a.skillNeeds[1][2] and not b.skillNeeds[1][2] then
end
            return false
        elseif a.skillNeeds[1][2] and a.skillNeeds[1][2] < b.skillNeeds[1][2] then
     elseif a.defaultVariant < b.defaultVariant then return true
            return true
     elseif a.defaultVariant > b.defaultVariant then return false
        elseif a.skillNeeds[1][2] and a.skillNeeds[1][2] > b.skillNeeds[1][2] then
     else return a.defaultVariant <= b.defaultVariant
            return false
        end
     elseif a.defaultVariant < b.defaultVariant then
        return true
     elseif a.defaultVariant > b.defaultVariant then
        return false
     -- else
    --    return a.defaultVariant <= b.defaultVariant
     end
     end
end
end
Zeile 74: Zeile 80:
function formatRecipes( recipes )
function formatRecipes( recipes )
   -- Sort recipes
   -- Sort recipes
   table.sort( recipes, recipeCompare )
   table.sort( recipes, function( a, b ) return recipeCompare( a, b ) end )


   return recipes
   return recipes
Zeile 84: Zeile 90:
function p.raw( f )
function p.raw( f )
     -- get args from the Template, parse them into recipes
     -- get args from the Template, parse them into recipes
     local recipes = frameParse( Utils.normaliseArgs(f) )
     local recipes = frameParse( norm( f ) )


     -- Format the recipes
     -- Format the recipes
Zeile 100: Zeile 106:
function p.formattedItem( products, ingredients, item )
function p.formattedItem( products, ingredients, item )
     -- Format the recipes, and call RecipeTable on each table
     -- Format the recipes, and call RecipeTable on each table
    local recipeTable = require( "Module:RecipeTable" )
local recipeTable = require( "Module:RecipeTable" )
     local returnVal = '=== '..L.t('Crafting Recipes')..' ===\n\n'
     local returnVal = '=== Rezepte herstellen ===\n\n'
      
      
     if (products ~= nil and #products ~= 0) then
     if (products ~= nil and #products ~= 0) then
        returnVal = returnVal .. recipeTable.main( formatRecipes(products) ) .. '\n\n=== '..L.t('Used in Recipes')..' ===\n\n'         
returnVal = returnVal .. recipeTable.main( formatRecipes(products) ) .. '\n\n=== Wird in Rezepten verwendet ===\n\n'         
     else
     else
         returnVal = returnVal .. "''"..L.t('None').."''\n\n=== "..L.t('Used in Recipes').." ===\n\n "
         returnVal = returnVal .. "''Keiner''\n\n=== Wird in Rezepten verwendet ===\n\n "
     end
     end
   
     if (ingredients ~= nil and #ingredients ~= 0) then
     if (ingredients ~= nil and #ingredients ~= 0) then
         returnVal = returnVal .. recipeTable.main( formatRecipes(ingredients) )
         returnVal = returnVal .. recipeTable.main( formatRecipes(ingredients) )
     else
     else
        returnVal = returnVal .. "''"..L.t('None').."''\n"       
returnVal = returnVal .. "''Keiner''\n"       
     end
     end


Zeile 125: Zeile 131:
     -- Format the recipes, and call RecipeTable
     -- Format the recipes, and call RecipeTable
     local recipeTable = require( "Module:RecipeTable" )
     local recipeTable = require( "Module:RecipeTable" )
     local returnVal = '=== ' .. L.t('Recipes at %s'):format(table) .. ' ===\n\n'
     local returnVal = '=== Rezepte bei ' .. table .. ' ===\n\n'
     if #recipes == 0 then
     if #recipes == 0 then
         returnVal = returnVal .. "''"..L.t('None').."''\n"
         returnVal = returnVal .. "''Keiner''\n"
     else
     else
         returnVal = returnVal .. recipeTable.main( formatRecipes( recipes ) )
         returnVal = returnVal .. recipeTable.main( formatRecipes( recipes ) )
Zeile 142: Zeile 148:
     -- Format the recipes, and call RecipeTable
     -- Format the recipes, and call RecipeTable
     local recipeTable = require( "Module:RecipeTable" )
     local recipeTable = require( "Module:RecipeTable" )
     local returnVal = '=== ' .. L.t('%s Recipes'):format(group) .. ' ===\n\n'
     local returnVal = '=== ' .. group .. ' Recipes ===\n\n'
     if #recipes == 0 then
     if #recipes == 0 then
         returnVal = returnVal .. "''"..L.t('None').."''\n"
         returnVal = returnVal .. "''Keiner''\n"
     else
     else
         returnVal = returnVal .. recipeTable.main( formatRecipes( recipes ) )
         returnVal = returnVal .. recipeTable.main( formatRecipes( recipes ) )
Bitte kopiere keine Webseiten, die nicht deine eigenen sind, benutze keine urheberrechtlich geschützten Werke ohne Erlaubnis des Urhebers!
Du gibst uns hiermit deine Zusage, dass du den Text selbst verfasst hast, dass der Text Allgemeingut (public domain) ist oder dass der Urheber seine Zustimmung gegeben hat. Falls dieser Text bereits woanders veröffentlicht wurde, weise bitte auf der Diskussionsseite darauf hin. Bitte beachte, dass alle Eco - Deutsches Wiki-Beiträge automatisch unter der „CC BY-NC-SA 4.0“ stehen (siehe Eco:Urheberrechte für Einzelheiten). Falls du nicht möchtest, dass deine Arbeit hier von anderen verändert und verbreitet wird, dann klicke nicht auf „Seite speichern“.

Um das Wiki vor automatisiertem Bearbeitungsspam zu schützen, bitten wir dich, das folgende hCaptcha zu lösen:

Abbrechen Bearbeitungshilfe (wird in einem neuen Fenster geöffnet)

Die folgende Vorlage wird auf dieser Seite verwendet: