Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
thoughts about making duplicate upvalues
Jackmcbarn (talk | contribs)
m Reverted edits by Jackmcbarn (talk) to last version by Le Deluge
Tags: Replaced Rollback
 
(75 intermediate revisions by 2 users not shown)
Line 1:
local getTarget = require('Module:Redirect').getTarget
local p = {}
 
local function makeCounterpagetype(nsText)
return nsText == '' and 'articles' or (mw.ustring.lower(nsText) .. ' pages')
local counter = 0
return function()
counter = counter + 1
return counter
end
end
 
function p.main(frame)
local myCountercurrentTitle = makeCountermw.title.getCurrentTitle()
local target = getTarget(currentTitle)
myCounter()
if target then
myCounter()
local currentNsText, targetNsText = currentTitle.nsText, mw.title.new(target).nsText
myCounter()
if currentNsText ~= targetNsText then
myCounter()
return string.format('[[:Category:Cross-namespace redirects from %s]][[:Category:Cross-namespace redirects to %s]]', pagetype(currentNsText), pagetype(targetNsText))
myCounter() -- this returns 5
end
local newCounter = myCounter
end
newCounter() -- this returns 6
return '[[:Category:Pages incorrectly tagged as cross-namespace redirects]]'
return myCounter() -- this returns 7, since newCounter and myCounter are really the same thing. is there any way to make a copy of a function that doesn't share upvalues?
end