모듈:SimMD5: 두 판 사이의 차이

리버티게임(개발), 모두가 만들어가는 자유로운 게임
둘러보기로 이동 검색으로 이동
백괴게임>Gustmd7410
잔글편집 요약 없음
백괴게임>Gustmd7410
잔글편집 요약 없음
19번째 줄: 19번째 줄:
value = tonumber(string.format("0x%s", string.sub(hash, index, index + 1)))
value = tonumber(string.format("0x%s", string.sub(hash, index, index + 1)))
if not (index == 11) then
if (index == 11) then
value = value / 2.55 * 3
else
value = value / 2.55
value = value / 2.55
end
end

2018년 6월 25일 (월) 20:15 판


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

마법의 MD-5 시뮬레이터 등에서 사용되는 스탯 계산 모듈입니다.


local p = {}
	
	function p.stat (frame)
		local hash = mw.hash.hashValue("md5", frame.args[1])
		local data = frame.args[2]
		
		local key = ""
		local index = 1
		local value = 0
		local stat = {}
		while (index < 12) do
			if (index == 1) then key = "attack"
			elseif (index == 3) then key = "quick"
			elseif (index == 5) then key = "defense"
			elseif (index == 7) then key = "hit"
			elseif (index == 9) then key = "luck"
			elseif (index == 11) then key = "HP"
			end
			
			value = tonumber(string.format("0x%s", string.sub(hash, index, index + 1)))
			if (index == 11) then
				value = value / 2.55 * 3
			else
				value = value / 2.55
			end
			
			stat[key] = math.floor(value + 0.5)
			
			index = index + 2
		end
		
		if (data == "JSON") then
			stat = mw.text.jsonEncode(stat)
		else
			stat = stat[data]
		end
		return stat
	end
	
return p