Module:Guidance: Difference between revisions

From The Audiovisual Identity Database
Jump to navigation Jump to search
imported>Pingu
No edit summary
imported>Pingu
No edit summary
Line 1: Line 1:
local p = {} --p stands for package
local p = {} --p stands for package


rs = {}
r = { --keyword, short name, formatted name, severity
rs[1] = "graphic violence or gore";
{ "flashing",
rs[2] = "[[:wikipedia:photosensitive epilepsy|flashing images]]";
"flashing images",
rs[3] = "[[:wikipedia:jump scare|jump scares]]";
"[[:wikipedia:photosensitive epilepsy|flashing images]]",
rs[4] = "sexual content";
"1",
},
{ "graphic",
"graphic violence",
"graphic violence or gore",
"2",
},
{ "jumpscare",
"jump scares",
"[[:wikipedia:jump scare|jump scares]]",
"1",
},
{ "sexual",
"sexual content",
"sexual content",
"2",
}
}


rv    = {};
rv[1] = "flashing"
rv[2] = "graphic"
rv[3] = "jumpscare"
rv[4] = "sexual"
function p.reasons(frame)
function p.reasons(frame)
for i = 4,1,-1
for i = 4,1,-1
do
do
if string.find(frame.args[1], rv[i]) then
if string.find(frame.args[1],r[i][1]) then
if ro == nil then
if ro == nil then
ro = rs[i]
ro = r[i][3]
elseif string.find(ro,", and") then
elseif string.find(ro,", and ") then
ro = rs[i]..", "..ro
ro = r[i][3]..", "..ro
else
else
ro = rs[i]..", and "..ro
ro = r[i][3]..", and "..ro
end
end
end
end
end
end
return ro
return ro;
end
end


function p.warn1(frame)
function p.warn_1(frame)
if string.find(frame.args[1], rv[1] or rv[3]) then
for i = 4,1,-1
rw1 = 1
do
if string.find(frame.args[1],r[i][1]) and (r[i][4] == 2) then
if (w1 == nil) then
w1 = r[i][2]
elseif string.find(w1," and ") then
w1 = r[i][2]..", "..w1
else
w1 = r[i][2].." and "..w1
end
end
end
end
return rw1
return w1;
end
end
 
function p.warn2(frame)
function p.warn_2(frame)
if string.find(frame.args[1], rv[2] or rv[4]) then
for i = 4,1,-1
rw2 = 1
do
if string.find(frame.args[1],r[i][1]) and (r[i][4] == 1) then
if w2 == nil then
w2 = r[i][2]
elseif string.find(w2," and ") then
w2 = r[i][2]..", "..w2
else
w2 = r[i][3].." and "..w2
end
end
end
end
return rw2
return w2;
end
end


return p
return p

Revision as of 05:37, 21 November 2022

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

local p = {} --p stands for package

r = { --keyword, short name, formatted name, severity
	{	"flashing",
		"flashing images",
		"[[:wikipedia:photosensitive epilepsy|flashing images]]",
		"1",
	},
	{	"graphic",
		"graphic violence",
		"graphic violence or gore",
		"2",
	},
	{	"jumpscare",
		"jump scares",
		"[[:wikipedia:jump scare|jump scares]]",
		"1",
	},
	{	"sexual",
		"sexual content",
		"sexual content",
		"2",
	}
}

function p.reasons(frame)
	for i = 4,1,-1
	do
		if string.find(frame.args[1],r[i][1]) then
			if ro == nil then
				ro = r[i][3]
			elseif string.find(ro,", and ") then
				ro = r[i][3]..", "..ro
			else
				ro = r[i][3]..", and "..ro
			end
		end
	end
	return ro;
end

function p.warn_1(frame)
	for i = 4,1,-1
	do
		if string.find(frame.args[1],r[i][1]) and (r[i][4] == 2) then
			if (w1 == nil) then
				w1 = r[i][2]
			elseif string.find(w1," and ") then
				w1 = r[i][2]..", "..w1
			else
				w1 = r[i][2].." and "..w1
			end
		end
	end
	return w1;
end
	
function p.warn_2(frame)
	for i = 4,1,-1
	do
		if string.find(frame.args[1],r[i][1]) and (r[i][4] == 1) then
			if w2 == nil then
				w2 = r[i][2]
			elseif string.find(w2," and ") then
				w2 = r[i][2]..", "..w2
			else
				w2 = r[i][3].." and "..w2
			end
		end
	end
	return w2;
end

return p