https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3ALoadData Module:LoadData - Revision history 2025-05-25T23:42:40Z Revision history for this page on the wiki MediaWiki 1.45.0-wmf.2 https://en.wikipedia.org/w/index.php?title=Module:LoadData&diff=1047451199&oldid=prev MusikBot II: Protected "Module:LoadData": High-risk template or module: 398 transclusions (more info) ([Edit=Require autoconfirmed or confirmed access] (indefinite)) 2021-09-30T22:57:10Z <p>Protected &quot;<a href="/wiki/Module:LoadData" title="Module:LoadData">Module:LoadData</a>&quot;: <a href="/wiki/Wikipedia:High-risk_templates" title="Wikipedia:High-risk templates">High-risk template or module</a>: 398 transclusions (<a href="/wiki/User:MusikBot_II/TemplateProtector" title="User:MusikBot II/TemplateProtector">more info</a>) ([Edit=Require autoconfirmed or confirmed access] (indefinite))</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <tr class="diff-title" lang="en"> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 22:57, 30 September 2021</td> </tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div> </td></tr></table> MusikBot II https://en.wikipedia.org/w/index.php?title=Module:LoadData&diff=1020204549&oldid=prev GKFX: Create more complex version of Module:Data with more options. 2021-04-27T19:46:53Z <p>Create more complex version of Module:Data with more options.</p> <p><b>New page</b></p><div>local p = {}<br /> <br /> -- Finds the next key key &lt;= or &gt;= the given i.<br /> -- operator is ±1<br /> local function findItemRange(data, i, operator)<br /> local bestIndex = nil<br /> i = i * operator<br /> for k, v in pairs(data) do<br /> local kop = type(k) == &#039;number&#039; and k * operator<br /> if kop and kop &lt;= i and (bestIndex == nil or kop &gt; bestIndex * operator) then<br /> bestIndex = k<br /> end<br /> end<br /> if bestIndex then return data[bestIndex] else return nil end<br /> end<br /> <br /> local function load(datamodule, frame)<br /> local args = frame.args<br /> local data = mw.loadData(datamodule)<br /> for i = 1, 20 do<br /> if args[i] then data = data[tonumber(args[i]) or args[i]]<br /> elseif args[i .. &#039; lteq&#039;] then<br /> data = findItemRange(data, tonumber(args[i .. &#039; lteq&#039;]), 1)<br /> elseif args[i .. &#039; gteq&#039;] then<br /> data = findItemRange(data, tonumber(args[i .. &#039; gteq&#039;]), -1)<br /> else break end<br /> end<br /> <br /> if data == nil then<br /> return args[&#039;if_nil&#039;] -- not a required argument, OK to return nil here.<br /> end<br /> <br /> if type(data) == &#039;table&#039; then<br /> -- Put the table into another table because the return value of loadData<br /> -- is a &quot;fake&quot; table that only has certain metamethods.<br /> local realdata = {}<br /> for k, v in pairs(data) do<br /> realdata[k] = v<br /> end<br /> data = realdata<br /> else<br /> data = { data }<br /> end<br /> <br /> if args[&#039;template&#039;] then<br /> return mw.text.unstripNoWiki(args[&#039;template&#039;]):format(unpack(data))<br /> elseif args[&#039;preprocess&#039;] then<br /> return frame:preprocess(mw.text.unstripNoWiki(args[&#039;preprocess&#039;]):format(unpack(data)))<br /> else<br /> return table.concat(data)<br /> end<br /> end<br /> <br /> return setmetatable({}, {<br /> __index = function(t, k)<br /> return function(frame)<br /> return load(&#039;Module:&#039; .. k, frame)<br /> end<br /> end<br /> })</div> GKFX