VOOZH about

URL: https://minecraft.wiki/w/Module:DidYouKnow

⇱ Module:DidYouKnow – Minecraft Wiki


Module:DidYouKnow

From Minecraft Wiki
Jump to navigation Jump to search
Documentation[view] [edit] [history] [purge]Jump to code ↴

Implements {{DidYouKnow}}. All individual hooks are stored and can be added at Module:DidYouKnow/facts.

[view] [edit] [history] [purge]The above documentation is transcluded from Module:DidYouKnow/doc.
localp={}
localfactTable=require("Module:DidYouKnow/facts")
localfunctiongetAllFacts(factTable,factsType)
localfacts=factTable.facts
iffactsType=='dungeons'then
facts=factTable.dungeons
elseiffactsType=='legends'then
facts=factTable.legends
elseiffactsType=='movie'then
facts=factTable.movie
elseiffactsType=='storymode'then
facts=factTable.storymode
elseiffactsType=='earth'then
facts=factTable.earth
end
returnfacts
end
localfunctionformatFact(factText)
return"* ... that "..factText.."?"
end
functionp.getFacts(frame)
localfacts=getAllFacts(factTable,frame:getParent().args['type']or'minecraft')
locals=""
locallength=#facts
localcount=math.min(length,tonumber(frame:getParent().args['count'])or8)
ifframe:getParent().args['random']then
math.randomseed(os.time())
else
-- Different random seed every day (displays the same set of facts for a day, then a different set the next day, etc.)
math.randomseed(math.floor(os.time()/(60*60*24))*2)-- *2 so that we will have a different set of facts compared to Fandom
end
-- Ensure duplicate facts are not displayed
localchosen={}
while#chosen<countdo
localrandom=math.random(1,length)
localisPresent=false
fori,vinipairs(chosen)do
ifv==randomthen
isPresent=true
break
end
end
ifnotisPresentthen
table.insert(chosen,random)
end
end
-- Now we actually get to write the output.
localresult={}
fori,vinipairs(chosen)do
result[i]=formatFact(facts[v])
end
returntable.concat(result,"\n")
end
localfunctionformatFactList(facts)
locallength=#facts
localresult={}
fori=1,lengthdo
result[i]=formatFact(facts[i])
end
returntable.concat(result,"\n")
end
-- List all facts. Intended to allow easier debugging.
functionp.listAllFacts(frame)
localfacts=getAllFacts(factTable,frame.args['type']or'minecraft')
returnformatFactList(facts)
end
functionp.listEditcopyFacts(frame)
localeditcopyFacts=require("Module:DidYouKnow/facts/editcopy")
localfacts=getAllFacts(editcopyFacts,frame.args['type']or'minecraft')
returnformatFactList(facts)
end
returnp
Retrieved from "https://minecraft.wiki/w/Module:DidYouKnow?oldid=2883053"

Navigation menu