Module:Minor planet meaning link: Difference between revisions
Appearance
Content deleted Content added
always forget this |
Tom.Reding (talk | contribs) m -concat ws |
||
Line 18: | Line 18: | ||
local subsec = string.sub(tostring(num + 1000), -3) |
local subsec = string.sub(tostring(num + 1000), -3) |
||
if (num <= 1000) then |
if (num <= 1000) then |
||
link = "Meanings of minor planet names: 1–1000#" |
link = "Meanings of minor planet names: 1–1000#"..subsec |
||
else |
else |
||
local pagefrom = math.floor((num - 1) / 1000) |
local pagefrom = math.floor((num - 1) / 1000) |
||
local pageto = pagefrom + 1 |
local pageto = pagefrom + 1 |
||
link = "Meanings of minor planet names: " |
link = "Meanings of minor planet names: "..pagefrom.."001–"..pageto.."000#"..subsec |
||
end |
end |
||
if (args[2] == nil) then |
if (args[2] == nil) then |
||
result = "[[" |
result = "[["..link.."]]" |
||
else |
else |
||
result = "[[" |
result = "[["..link.."|"..args[2].."]]" |
||
end |
end |
||
return result |
return result |
Revision as of 17:53, 26 January 2025
Implements {{Minor planet meaning link}}
local p = {}
function p.MoMP(frame)
-- For calling from #invoke.
local pframe = frame:getParent()
local args = pframe.args
return p._MoMP(args)
end
function p._MoMP(args)
local link, result
-- For calling from other Lua modules.
local num = tonumber(args[1])
if not num then
local warning = require('Module:If preview')._warning
return warning({'Non-numeric or missing asteroid number'})
end
local subsec = string.sub(tostring(num + 1000), -3)
if (num <= 1000) then
link = "Meanings of minor planet names: 1–1000#"..subsec
else
local pagefrom = math.floor((num - 1) / 1000)
local pageto = pagefrom + 1
link = "Meanings of minor planet names: "..pagefrom.."001–"..pageto.."000#"..subsec
end
if (args[2] == nil) then
result = "[["..link.."]]"
else
result = "[["..link.."|"..args[2].."]]"
end
return result
end
return p