Модуль:Entity Lookup: различия между версиями
Pok (обсуждение | вклад) м поддержка суффиксов Метка: отменено |
CL w (обсуждение | вклад) м Замена текста — «Mousegif.gif» на «MobMouse2.png» |
||
| (не показаны 2 промежуточные версии 2 участников) | |||
| Строка 5: | Строка 5: | ||
p.entities = prototypes.entities | p.entities = prototypes.entities | ||
p.name_overrides = overrides.name_overrides or {} | p.name_overrides = overrides.name_overrides or {} | ||
-- p.getname{args={"FreedomImplant"}} | -- p.getname{args={"FreedomImplant"}} | ||
| Строка 11: | Строка 12: | ||
if not id then return "Не найдено" end | if not id then return "Не найдено" end | ||
local override = p.name_overrides[id] | |||
return | if override then | ||
return override | |||
end | end | ||
local entity = p.entities[id] | local entity = p.entities[id] | ||
if entity then | if entity then | ||
return entity.name | |||
end | end | ||
return "Не найдено" | return "Не найдено" | ||
end | end | ||
-- p.getidbyname{args={"Швабра"}} | -- p.getidbyname{args={"Швабра"}} | ||
| Строка 39: | Строка 38: | ||
for id, entity in pairs(p.entities) do | for id, entity in pairs(p.entities) do | ||
if entity.name == name then | |||
return id | return id | ||
end | end | ||
| Строка 51: | Строка 46: | ||
end | end | ||
-- p. | |||
-- p.getname{args={"FreedomImplant"}} | |||
function p.getdesc(frame, entid) -- {{#invoke:Entity Lookup|getdesc|ProtoID}} | 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 | end | ||
-- p.createtexttooltip{args={"Верхний текст", "FreedomImplant", "Файл: | |||
-- p.createtexttooltip{args={"Верхний текст", "FreedomImplant", "Файл:Horns.png"}} | |||
function p.createtexttooltip(frame) -- {{#invoke:Entity Lookup|createtexttooltip|Текст|ProtoID|img=картиночка}} | function p.createtexttooltip(frame) -- {{#invoke:Entity Lookup|createtexttooltip|Текст|ProtoID|img=картиночка}} | ||
local | local out = " " | ||
local | local entity = p.entities[frame.args[2]] | ||
local stats = frame:preprocess("{{Особое|".. frame.args[2] .."}}") | |||
local stats = frame:preprocess("{{Особое|" .. | if entity ~= nil then do | ||
if entity then | 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"] .."}}") | |||
if | end else | ||
out = frame:preprocess("{{Tooltip|".. frame.args[1] .."|".. entity.name .."|".. string.gsub(entity.desc, "\n", "<br>") .."|".. stats .."}}") | |||
else | |||
end | end | ||
-- {{Tooltip|Текст|[[картиночка|64x64px|left|middle|link=]] Название|Описание}} | |||
end else | |||
out = frame:preprocess("{{Tooltip|".. frame.args[1] .."|Не найден|Предмет не найден|img=MobMouse2.png}}") | |||
end | end | ||
return | return out | ||
end | end | ||
-- p.createimagetooltip{args={"Файл: | |||
-- p.createimagetooltip{args={"Файл:Horns.png", "FreedomImplant", Статы="Имеет 3 заряда"}} | |||
function p.createimagetooltip(frame) -- {{#invoke:Entity Lookup|createimagetooltip|Картинка|ProtoID|Мета=мета|Статы=статы}} | function p.createimagetooltip(frame) -- {{#invoke:Entity Lookup|createimagetooltip|Картинка|ProtoID|Мета=мета|Статы=статы}} | ||
local | local out = " " | ||
local meta = frame.args["Мета"] | local entity = p.entities[frame.args[2]] | ||
local stats = frame:preprocess("{{Особое|" .. | 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(',', '|') | 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 | end | ||
-- {{Tooltip|Текст|[[картиночка|64x64px|left|middle|link=]] Название|Описание}} | |||
end else | |||
out = frame:preprocess("{{Tooltip|" .. pic .. "|Не найден|Предмет не найден|img=MobMouse2.png|no-text-decoration=1}}") | |||
end | end | ||
return out | |||
return | |||
end | end | ||
return p | return p | ||