Cafeinlove (메시지 담벼락 | 기여) 편집 요약 없음 태그: sourceedit |
Cafeinlove (메시지 담벼락 | 기여) (author 코멘트 추가) 태그: sourceedit |
||
(같은 사용자의 중간 판 16개는 보이지 않습니다) | |||
1번째 줄: | 1번째 줄: | ||
+ | -- 포켓몬 도감 관련 모듈 |
||
⚫ | |||
+ | -- @Author: [[User:Cafeinlove]] at ko.pokemon.wikia.com |
||
+ | -- @License: MIT License |
||
⚫ | |||
⚫ | |||
+ | |||
⚫ | |||
+ | -- Dependencies |
||
⚫ | |||
⚫ | |||
⚫ | |||
− | local |
+ | local dex = dex or mw.loadData( 'Module:Pokedex/Data' ) |
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | local args = getArgs( frame ) |
||
− | local dexKey = args[1] |
||
+ | -- [[틀:번2포]] |
||
⚫ | |||
+ | function pokedex.getName ( index ) |
||
+ | return dexData[index] or '없는 번호입니다.' |
||
end |
end |
||
+ | -- [[틀:포번앞]] |
||
⚫ | |||
+ | function pokedex.getPrevIndex ( index ) |
||
− | local args = getArgs( frame ) |
||
− | local currentIndex = tonumber( |
+ | local currentIndex = tonumber( index ) |
local prevIndex = ( currentIndex > 1 ) and ( currentIndex - 1 ) or dexSize |
local prevIndex = ( currentIndex > 1 ) and ( currentIndex - 1 ) or dexSize |
||
⚫ | |||
return string.format( '%03d', prevIndex ) |
return string.format( '%03d', prevIndex ) |
||
end |
end |
||
+ | -- [[틀:포번뒤]] |
||
− | function Pokedex.nextIndex ( frame ) |
||
+ | function pokedex.getNextIndex ( index ) |
||
− | local args = getArgs( frame ) |
||
− | local currentIndex = tonumber( |
+ | local currentIndex = tonumber( index ) |
local nextIndex = ( currentIndex < dexSize ) and ( currentIndex + 1 ) or 1 |
local nextIndex = ( currentIndex < dexSize ) and ( currentIndex + 1 ) or 1 |
||
⚫ | |||
return string.format( '%03d', nextIndex ) |
return string.format( '%03d', nextIndex ) |
||
end |
end |
||
⚫ | |||
− | |||
+ | -- [[틀:폼문자]] |
||
− | function Pokedex.formData ( frame ) |
||
+ | function pokedex.getFormLetter ( name ) |
||
+ | local ret = forms[name] and forms[name][2] or '없는 폼입니다.' |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | -- [[틀:폼이름]] |
||
+ | function pokedex.getFormName ( name ) |
||
+ | local ret = forms[name] and forms[name][1] or '없는 폼입니다.' |
||
+ | return ret |
||
+ | end |
||
⚫ | |||
⚫ | |||
local args = getArgs( frame ) |
local args = getArgs( frame ) |
||
− | local |
+ | local requested = args['request'] |
− | local |
+ | local result = pokedex[requested] and pokedex[requested]( args[1] ) |
+ | |||
− | |||
− | + | return result |
|
− | |||
− | for key, value in pairs( forms ) do |
||
− | if value[1] == formName then |
||
− | if requested == 'fullname' then |
||
− | return value[2] |
||
− | elseif requested == 'initial' then |
||
− | return value[3] |
||
− | end |
||
− | end |
||
⚫ | |||
end |
end |
||
− | return |
+ | return pokedex |
2017년 2월 1일 (수) 09:18 판
이 모듈에 대한 설명문서는 모듈:Pokedex/설명문서에서 만들 수 있습니다
-- 포켓몬 도감 관련 모듈
-- @Author: [[User:Cafeinlove]] at ko.pokemon.wikia.com
-- @License: MIT License
local pokedex = {}
-- Dependencies
local getArgs = getArgs or require( 'Module:Arguments' ).getArgs
local dex = dex or mw.loadData( 'Module:Pokedex/Data' )
local dexSize = dexSize or dex.size
local dexData = dexData or dex.data
local forms = forms or mw.loadData( 'Module:Pokedex/Forms' )
-- [[틀:번2포]]
function pokedex.getName ( index )
return dexData[index] or '없는 번호입니다.'
end
-- [[틀:포번앞]]
function pokedex.getPrevIndex ( index )
local currentIndex = tonumber( index )
local prevIndex = ( currentIndex > 1 ) and ( currentIndex - 1 ) or dexSize
return string.format( '%03d', prevIndex )
end
-- [[틀:포번뒤]]
function pokedex.getNextIndex ( index )
local currentIndex = tonumber( index )
local nextIndex = ( currentIndex < dexSize ) and ( currentIndex + 1 ) or 1
return string.format( '%03d', nextIndex )
end
-- [[틀:폼문자]]
function pokedex.getFormLetter ( name )
local ret = forms[name] and forms[name][2] or '없는 폼입니다.'
return ret
end
-- [[틀:폼이름]]
function pokedex.getFormName ( name )
local ret = forms[name] and forms[name][1] or '없는 폼입니다.'
return ret
end
function pokedex.main( frame )
local args = getArgs( frame )
local requested = args['request']
local result = pokedex[requested] and pokedex[requested]( args[1] )
return result
end
return pokedex