Module:Xdnum:修订间差异

此后如竟没有炬火,我便是唯一的光。
荆哲留言 | 贡献
无编辑摘要
荆哲留言 | 贡献
无编辑摘要
第13行: 第13行:
local keya = {"0","1","2","3","4","5","6","7","8","9","T","."}
local keya = {"0","1","2","3","4","5","6","7","8","9","T","."}
local vala = {"","","","","","","","","","","",""}
local vala = {"","","","","","","","","","","",""}
for ii in aa do
for ii,vv in pairs(aa) do
cc[ii]=1
cc[vv]=1
end
end
for ii in bb do
for ii,vv in pairs(bb) do
dd[ii]=1
dd[vv]=1
end
end
for i = 1,string.len(input) do
for i = 1,string.len(input) do

2021年9月7日 (二) 17:27的版本

此模块的文档可以在Module:Xdnum/doc创建

local module = {}
local getArgs = require('Module:Arguments').getArgs

function module.tran(frame)
	local args = getArgs(frame)
	local input = string.gsub(string.gsub(args[1],"n","."),"T","0")
	local output = ""
	local bj = 0
	local aa = {"0","1","2","3","4","5","6","7","8","9"}
	local bb = {"1","2","3","4","5","6","7","8","9"}
	local cc = {}
	local dd = {}
	local keya = {"0","1","2","3","4","5","6","7","8","9","T","."}
	local vala = {"","","","","","","","","","","",""}
	for ii,vv in pairs(aa) do
		cc[vv]=1
	end
	for ii,vv in pairs(bb) do
		dd[vv]=1
	end
	for i = 1,string.len(input) do
		if (cc[string.sub(input,i,i)]==nil) then
			bj = 2
		end
		if (bj==0 and dd[string.sub(input,i,i)]==1) then
			bj = 1
		end
		if (bj==1 and string.sub(input,i,i)=="0") then
			output = output.."T"
		else
			output = output..string.sub(input,i,i)
		end
	end
	for i = #keya,1,-1 do
		output = string.gsub(output, keya[i], vala[i])
	end	
	return output
end

return module