Module:LSEvent: Difference between revisions

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Jump to navigation Jump to search
Content deleted Content added
Mayhalke (talk | contribs)
Undo revision 992755 by Mayhalke (talk)
Tag: Undo
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local p = {}
local p = {}


local lsEventsData = mw.loadData('Module:LSEvents/data')
-- Load the data from Module:LSEvent/data
local events = mw.loadData('Module:LSEvent/data')


function p.main(frame)
function p.main(frame)
-- Retrieve the event code passed in the template
local eventKey = frame.args[1]
local eventData = lsEventsData[eventKey] or {}
local eventCode = frame.args[1]

-- Get the event name corresponding to the code
local eventName = eventData.eventName or ""
local description = eventData.description or ""
local eventName = events[eventCode]

mw.log(frame.args[1])
return eventName, description
mw.log(eventCode)
mw.log(eventName)
-- If the event name is found, return a formatted link
if eventName then
return string.format('[[Last Survivor/Events#%s|%s]]', eventName, eventName)
else
-- If the event code is not found, return a message or empty string
return "Event not found"
end
end
end



Latest revision as of 00:33, 2 September 2024

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

local p = {}

-- Load the data from Module:LSEvent/data
local events = mw.loadData('Module:LSEvent/data')

function p.main(frame)
    -- Retrieve the event code passed in the template
    local eventCode = frame.args[1]
    
    -- Get the event name corresponding to the code
    local eventName = events[eventCode]
    
    mw.log(frame.args[1])
    mw.log(eventCode)
    mw.log(eventName)
    
    -- If the event name is found, return a formatted link
    if eventName then
        return string.format('[[Last Survivor/Events#%s|%s]]', eventName, eventName)
    else
        -- If the event code is not found, return a message or empty string
        return "Event not found"
    end
end

return p