Модуль:Meals Lookup: различия между версиями

non-expensive getimage
less expensive getimage
Строка 31: Строка 31:
function getimage(frame, fileid) -- should not be invoked
function getimage(frame, fileid) -- should not be invoked
     local out = ""
     local out = ""
     local gifFileTitle = mw.title.new(fileid .. ".gif", "File")
     --[[
    local pngFileTitle = mw.title.new(fileid .. ".png", "File")
        WARNING!! THE NEXT THING IS "EXPENSIVE" AND DOES NOT WORKS AFTER 30 OR SMTHNG RUNS
    if gifFileTitle.file.exists then
        read https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Expensive_properties for more info
        out = "File:" .. fileid .. ".gif"
        local gifFileTitle = mw.title.new(fileid .. ".gif", "File")
    elseif pngFileTitle.file.exists then
        local pngFileTitle = mw.title.new(fileid .. ".png", "File")
        out = "File:" .. fileid .. ".png"
        if gifFileTitle.file.exists then
    else
            out = "File:" .. fileid .. ".gif"
        out = ""
        elseif pngFileTitle.file.exists then
     end
            out = "File:" .. fileid .. ".png"
        else
            out = ""
        end
     --]]
 
    -- less expensive variant, but returns only png (AND BIG RED TEXT IF PNG DOES NOT EXISTS)
    out = "File:" .. fileid .. ".png"
     return out
     return out
end
end