User:Al97729/sandbox2
Book of darkness[edit | edit source]
-- from a given list of quests, find their quest requirements and add them to a list, ignoring any repeated quests
local p = {}
function p.main(frame) -- retrieve list of quests in json format local q = { '+', '?Quest Requirements', limit = 500, format=json } local all_quests = mw.smw.ask(q)
-- populate table with headers local t = mw.html.create('table')
t :addClass('wikitable sortable products-list align-right-4') :tag('tr') :tag('th') :wikitext('Quests') :done() :tag('th') :wikitext('Skills') :done() :done()
local quests_row = t:tag('tr') local quests_cell = quests_row:tag('td') -- try making data into a checklist
local temp_list = {"%[%[%:Monkey Madness II%|Monkey Madness II%]%]", "%[%[%:Devious Minds%|Devious Minds%]%]"} -- smw_item = full quest smw output -- item = quest link
local required_quests = get_quests(temp_list, all_quests)
local quest_str = "" for _, quest in ipairs(required_quests) do quest_str = quest_str .. quest end quests_cell:wikitext(quest_str)
--[[ for _, smw_item in ipairs(all_quests) do for _, item in ipairs(smw_item) do -- for every quest the user has selected do: if string.find(item, "%[%[%:Monkey Madness II%|Monkey Madness II%]%]") then --quests_cell:wikitext(item) --mw.logObject(smw_item) --take quest requirements and add them to list of required quests --table.insert(required_quests, "test") --mw.log(smw_item["Quest Requirements"]) --take everything from between two brackets [] and put it into a temp array, search through them for any skill name and remove
-- get all links in Requirements local quest_req_links = get_links(smw_item["Quest Requirements"])
-- filter links to remove anything that isnt a quest local filtered_links = filter_links(quest_req_links)
required_quests = add_new_quests(required_quests, filtered_links)
end -- end of if string.find(item,
end -- end of for _,item in ipairs(smw_item)
end -- end of for _,smw_item in ipairs(all_quests)
]]
--[[
-- populate quests cell
local quests_row = t:tag('tr')
local quests_cell = quests_row:tag('td') -- try making data into a checklist
local i = 0
for _,smw_item in ipairs(all_quests) do
for _,item in ipairs(smw_item) do
mw.log(item)
if string.find(item, "Quick guide") then break end -- if its a quick guide, break the loop to prevent duplicate quests showing
quests_cell:wikitext(item .. "
")
end
end
quests_cell:done()
quests_row:done()
]]
--[[ local skills_cell = mw.html.create('td')
local skills_ul = skills_cell:tag('ul') skills_ul:addClass('Item 1') :css({ ['list-style-type'] = 'none', ['list-style-image'] = 'none', margin = 0 }) local skill_li = skills_ul:tag('li') skill_li:wikitext('Test') ]]
return tostring(t) end
function get_links(list) -- filter through quest requirements for links local temp_list = {} for i in string.gmatch(list, "%[%b[]%]") do -- mw.log(i) table.insert(temp_list, i) end return temp_list end -- get_links
function filter_links(links) --filter links so theres only quests left local skills = {"Combat","Attack","Strength","Defence","Ranged","Prayer","Magic","Runecraft","Hitpoints","Crafting","Mining","Smithing","Fishing","Cooking","Firemaking","Woodcutting","Agility","Herblore","Thieving","Fletching","Slayer","Farming","Construction","Hunter"} local num = 0 local list = {} --mw.log("Previous table:") --mw.logObject(links) for _, item in ipairs(links) do table.insert(list, item) for _, skill in ipairs(skills) do if string.find(item, skill) then -- if item is some sort of skill related thing, like an image, etc table.remove(list) break end -- end of if string.find(item, skill) end -- end of for skill in skills num = num + 1 end -- end of for item in links --mw.log("Finished table:") --mw.logObject(list) return list end
function add_new_quests(list, links) -- add non duplicate quests to the quest list for _, new_quest in ipairs(links) do local found = false for _, quest in ipairs(list) do -- if the new quest is the same as quest, dont add, otherwise, add if new_quest == quest then found = true break end -- if new_quest == quest end -- for quest in ipairs(list) if found == false then mw.log("adding new quest " .. new_quest) table.insert(list, new_quest) end end --mw.logObject(list) return list end
function get_quests(quests, all_quests) -- find quests in all quests local required_quests = {} for _, quest in ipairs(quests) do local quest_req_links for _, q in ipairs(all_quests) do --if q[1] == quest then mw.log(q[1]) end if string.find(q[1], quest) then quest_req_links = get_links(q["Quest Requirements"]) local filtered_links = filter_links(quest_req_links) required_quests = add_new_quests(required_quests, filtered_links) end end end --mw.logObject(required_quests) return required_quests end
return p
|37,925
|-
|
|Ancient page 2
|51,178
|-
|
|Ancient page 3
|44,492
|-
|
|Ancient page 4
|54,827 |-
! colspan=3 |Compare
|-
|
|Book of darkness page set
| style="text-align:right;" |221,297 |- ! colspan=2 |Difference | style="text-align:right;" |32,875 |}
Book of law[edit | edit source]
-- from a given list of quests, find their quest requirements and add them to a list, ignoring any repeated quests
local p = {}
function p.main(frame) -- retrieve list of quests in json format local q = { '+', '?Quest Requirements', limit = 500, format=json } local all_quests = mw.smw.ask(q)
-- populate table with headers local t = mw.html.create('table')
t :addClass('wikitable sortable products-list align-right-4') :tag('tr') :tag('th') :wikitext('Quests') :done() :tag('th') :wikitext('Skills') :done() :done()
local quests_row = t:tag('tr') local quests_cell = quests_row:tag('td') -- try making data into a checklist
local temp_list = {"%[%[%:Monkey Madness II%|Monkey Madness II%]%]", "%[%[%:Devious Minds%|Devious Minds%]%]"} -- smw_item = full quest smw output -- item = quest link
local required_quests = get_quests(temp_list, all_quests)
local quest_str = "" for _, quest in ipairs(required_quests) do quest_str = quest_str .. quest end quests_cell:wikitext(quest_str)
--[[ for _, smw_item in ipairs(all_quests) do for _, item in ipairs(smw_item) do -- for every quest the user has selected do: if string.find(item, "%[%[%:Monkey Madness II%|Monkey Madness II%]%]") then --quests_cell:wikitext(item) --mw.logObject(smw_item) --take quest requirements and add them to list of required quests --table.insert(required_quests, "test") --mw.log(smw_item["Quest Requirements"]) --take everything from between two brackets [] and put it into a temp array, search through them for any skill name and remove
-- get all links in Requirements local quest_req_links = get_links(smw_item["Quest Requirements"])
-- filter links to remove anything that isnt a quest local filtered_links = filter_links(quest_req_links)
required_quests = add_new_quests(required_quests, filtered_links)
end -- end of if string.find(item,
end -- end of for _,item in ipairs(smw_item)
end -- end of for _,smw_item in ipairs(all_quests)
]]
--[[
-- populate quests cell
local quests_row = t:tag('tr')
local quests_cell = quests_row:tag('td') -- try making data into a checklist
local i = 0
for _,smw_item in ipairs(all_quests) do
for _,item in ipairs(smw_item) do
mw.log(item)
if string.find(item, "Quick guide") then break end -- if its a quick guide, break the loop to prevent duplicate quests showing
quests_cell:wikitext(item .. "
")
end
end
quests_cell:done()
quests_row:done()
]]
--[[ local skills_cell = mw.html.create('td')
local skills_ul = skills_cell:tag('ul') skills_ul:addClass('Item 1') :css({ ['list-style-type'] = 'none', ['list-style-image'] = 'none', margin = 0 }) local skill_li = skills_ul:tag('li') skill_li:wikitext('Test') ]]
return tostring(t) end
function get_links(list) -- filter through quest requirements for links local temp_list = {} for i in string.gmatch(list, "%[%b[]%]") do -- mw.log(i) table.insert(temp_list, i) end return temp_list end -- get_links
function filter_links(links) --filter links so theres only quests left local skills = {"Combat","Attack","Strength","Defence","Ranged","Prayer","Magic","Runecraft","Hitpoints","Crafting","Mining","Smithing","Fishing","Cooking","Firemaking","Woodcutting","Agility","Herblore","Thieving","Fletching","Slayer","Farming","Construction","Hunter"} local num = 0 local list = {} --mw.log("Previous table:") --mw.logObject(links) for _, item in ipairs(links) do table.insert(list, item) for _, skill in ipairs(skills) do if string.find(item, skill) then -- if item is some sort of skill related thing, like an image, etc table.remove(list) break end -- end of if string.find(item, skill) end -- end of for skill in skills num = num + 1 end -- end of for item in links --mw.log("Finished table:") --mw.logObject(list) return list end
function add_new_quests(list, links) -- add non duplicate quests to the quest list for _, new_quest in ipairs(links) do local found = false for _, quest in ipairs(list) do -- if the new quest is the same as quest, dont add, otherwise, add if new_quest == quest then found = true break end -- if new_quest == quest end -- for quest in ipairs(list) if found == false then mw.log("adding new quest " .. new_quest) table.insert(list, new_quest) end end --mw.logObject(list) return list end
function get_quests(quests, all_quests) -- find quests in all quests local required_quests = {} for _, quest in ipairs(quests) do local quest_req_links for _, q in ipairs(all_quests) do --if q[1] == quest then mw.log(q[1]) end if string.find(q[1], quest) then quest_req_links = get_links(q["Quest Requirements"]) local filtered_links = filter_links(quest_req_links) required_quests = add_new_quests(required_quests, filtered_links) end end end --mw.logObject(required_quests) return required_quests end
return p
|23,348
|-
|
|Armadyl page 2
|36,584
|-
|
|Armadyl page 3
|27,041
|-
|
|Armadyl page 4
|42,782 |-
! colspan=3 |Compare
|-
|
|Book of law page set
| style="text-align:right;" |154,330 |- ! colspan=2 |Difference | style="text-align:right;" |-163,847 |}