Module:Script-IS: Difference between revisions

From Mizuumi Wiki
Jump to navigation Jump to search
(working on color coding inputs)
(added entire combo support)
Line 28: Line 28:


--color code and format game inputs
--color code and format game inputs
--supports entire combos as arguments
function p.gameInput(frame)
function p.gameInput(frame)
local input = frame.args[1]
local button = input:sub(-1, -1)
local str = frame.args[1]
switch = {
local sep = " "
["L"] = "#81D5FE",
local inputs = {}
["M"] = "#FEFE20",
--split combo terms
["H"] = "#FE8E71",
for str in string.gmatch(str, "([^"..sep.."]+)") do
["S"] = "#F3A4FE",
table.insert(inputs, str)
["G"] = "#F3A4FE",
end
["X"] = "#808080"
}
for index, input in ipairs(inputs) do
local color = switch[button]
local button = string.sub(input, -1, -1)
if (color==nil) then
color = "#000000"
--recognized buttons
switch = {
["L"] = "#81D5FE",
["M"] = "#FEFE20",
["H"] = "#FE8E71",
["S"] = "#F3A4FE",
["G"] = "#F3A4FE",
["X"] = "#808080"
}
 
local color = switch[button]
if (color==nil) then
color = "#000000"
end
local start = "<span style=\"font-weight:bold;color:"
local mid = ";\">"
local endstr = "</span>"
local cterm = start .. color .. mid .. input .. endstr
inputs[index] = cterm
end
end
local start = "<span style=\"font-weight:bold;color:"
local mid = ";\">"
local ret = table.concat(inputs, " ")
local endstr = "</span>"
local ret = start .. color .. mid .. input .. endstr
return ret
return ret

Revision as of 03:52, 27 May 2023

Documentation for this module may be created at Module:Script-IS/doc

local p = {}

--custom script for the IS wiki, feel free to make a copy of it or take any part of the code for other wikis

--split multiple properties passed as a single param to a template call and return the converted property text
function p.multiprop(frame)
	
	local str = frame.args[1]
	local sep = ","
	local t={}
	--split properties
	for str in string.gmatch(str, "([^"..sep.."]+)") do
			table.insert(t, str)
	end
	--get the string done
	for index, prop in ipairs(t) do
		if prop:sub(1,1) == "%s" then
			prop = prop:sub(2,-1)
		end
		expanded = frame:expandTemplate{ title="Property-IS", args={prop,"IGNOREPROPERTYERROR"}}
		t[index] = expanded
	end
	
	ret = table.concat(t,", ")
	
	return ret
end

--color code and format game inputs
--supports entire combos as arguments
function p.gameInput(frame)
	
	
	local str = frame.args[1]
	local sep = " "
	local inputs = {}
	--split combo terms
	for str in string.gmatch(str, "([^"..sep.."]+)") do
			table.insert(inputs, str)
	end
	
	for index, input in ipairs(inputs) do
		local button = string.sub(input, -1, -1)
		
		--recognized buttons
		switch = {
			["L"] = "#81D5FE",
			["M"] = "#FEFE20",
			["H"] = "#FE8E71",
			["S"] = "#F3A4FE",
			["G"] = "#F3A4FE",
			["X"] = "#808080"
		}

		local color = switch[button]
		if (color==nil) then
			color = "#000000"
		end
		local start = "<span style=\"font-weight:bold;color:"
		local mid = ";\">"
		local endstr = "</span>"
		local cterm = start .. color .. mid .. input .. endstr
		inputs[index] = cterm
	end
	
	local ret = table.concat(inputs, " ")
	
	return ret
end

return p