function warp_portal.get_game_info()
    if core.get_game_info then return core.get_game_info(); end;
    local gameid = Settings(core.get_worldpath().."/world.mt"):get("gameid");
    return { id=gameid, title="", author="", path="" };
end;

function warp_portal.impact(default, vars)
    for game, value in pairs(vars) do
        if (warp_portal.get_game_info().id == game) then
            return value;
        end;
    end;
    return default;
end;

function warp_portal.var_impact(equation, var, rtn)
    if (equation == true) then return var; end;
    return rtn;
end;

function warp_portal.storage_add(storage, key, value)
    if not storage.get_keys then
        local keys = storage:get_string(warp_portal.storage_id);
        storage:set_string(warp_portal.storage_id, keys.."||"..key);
    end;
    
    storage:set_string(key, value);
end;

function warp_portal.storage_get_keys(storage)
    if storage.get_keys then return storage:get_keys(); end;
    local str_keys = storage:get_string(warp_portal.storage_id);
    local keys = {};
    for key in string.gmatch(str_keys, "([^||]+)") do
        table.insert(keys, key);
    end;
    return keys;
end;

function warp_portal.storage_remove(storage, key)
    if not storage.get_keys then
        local key_list = warp_portal.storage_get_keys(storage);
        key_list[key] = nil; keys = "";
        for i, ckey in pairs(key_list) do
            if (keys ~= "") then keys = keys.."||"; end;
            keys = keys..ckey;
        end;
        
        storage:set_string(warp_portal.storage_id, keys);
    end;
    
    storage:set_string(key, "");
end;

function warp_portal.table_merge(tbl, tbl2)
    tbl = table.copy(tbl);
    for key, value in pairs(tbl2) do
        tbl[key] = value;
    end;
    return tbl;
end;