local p = {}
local all = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = '模块:GameTag/All_js' } )
local i18n = {
['WrongID'] = "'''未知的ID或无标签'''[[Category:未知的ID]]",
['WrongTag'] = "'''未知的标签'''[[Category:未知标签]]",
['WrongType'] = "'''未知的标签类型[[Category:未知标签]]'''",
['EmptyType'] = "'''空标签类型[[Category:空标签类型]]'''"
}
function p.main(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
end
--'blocks','items','entity_types','fluids','game_events'
local objtype
if args[1] == 'block' or args[1] == 'blocks' then
objtype='blocks'
end
if args[1] == 'item' or args[1] == 'items' then
objtype='items'
end
if args[1] == 'entity_type' or args[1] == 'entity_types' or args[1] == 'entity'then
objtype='entity_types'
end
if args[1] == 'fluid' or args[1] == 'fluids' then
objtype='fluids'
end
if args[1] == 'game_event' or args[1] == 'game_events' then
objtype='game_events'
end
if not all['tag_ori'][args[1]] then
return i18n['WrongType']
end
if not args[1] or args[1] == '' then
return i18n['EmptyType']
end
local outtable = {}
local id = string.gsub(string.lower(args[2] or ''),' ','_')
if args['tagpage'] == '1' or args['tagpage'] == 'y' or args['tagpage'] == 'true' then
if all['tag_ori'][objtype][id] then
for i,v in ipairs(all['tag_ori'][objtype][id]) do
if string.find(v,'#') == 1 then
table.insert(outtable,
--[[#blocks flowers|#flowers]]
table.concat({
'[[#',
objtype,
' ',
string.sub(v,12),
'|#',
string.sub(v,12),
']]'
})
)
else
table.insert(outtable,string.sub(v,11))
end
end
else
return i18n['WrongTag']
end
return table.concat(outtable,', ')
else
if all['ID'][objtype][id] then
for i,v in ipairs(all['ID'][objtype][id]) do
table.insert(outtable,v)
end
return table.concat(outtable,',')
else
return i18n['WrongID']
end
end
end
return p
Advertisement
Advertisement