Module:Xdnum:修订间差异

此后如竟没有炬火,我便是唯一的光。
跳转到导航 跳转到搜索
无编辑摘要
无编辑摘要
第39行: 第39行:
local vala = {"0","1","2","3","4","5","6","7","8","9","T","n"}
local vala = {"0","1","2","3","4","5","6","7","8","9","T","n"}
local output = numtran(input)
local output = numtran(input)
for ij = #keya,1,-1 do
-- for ij = #keya,1,-1 do
output = string.gsub(output, keya[ij], vala[ij])
-- output = string.gsub(output, keya[ij], vala[ij])
end
-- end
return output
return output
end
end

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

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

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

function numtran(input1)
	local input = string.gsub(string.gsub(input1,"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 = {}
	for ii = #aa,1,-1 do
		cc[aa[ii]]=1
	end
	for ii = #bb,1,-1 do
		dd[bb[ii]]=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
	mw.log(output)
	return output
end

function module.tran(frame)
	local args = getArgs(frame)
	local input = args[1]
	local keya = {"0","1","2","3","4","5","6","7","8","9","T","."}
	local vala = {"0","1","2","3","4","5","6","7","8","9","T","n"}
	local output = numtran(input)
--	for ij = #keya,1,-1 do
--		output = string.gsub(output, keya[ij], vala[ij])
--	end	
	return output
end

return module