มอดูล:Requested books
เอกสารการใช้งานสำหรับมอดูลนี้อาจสร้างขึ้นที่ มอดูล:Requested books/doc
local p = {}
local random = require('Module:Math')._random
function p.main(frame)
total = tonumber(frame.args[1])
links = {}
content = mw.title.new('วิกิตำรา:ตำราที่ต้องการ'):getContent()
for thlink, enlink in content:gmatch('* %[%[(%S-)%]%] %(%[%[(:en:%S-)%]%]%)') do
if not thlink:find(']', 1, true) then
table.insert(links, {thlink, enlink})
end
end
selected = {}
out = {}
while #out < total do
num = random(#links)
if not selected[num] then
selected[num] = true
table.insert(out, '[[' .. links[num][1] .. ']][[' .. links[num][2] .. '|^]]')
end
end
return table.concat(out, ' ')
end
return p