본문으로 이동
  • 이 서버는 리버티게임의 개발용 베타 서버로, 게임 플레이 용도로 제작된 사이트가 아닙니다.
  • 리버티게임의 자동 인증된 사용자라면 개발에 필요한 관리자 권한을 신청할 수 있습니다.
  • 틀 및 기능별 소도구를 필요한 문서에만 선택적으로 로딩하는 테스트를 진행하고 있습니다. 작동하지 않는 문서가 있다면 담당자에게 알려주세요.

모듈:한글조합: 두 판 사이의 차이

리버티게임(개발), 모두가 만들어가는 자유로운 게임
백괴게임>Gustmd7410
잔글편집 요약 없음
백괴게임>Gustmd7410
편집 요약 없음
3번째 줄: 3번째 줄:
function p.typ(frame)
function p.typ(frame)
local han = mw.text.jsonDecode(frame:expandTemplate{title = '모듈:한글조합/변환'})
local han = mw.text.jsonDecode(frame:expandTemplate{title = '모듈:한글조합/변환'})
local text = frame.args[1]
local text = frame.args[1]
local key = frame.args[2]
local key = frame.args[2]
-- text의 마지막 글자를 확인 (-3)
-- 종성부터 확인
-- 자음 .. 모음 => 초성 .. 중성
local last = text:sub(-3)
-- 중성 .. 모음 => 중성(else 모음)
local left = text:sub(1, -4)
-- 중성 .. 자음 => 중성 .. 종성
-- 종성 .. 자음 => 종성(else 자음)
local keycode = mw.ustring.codepoint(key)
-- 종성 .. 모음 => 초성 .. 중성
local lastcode = mw.ustring.codepoint(last)
-- return text .. key
if (0x3131 <= lastcode and lastcode <= 0x314E) then -- 자음
if (0x314F <= keycode and keycode <= 0x3163) then -- 모음
return left .. han.letter.cho[last] .. han.letter.jung[key] -- 초성 .. 중성
else return text .. key end
elseif (0x1161 <= lastcode and lastcode <= 0x1175) then -- 중성
if (0x314F <= keycode and keycode <= 0x3163) then -- 모음
return left .. (han.letter.jung[last .. key] or last .. key) -- 중성 or 중성 .. 모음
elseif (0x3131 <= keycode and keycode <= 0x314E) then -- 자음
return text .. han.letter.jong[key] -- .. 종성
else return text .. key end
elseif (0x11A8 <= lastcode and lastcode <= 0x11C2) then -- 종성
if (0x3131 <= keycode and keycode <= 0x314E) then -- 자음
return left .. (han.letter.jong[last .. key] or last .. key) -- 종성 or 종성 .. 초성
elseif (0x314F <= keycode and keycode <= 0x3163) then -- 모음
return left .. han.jong.cho[last] .. han.letter.jung[key] -- (종성 .. 초성) .. 중성
else return text .. key end
else return text .. key end
end
end


return p
return p

2018년 7월 29일 (일) 03:14 판


모듈 설명문서[보기] [편집] [역사] [새로 고침]

틀:한글입력기틀:입력기를 위한 윤희코드 한글 조합 모듈입니다.


local p = {}

function p.typ(frame)
	local han = mw.text.jsonDecode(frame:expandTemplate{title = '모듈:한글조합/변환'})
	
	local text = frame.args[1]
	local key = frame.args[2]
	
	local last = text:sub(-3)
	local left = text:sub(1, -4)
	
	local keycode = mw.ustring.codepoint(key)
	local lastcode = mw.ustring.codepoint(last)
	
	if (0x3131 <= lastcode and lastcode <= 0x314E) then -- 자음
		if (0x314F <= keycode and keycode <= 0x3163) then -- 모음
			return left .. han.letter.cho[last] .. han.letter.jung[key] -- 초성 .. 중성
		else return text .. key end
	elseif (0x1161 <= lastcode and lastcode <= 0x1175) then -- 중성
		if (0x314F <= keycode and keycode <= 0x3163) then -- 모음
			return left .. (han.letter.jung[last .. key] or last .. key) -- 중성 or 중성 .. 모음
		elseif (0x3131 <= keycode and keycode <= 0x314E) then -- 자음
			return text .. han.letter.jong[key] -- .. 종성
		else return text .. key end
	elseif (0x11A8 <= lastcode and lastcode <= 0x11C2) then -- 종성
		if (0x3131 <= keycode and keycode <= 0x314E) then -- 자음
			return left .. (han.letter.jong[last .. key] or last .. key) -- 종성 or 종성 .. 초성
		elseif (0x314F <= keycode and keycode <= 0x3163) then -- 모음
			return left .. han.jong.cho[last] .. han.letter.jung[key] -- (종성 .. 초성) .. 중성
		else return text .. key end
	else return text .. key end
end

return p