跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
快速跳转
快速上手
登场角色
歌曲列表
成就指南
任务指南
DLC购买指南
其他企划
CDC赛事
DJMAX Ent
DJMAX中文资料库
搜索
搜索
外观
外观
移至侧栏
隐藏
创建账号
登录
个人工具
创建账号
登录
查看“︁模块:Db”︁的源代码
模块
讨论
English
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
页面信息
←
模块:Db
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} local valueTypes = mw.loadData('Module:Autovalue/types') local groupsConfig = mw.loadData('Module:Autovalue/groups') local i18n = { ['true'] = '是', ['false'] = '否', ['none'] = '\'\'无\'\'', ['error_raw_only'] = '<span class="error">Autovalue:数据类型"%s"只能通过tryGetRawValue方法获取值。</span>', ['category_unknown_value_type'] = '未知自动值类型', ['category_missing_value'] = '缺失%s', ['content_or'] = '或', ['grouping_others'] = '其他', } local function tableHasValue (targetTable, targetValue) for index, value in ipairs(targetTable) do if value == targetValue then return true end end return false end local function IsSameArray(arr1, arr2) if #arr1 ~= #arr2 then return false end for i, entry in ipairs(arr1) do if not tableHasValue (arr2, entry) then return false end end return true end local function ValueTypeExist(valueType) return valueTypes[valueType] ~= nil end local function MappingKey(key, mappingName) return p.getRawValue(key, mappingName) or key end local function GetValuesTable(valueType, onlyBE) local values if valueTypes[valueType].beTable then values = mw.loadData('Module:' .. valueType .. ' values') end return values end local function MappingValueFull(mappingFullName, value) local mapping = mw.loadData(mappingFullName) if mapping[value] then return mapping[value] else return value end end local function MappingValue(mappingName, value) return MappingValueFull('Module:db/' .. mappingName .. ' mapping', value) end local function ValueFromValuesByKey(values, key) local value = values[key] --if value == nil then -- value = values[key:gsub('s$', '')] --end if value == nil then value = values['__fallback'] end return value end -- 键映射方法。 local keyMappingMethod = { } local valueGettingMethod = { } -- 将true和false分别转换为'是'和'否'。 local function TrueFalueMapping (value) if value == true then return i18n['true']; elseif value == false then return i18n['false']; else return value end end -- 为数字添加逗号分隔符。 local function FormatNumber (value) if type(value) == 'number' then local i, j, minus, int, fraction = tostring(value):find('([-]?)(%d+)([.]?%d*)') int = int:reverse():gsub("(%d%d%d)", "%1,") return minus .. int:reverse():gsub("^,", "") .. fraction else return value end end local function FormatRomanNumber(value) local roman = require( [[Module:Roman number]] ).toroman(value) if roman then return roman end return FormatNumber (value) end local function EmptyStringToNone(value) if value == '' then return i18n['none'] end return value end -- 值映射方法,不设置则输出原值。 --数值类 local valueMappingMethod = { ['4b_nm_difficulty'] = FormatNumber, --布尔类 ['key_sound'] = TrueFalueMapping, ['key_sound2'] = (function (value) if value == true then return 'true'; elseif value == false then return 'false'; else return value end end), --字符串类 ['composer'] = (function (value) return MappingValue('composer', value) end), } -- 提供类型名称、键值名称来获取值。返回原始数据类型。 local function tryGetRawValue(valueType, targetName) if type(keyMappingMethod[valueType]) == 'function' then targetName = keyMappingMethod[valueType](targetName) elseif type(valueTypes[valueType].keyMap) == 'string' then targetName = MappingKey(targetName, valueTypes[valueType].keyMap) end if type(valueGettingMethod[valueType]) == 'function' then return valueGettingMethod[valueType](targetName) else return ValueFromValuesByKey(GetValuesTable(valueType), targetName) end end -- 提供类型名称、键值名称来获取值。返回值应当是字符串。 local function tryGetValue(valueType, targetName) if valueTypes[valueType].rawOnly then return string.format( i18n['error_raw_only'], valueType ) end local value = tryGetRawValue(valueType, targetName) if type(valueMappingMethod[valueType]) == 'function' then return valueMappingMethod[valueType](value) else return value end end -- 获取值。 local function GetValue(targetName, argType, argMode, nocat) if not ValueTypeExist(argType) then return '?[[Category:'..i18n['category_unknown_value_type']..']]' end local value local category = '' local result value = tryGetValue(argType, targetName) if value == nil then if valueTypes[argType].noNullError then value = i18n['none'] else value = '?' end end --707 741 end
该页面使用的模板:
模块:Db/doc
(
查看源代码
)
返回
模块:Db
。
搜索
搜索
查看“︁模块:Db”︁的源代码
添加话题