有兽档案馆
搜索
切换搜索
切换菜单
切换个人菜单
查看“Module:CharactersAppearanceNodes”的源代码
来自有兽档案馆
阅读
查看源代码
查看历史
模块
讨论
更多操作
←
Module:CharactersAppearanceNodes
因为以下原因,您没有权限编辑该页面:
您所请求的操作,仅限具有
注册用户
、
自动确认用户
、
管理员
、
界面管理员
、
优质编辑者
、
确认用户
、
巡查员
、
档案理事员
等
权限
的
用户
执行。
若您尚未登录有兽档案馆账号,请您
登录
有兽档案馆账号后操作。
您尚未完成电子邮件确认,因此操作受限,请尽快
完成电子邮件确认
。
若您无法完成前述手续,请通过适当渠道请求管理员或档案理事员协助。
您可以查看和复制此页面的源代码。
若您无权编辑本页面,您可以
提出编辑请求
,提请有权限者代为编辑。
local p = {} --当角色列表更新时请更改这里 local namelist={"天禄","辟邪","辟邪的小鸡","四不像","兔爷","青鸟","二两","八斤","瓦猫","Lady瓦","吐宝神鼬","獬豸","谢兰兰","小山雀","刍狗","小山雀的孩子们","兜兜","小勺","巴陵君","巴狗蛋","巴赫","永夜","壮壮","盘湖","猫猫泪","慕容雪川","花椒","天尊","金角","银角","土蝼","英招","谛听","擎火","阿飘","骷髅猫","骷髅鼠","骷髅鱼头","芝麻","骷猫猫","魔王松鼠","小饼","嗷嗷","福仔","翔太","牧","犬张子","战虎","核桃","夹竹桃","棉桃","云豆","始麒麟","玉麒麟","四不相","糖麒麟","四一星","兔三星","皮七星","凤星星","荔枝","葡萄","花蕊鸟","凤皇","经纪鸽","风凰","金翅大鹏","经纪鸦","孔雀","比比","克里斯蒂娜","饕餮","梼杌","穷奇","穷大长","混沌","帝江","三足金乌","金十","擎天树","老金人","白泽","小白泽","地藏菩萨","九月","哪吒","敖烈","哮天","大毛","敖丙","豆豆","安东尼","麒麟舅舅","徐哼唧","苍天","大地","徐大山","睚眦","金沙","米乌拉","猫大爷","青子","虹虹","彩虹云","双皮奶","黄四","黄五","陈思德","耳鼠","乐乐","鲶鱼精","宇佐见","绿子","智纪","小樱","狐狸长老","当康","小沙","水萝卜精","骷髅锦鲤","储备粮","喳喳","诸犍","老八哥","波波","米糖","令狐紫"} local function inlist(value) for _, v in ipairs(namelist) do if v == value then return true end end return false end function p.list( frame ) --查询角色是否符合规定的函数 local char1=frame.args[1] -- 判断如果角色名1是空值则返回“输入角色名称” if char1=="" or nil then return frame:expandTemplate{title="Error", args={"请输入角色名称"}} end if inlist(char1)==false then return frame:expandTemplate{title="Error", args={'以下角色不在[[属性:OnCamera:character name]]规定的角色列表内:' .. char1}} end local char2=frame.args[2] if char2 ~= "" then if inlist(char2)==false then return frame:expandTemplate{title="Error", args={'以下角色不在[[属性:OnCamera:character name]]规定的角色列表内:' .. char2}} end end -- 定义话别个数查询函数,character为角色名,kind为出场类型。下同 local function askcount(char1,char2) local countlist={} local summarylist={} local character=nil local askkind=nil local summaryall=nil -- 如果角色名2为空,则只查询角色名1,否则同时查询二者 if char2=="" then character=char1 else character=char1.."||"..char2 end -- 根据kind不同的值对askkind(话别出场类型的查询参数)赋不同的值 local kindlist={"全部","主要","次要","背景"} for _,i in ipairs(kindlist) do if i == "全部" then askkind = "" else askkind = "[[OnCamera:type::"..i.."]]" end countlist[i] = mw.smw.ask("[[OnCamera:character name::"..character.."]]"..askkind.."|?OnCamera:number=|mainlabel=-|sort=OnCamera:number|limit=1000|format=count") if i == "全部" then summaryall=char1.."在档案馆已有条目的漫画中一共出现了"..countlist["全部"].."话,其中有" else if countlist[i]==0 then summarylist[i]="" else if i=="主要" then summarylist[i]=countlist[i].."话作为"..i.."角色出场" else summarylist[i]=",有"..countlist[i].."话作为"..i.."角色出场" end end end end result=summaryall..summarylist["主要"]..summarylist["次要"]..summarylist["背景"].."。\n" return result end local function asklist(char1,char2,kind) local character=nil -- 如果角色名2为空,则只查询角色名1,否则同时查询二者 if char2=="" then character=char1 else character=char1.."||"..char2 end local res = mw.smw.ask("[[OnCamera:character name::"..character.."]][[OnCamera:type::"..kind.."]]|?OnCamera:number=|mainlabel=-|sort=OnCamera:number|limit=1000") return res end local function listoutput(nlist) -- 创建一个空的字符串result local result = "" -- 创建一个空的table类型的变量groups,用来存放不同范围的数字序列 local groups = {} -- 遍历nlist中的每个元素,判断它属于哪个范围,并加入到相应的序列中 for _, v in ipairs(nlist) do local num=tonumber(v[1]) if num then -- 检查数值是否为整百 local isWholeHundred = num % 100 == 0 -- 计算元素所属的范围的索引,例如100以内的索引是1,100-200之间的索引是2,以此类推 local index = math.floor(num / 100) + (isWholeHundred and 0 or 1) -- 如果索引在1到9之间,才进行处理 -- 当最新话别的整百话出现变更时(如8xx到9xx),请更改这里 if index >= 1 and index <= 10 then -- 如果groups中还没有该索引对应的序列,就创建一个空的序列 if not groups[index] then groups[index] = {} end -- 把元素加入到该索引对应的序列中 table.insert(groups[index], num) end end end -- 遍历groups中的每个序列,如果有值,就用符号“·”拼接为字符串,并加入到result中 -- 当最新话别的整百话出现变更时(如8xx到9xx),请更改这里 for i = 1, 10 do -- 如果groups中有该索引对应的序列,就进行处理 if groups[i] then if i==1 then period="第1~100话" -- 当最新话别的整百话出现变更时(如8xx到9xx),请更改这里 elseif i==10 then period="第901话及以后" else period="第"..tostring(i-1).."01~"..tostring(i).."00话" end result = result ..frame:expandTemplate{title="Hide", args={period,"[[第"..table.concat(groups[i], "话]]·[[第").."话]]"}} end end return result end -- 程序正式开始 output=askcount(char1,char2) local typelist={"主要","次要","背景"} for _,i in ipairs(typelist) do nodes=asklist(char1,char2,i) if nodes~=nil then output=output..frame:expandTemplate{title="Hide", args={"作为"..i.."角色出场",listoutput(nodes)}} end end return output end function p.appearance( frame ) local kind=frame.args[1] local ordertype="" if kind=="first" then ordertype="" end if kind=="latest" then ordertype="|order=desc" end local character=frame.args[2] if character=="" or nil then return frame:expandTemplate{title="Error", args={"请输入角色名称"}} end if inlist(character)==false then return frame:expandTemplate{title="Error", args={'以下角色不在[[属性:OnCamera:character name]]规定的角色列表内:' .. character}} end local res=mw.smw.ask("{{#ask:[[OnCamera:character name::"..character.."]]|mainlabel=-|?OnCamera:number=|sort=OnCamera:number"..ordertype.."|limit=1|searchlabel=}}") return "[[第"..res[1][1].."话]]" end return p
该页面使用的模板:
Module:Arguments
(
查看源代码
)
Module:CharactersAppearanceNodes
(
查看源代码
)
Module:CharactersAppearanceNodes/doc
(
查看源代码
)
Module:Documentation
(
查看源代码
)
Module:Fullurl
(
查看源代码
)
Module:No globals
(
查看源代码
)
Module:Page name
(
查看源代码
)
Module:Yesno
(
查看源代码
)
返回
Module:CharactersAppearanceNodes
。