Модуль:Песочница/Pok/2: различия между версиями
Материал из Space Station 14 Вики
< Модуль:Песочница | Pok
Pok (обсуждение | вклад) Полностью удалено содержимое страницы Метка: очистка |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
local p = {} | |||
local STORE = {} | |||
local function curKey() | |||
local t = mw.title.getCurrentTitle() | |||
if not t then return nil end | |||
return t.prefixedText | |||
end | |||
function p.set(frame) | |||
local args = frame and frame.args or {} | |||
local path = args.path or args[1] or args.base or "" | |||
path = mw.text.trim(tostring(path or "")) | |||
if path == "" then return "" end | |||
local key = curKey() | |||
if not key then return "" end | |||
STORE[key] = path | |||
return "" | |||
end | |||
function p.get(frame) | |||
local key = curKey() | |||
if not key then return nil end | |||
return STORE[key] | |||
end | |||
function p.clear(frame) | |||
local key = curKey() | |||
if key then STORE[key] = nil end | |||
return "" | |||
end | |||
return p | |||
Версия от 05:24, 18 марта 2026
Для документации этого модуля может быть создана страница Модуль:Песочница/Pok/2/doc
local p = {}
local STORE = {}
local function curKey()
local t = mw.title.getCurrentTitle()
if not t then return nil end
return t.prefixedText
end
function p.set(frame)
local args = frame and frame.args or {}
local path = args.path or args[1] or args.base or ""
path = mw.text.trim(tostring(path or ""))
if path == "" then return "" end
local key = curKey()
if not key then return "" end
STORE[key] = path
return ""
end
function p.get(frame)
local key = curKey()
if not key then return nil end
return STORE[key]
end
function p.clear(frame)
local key = curKey()
if key then STORE[key] = nil end
return ""
end
return p