Модуль:Entity Lookup

Материал из DarkStation Wiki

Для документации этого модуля может быть создана страница Модуль:Entity Lookup/doc

local prototypes = mw.loadData("Module:Entity Lookup/data")

local p = {}
p.entities = prototypes.entities


-- p.getname{args={"FreedomImplant"}}
function p.getname(frame, entid) -- {{#invoke:Entity Lookup|getname|ProtoID}}
    local out = ""
    local id = ""
    if frame.args[1] ~= nil then id = frame.args[1] 
    else id = entid end
    local entity = p.entities[id]
    if entity ~= nil then
        out = entity.name
    else
        out = "Не найдено"
    end
return out
end


-- p.getname{args={"FreedomImplant"}}
function p.getdesc(frame, entid) -- {{#invoke:Entity Lookup|getdesc|ProtoID}}
    local out = ""
    local id = ""
    if frame.args[1] ~= nil then id = frame.args[1] 
    else id = entid end
    local entity = p.entities[id]
    if entity ~= nil then
        out = entity.desc
    else
        out = "Не найдено"
    end
return out
end


-- p.createtexttooltip{args={"Верхний текст", "FreedomImplant", "Файл:Honks.gif"}}
function p.createtexttooltip(frame) -- {{#invoke:Entity Lookup|createtexttooltip|Текст|ProtoID|img=картиночка}}
    local out = " "
    local entity = p.entities[frame.args[2]]
    local stats = frame:preprocess("{{Особое|".. frame.args[2] .."}}")
    if entity ~= nil then do
    	if frame.args["img"] ~= nil then do
    		out = frame:preprocess("{{Tooltip|".. frame.args[1] .."|".. entity.name .."|".. entity.desc .."|".. stats .."|img=".. frame.args["img"] .."}}")
    	end else
    		out = frame:preprocess("{{Tooltip|".. frame.args[1] .."|".. entity.name .."|".. entity.desc .."|".. stats .."}}")
    	end
    -- {{Tooltip|Текст|[[картиночка|64x64px|left|middle|link=]] Название|Описание}}
    end else
       out = frame:preprocess("{{Tooltip|".. frame.args[1] .."|Не найден|Предмет не найден|img=Mousegif.gif}}")
    end
    return out
end


-- p.createimagetooltip{args={"Файл:Honks.gif", "FreedomImplant", Статы="Имеет 3 заряда"}}
function p.createimagetooltip(frame) -- {{#invoke:Entity Lookup|createimagetooltip|Картинка|ProtoID|Мета=мета|Статы=статы}}
    local out = " "
    local entity = p.entities[frame.args[2]]
    local pic = frame.args[1]
    local meta = frame.args["Мета"]
    local stats = frame:preprocess("{{Особое|".. frame.args[2] .."}}")
    if meta == nil then
        meta = "64x64px|link="
    end
    meta = meta:gsub(',', '|')
    pic = "[[" .. frame.args[1] .. "|" .. meta .. "]]"
    if entity ~= nil then do
    	if frame.args[1] ~= nil then do
    		out = frame:preprocess("{{Tooltip|".. pic .. "|" .. entity.name .. "|" .. entity.desc .. "|" .. stats .."}}")
    	end else
    		out = frame:preprocess("{{Tooltip|[[Файл:Mousegif.gif|64x64px|left|middle|link=]]|" .. entity.name .. "|" .. entity.desc .. "|" .. stats .."}}")
    	end
    -- {{Tooltip|Текст|[[картиночка|64x64px|left|middle|link=]] Название|Описание}}
    end else
       out = frame:preprocess("{{Tooltip|" .. pic .. "|Не найден|Предмет не найден|img=Mousegif.gif}}")
    end
    return out
end


return p