Модуль:Песочница/Pok/2

Материал из Space Station 14 Вики

Для документации этого модуля может быть создана страница Модуль:Песочница/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