本站文本内容除另有声明外,转载时均必须注明出处,并遵守CC BY-NC-SA 3.0协议。(转载须知
本站是中文Minecraft Wiki的镜像站,与Mojang Studios、Weird Gloop没有从属关系。(免责声明

全站通知:

模块:Sandbox/Star00/sandbox

来自我的世界地下城WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索
[创建 | 历史 | 清除缓存]文档页面
此模板没有文档页面。如果你知道此模板的使用方法,请帮助为其创建文档页面。
local p={}

function p.try(frame)
	return frame:preprocess("其他{{Template:SPConversion|SPConversion}}文本")
end
function table.unique(t, bArray)
    local check = {}
    local n = {}
    local idx = 1
    for k, v in pairs(t) do
        if not check[v] then
            if bArray then
                n[idx] = v
                idx = idx + 1
            else
                n[k] = v
            end
            check[v] = true
        end
    end
    return n
end

function get_len(tb)
  local len = 0
  for k,v in pairs(tb) do
    len= len+1
  end
return len
end

function p.user_manage(frame)
	--输入讨论的文本,输出和User有关的转换部分table
	--1-4分别为发言条数,发言人数,发起人,最后发言的人。
	local text=mw.getCurrentFrame():expandTemplate{ title = "User:Star00/sandbox" }
	text=string.gsub(text, "Special:用户贡献/", "User:ip:")
	local match=string.gmatch (text,"User:([^\n]-)%|[^\n]-UTC")
	local userlist={}
	local user,firstuser,lastuser="","",""
	local i=1
	while true
	do
		user=match()
		if user==nil then break end
		lastuser=user
		if i==1 then firstuser=user end 
		userlist[i]=user
		i=i+1
	end
	local user_len=get_len(userlist)
	local user_len_ind=get_len(table.unique(userlist))
	local result={user_len,user_len_ind,firstuser,lastuser}
	
	return tostring(result[1]..result[3])
end

return p