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

мНет описания правки
м Замена текста — «Mousegif.gif» на «MobMouse2.png»
 
(не показана 61 промежуточная версия 3 участников)
Строка 1: Строка 1:
local prototypes = mw.loadData("Module:Entity Lookup/data")
local prototypes = mw.loadData("Module:Entity Lookup/data")
local overrides = mw.loadData("Module:Entity Lookup/names")


local p = {}
local p = {}
p.entities = prototypes.entities
p.entities = prototypes.entities
p.name_overrides = overrides.name_overrides or {}


function p.createtooltip(frame) -- {{#invoke:Entity Lookup|createtooltip|Текст|ProtoID|картиночка}}
 
-- p.getname{args={"FreedomImplant"}}
function p.getname(frame, entid) -- {{#invoke:Entity Lookup|getname|ProtoID}}
local id = frame.args and frame.args[1] or entid
if not id then return "Не найдено" end
 
local override = p.name_overrides[id]
if override then
return override
end
 
local entity = p.entities[id]
if entity then
return entity.name
end
 
return "Не найдено"
end
 
 
-- p.getidbyname{args={"Швабра"}}
function p.getidbyname(frame, entname) -- {{#invoke:Entity Lookup|getidbyname|Название}}
local name = frame.args and frame.args[1] or entname
if not name then return "Не найдено" end
 
for id, overrideName in pairs(p.name_overrides) do
if overrideName == name then
return id
end
end
 
for id, entity in pairs(p.entities) do
if entity.name == name then
return id
end
end
 
return "Не найдено"
end
 
 
-- p.getname{args={"FreedomImplant"}}
function p.getdesc(frame, entid) -- {{#invoke:Entity Lookup|getdesc|ProtoID}}
     local out = ""
     local out = ""
     mw.log(out)
     local id = ""
     local entity = p.entities[frame.args[3]]
     if frame.args[1] ~= nil then id = frame.args[1]  
     mw.log(entity)
     else id = entid end
     if entity ~= nil then do
    local entity = p.entities[id]
    -- {{Tooltip|Текст|Название|Описание|[[картиночка|64x64px|left|middle|link=]]}}
     if entity ~= nil then
         out = frame:expandTemplate{ title = "tooltip", args = { frame.args[1],  entity.name, entity.desc, "[[" .. frame.args[3] .. "|64x64px|left|middle|link=]]"} }
         out = entity.desc
        mw.log(out)
     else
     end else
        out = "Не найдено"
      out = frame:expandTemplate{ title = "tooltip", args = { frame.args[1],  "Не найден", "Предмет не найден", "[[Файл:Mousegif.gif|64x64px|left|middle|link=]]"} }
      mw.log(out)
     end
     end
    return out
return out
end
 
 
-- p.createtexttooltip{args={"Верхний текст", "FreedomImplant", "Файл:Horns.png"}}
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 .."|".. string.gsub(entity.desc, "\n", "<br>") .."|".. stats .."|img=".. frame.args["img"] .."}}")
end else
out = frame:preprocess("{{Tooltip|".. frame.args[1] .."|".. entity.name .."|".. string.gsub(entity.desc, "\n", "<br>") .."|".. stats .."}}")
end
-- {{Tooltip|Текст|[[картиночка|64x64px|left|middle|link=]] Название|Описание}}
end else
  out = frame:preprocess("{{Tooltip|".. frame.args[1] .."|Не найден|Предмет не найден|img=MobMouse2.png}}")
end
return out
end
end
-- p.createimagetooltip{args={"Файл:Horns.png", "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 .."|no-text-decoration=1}}")
end else
out = frame:preprocess("{{Tooltip|[[Файл:MobMouse2.png|64x64px|left|middle|link=]]|" .. entity.name .. "|" .. entity.desc .. "|" .. stats .."|no-text-decoration=1}}")
end
-- {{Tooltip|Текст|[[картиночка|64x64px|left|middle|link=]] Название|Описание}}
end else
  out = frame:preprocess("{{Tooltip|" .. pic .. "|Не найден|Предмет не найден|img=MobMouse2.png|no-text-decoration=1}}")
end
return out
end
return p