Module:FindOptions

From Fallen London Wiki

Documentation for this module may be created at Module:FindOptions/doc

local p = {}

-- (if the construction pattern in Template:Options changes,
--  please remember to also change search_pattern accordingly!)
local search_pattern = 
	'<h3.-%[%[' .. '(.-)' .. '%]%]' .. '(.-)' .. '</h3>'

function p.main(frame)
	-- table of all found action name strings
	local actions = '' 
	
	-- wiki text of page to embed that we want to find option names in,
	-- usually everything following the == Options: == section heading
	local page_text = frame.args[1] or frame:getParent().args[1]
	
	-- loop over matches found in page text
	for action_name, extra_text in mw.ustring.gmatch(page_text, search_pattern) do
		local option =
            '{{Options|'
            .. mw.ustring.gsub(action_name, '|', '{{!}}', 1)
            .. '|' .. extra_text .. '}}'
		actions = actions .. '<li>' .. option .. [[</li>
]]
    end
    actions = frame:preprocess(actions)
	return actions
end
 
return p