Wikipedia talk:Lua
![]() | To help centralize discussions and keep related topics together, all Wikipedia:Lua subpages' talk pages and Help talk:Lua redirect here. |
![]() | The content of Wikipedia:Lua/Requests was merged into Wikipedia talk:Lua on 5 February 2016. The former page's history now serves to provide attribution for that content in the latter page, and it must not be deleted as long as the latter page exists. |
![]() | Wikipedia:Lua/To do was nominated for deletion on 21 May 2015. The result of the discussion was keep. |
This page has archives. Sections older than 90 days may be auto-archived by ClueBot III if there are more than 1. |
Rewrite backend of Template:Afd-merged-from
[edit]Thanks to Tule-hog's work at Template talk:Copied#Backend rewrite, the backend of {{Afd-merged-from}} can be rewritten to invoke Module:Copied, much like the rewrite at Template talk:Merged-from#Backend rewrite. Because I have zero experience in such matters: is this a bad idea? If potentially controversial, would I ask VPT or some other venue? FWIW, consensus for rewriting {{merged-from}} was assessed at Wikipedia:Templates for discussion/Log/2025 March 12#Template:Merged-from (no consensus against rewriting the backend of the merged-from template, so long as it doesn't affect functionality
). Thanks in advanced! Rotideypoc41352 (talk · contribs) 19:02, 16 June 2025 (UTC)
- What do you think would make it potentially a bad idea? There's no issue with using one module for multiple templates, which is the only concern I can conceive someone potentially having. Izno (talk) 19:11, 16 June 2025 (UTC)
- Less concept- and more implementation-wise: I just don't know how much Module:Copied would need to be changed, and if adding to the module to minimize changes to Afd-merged-from is a good idea.
- When I copied merged-from's code to Template:Afd-merged-from/sandbox and changed it, the results at Template:Afd-merged-from/testcases (unsurprisingly) look like {{merged-from|...|afd=...}}. This brought up three questions:
- Should I also change Module:Copied to keep the original wording of Afd-merged-from, especially
The discussion was closed on {{{3}}}
missing from the merged-from lookalikes? - Invoking the module allows the template to fail more gracefully.
- At the moment, omitting the AfD page name from
{{Afd-merged-from/sandbox}}
documents a normal merge unrelated to a deletion discussion. Should it instead assume the AfD page name and the merge source are the same? That is, adding{{{1}}}}
to form|afd1={{{afd|{{{afd1|{{{2|{{{1}}}}}}}}}}}}
? - Or should it instead not fail gracefully if that parameter is missing?
- At the moment, omitting the AfD page name from
- Should I also change Module:Copied to keep the original wording of Afd-merged-from, especially
- If I need to clarify something, please feel free to let me know. Thank you! Rotideypoc41352 (talk · contribs) 02:23, 17 June 2025 (UTC)
- I'll change as little as possible and see how it goes. Rotideypoc41352 (talk · contribs) 22:47, 24 June 2025 (UTC)
Query
[edit]Hello, I'm hoping I'm posting in the right place. A very new editor just created Module:RandomWikiverse and I'm not sure if it's valid or just some sort of experiment because I know nothing about modules. Can someone who does know something review this page? Thank you, in advance, for your help. Liz Read! Talk! 22:23, 7 July 2025 (UTC)
- Looks like it returns a randomly selected phrase from its list of phrases but seems otherwise pointless
{{#invoke:RandomWikiverse|random}}
→ Rise and Fall of Emperor Quack (refresh this page to get another phrase)
- Nothing in it seems valuable to me so can probably be deleted.
- —Trappist the monk (talk) 22:31, 7 July 2025 (UTC)
- Agreed. Module:Random could do the same thing trivially. * Pppery * it has begun... 22:32, 7 July 2025 (UTC)
- It was created on 28th June, and remains unused. Editor hasn't edited since. Looks like a test that has been completed. It should be deleted or moved under Module:Sandbox. —CX Zoom[he/him] (let's talk • {C•X}) 16:51, 10 July 2025 (UTC)
Regex help
[edit]Any LUA Regex experts who might be able to help me? Trying to write a regex with an or statement in it but my understanding is that LUA doesn’t support or statements in their regexes. So for example if I’m trying to detect a month in a date I would normally do something like:
\d+\s*(Jan|January|Feb|February|…)\s*\d{4}
How can I achieve the same result with a regex in LUA? —Zackmann (Talk to me/What I been doing) 18:36, 17 September 2025 (UTC)
- The first idea that comes to my mind is just using a regular
(%a+)
catch and then manually checking the content of the group in lua code to see if it matches a known month, since lua regex is far more simplistic than standard regexes. Aidan9382 (talk) 18:44, 17 September 2025 (UTC)- As did I:
string.match ("17 September 2025", "%d+%s*(%a+)%s*%d%d%d%d")
– validate the returned value as a next step- Or one of these:
mw.language.getContentLanguage():formatDate ("M", "17 September 2025")
– returnsSep
mw.language.getContentLanguage():formatDate ("F", "17 September 2025")
– returnsSeptember
mw.language.getContentLanguage():formatDate ("m", "17 September 2025")
– returns09
mw.language.getContentLanguage():formatDate ("n", "17 September 2025")
– returns9
- —Trappist the monk (talk) 18:57, 17 September 2025 (UTC)