We are actively looking for staff to help us build the wiki. If you are interested please join our Discord server and apply.

Module:QuestListModule

From Moonbounce Wiki
Jump to navigation Jump to search

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

-- Module:QuestListModule
local p = {}

function p.displayList(frame)
  -- Get the first argument passed to the module
  local itemList = frame.args[1]
  -- Split the string into a table based on the comma delimiter
  local items = mw.text.split(itemList, ',')
  -- Initialize the result string
  local result = ""

  -- If no items are found, add "Nothing" to the list
  if #items == 0 then
    items = {"Nothing"}
  end

  -- if the item is wrapped in brackets, remove them
  for i, item in ipairs(items) do
    items[i] = item:gsub("%[", ""):gsub("%]", "")
  end

  -- Iterate over the items and create a div element for each
  for i, item in ipairs(items) do
    item = mw.text.trim(item)

    -- Open the div element 
    result = result .. '<div class="list_item" style="display: flex; gap: 5px;">'
    -- Add the image and item name to the div element
    result = result .. item
    -- Close the div element
    result = result .. '</div>\n'
  end

  return result
end

return p