Module:ItemEffect
From He is Coming Official Wiki
Documentation for this module may be created at Module:ItemEffect/doc
-- Module:ItemEffect
local p = {}
-- List of keywords & colors comes from ColorText
local colorModule = require("Module:ColorText") -- Adjusted for subspace if needed
-- Main function: fetch effect content and color keywords
function p.main(frame)
local itemName = frame.args[1] or ""
if itemName == "" then return "" end
-- Construct the effect page title under He_is_Coming
local effectTitle = mw.title.new(itemName .. "/effect", "He_is_Coming")
if not effectTitle or not effectTitle.exists then
return "Effect page not found: " .. itemName .. "/effect"
end
local effectContent = effectTitle:getContent() or ""
if effectContent == "" then return "(No effect text)" end
-- Color each keyword using ColorText
local function colorKeyword(word)
return colorModule.main({ args = { word } })
end
-- Simple pattern to find keywords (adjust if needed)
-- Only match words that exist in ColorText's color table
effectContent = effectContent:gsub("%w+", function(w)
local lower = w:lower()
if colorModule.colors and colorModule.colors[lower] then
return colorKeyword(w)
else
return w
end
end)
return effectContent
end
return p


