COM_AddCommand("supercolor", function(p, str)
    if not (p and p.mo and p.mo.valid) then
        CONS_Printf(p, "You must be in a level to use this.")
        return
    end
	if not str then
		if p.scolorstring == nil
			CONS_Printf(p,"supercolor [argument] - This command will change your super color. Use 'list' as an argument to see what colors you can use!")
		else
			CONS_Printf(p,"supercolor [argument] - This command will change your super color. Use 'list' as an argument to see what colors you can use!")
		end
	return end

	str = $:lower()
	
	if str == "list"
		CONS_Printf(p,
		"\n" ..
		"List of valid Super Colors are:\n" ..
		"\n" ..
		"Base Game Super Colors\n" ..
		"----------------\n" ..
		"\x85"+"Red\n" ..
		"\x87"+"Orange\n" ..
		"\x82"+"Gold\n" ..
		"\x8B"+"Peridot\n" ..
		"\x88"+"Sky\n" ..
		"\x89"+"Purple\n" ..
		"\x87"+"Rust\n" ..
		"\x8D"+"Tan\n" ..
		"\x86"+"Silver\n" ..
		"\n" ..
		"\x80"+"Extra Super Colors\n" ..
		"------------\n" ..
		"\x83"+"Mint\n" ..
		"\x81"+"Bubblegum\n" ..
		"\x84"+"Sapphire\n" ..
		"\x88"+"Wave\n" ..
		"\x87"+"Copper\n" ..
		"\x85"+"Ruby\n" ..
		"\x80"+"Aether\n" ..
		"\x85"+"Burning\n" ..
		"\x83"+"Emerald\n" ..
		"\x89"+"Lavender\n" ..
		"\x8E"+"Rosy\n" ..
		"\x81"+"Raspberry\n" ..
		"\x84"+"Dark\n" ..
		"\x8D"+"Brown\n" ..
		"\x81"+"Magenta\n" ..
		"\x89"+"PurpleRust\n" ..
		"\x82"+"RedGold\n" ..
		"\x85"+"RoseGold\n" ..
		"\x84"+"Cobalt\n" ..
		"\x87"+"Sunset\n" ..
		"\x86"+"Jet\n" ..
		"\x82"+"Topaz\n" ..
		"\x88"+"Aquatic\n" ..
		"\x89"+"Grape\n" ..
		"\x82"+"Lemon\n" ..
		"\x86"+"Chrome\n" ..
		"\x82"+"Radiance\n" ..
		"\x87"+"Discovery\n" ..
		"\x85"+"Redemption\n" ..
		"\x8E"+"Lovestruck\n" ..
		"\x83"+"Vortex\n" ..
		"\n" ..
		"\x80"+"None\n" ..
		"\n" ..
		"Use the Page Up/Page Down keys to scroll the list.\n"..
		"If you want to use a regular skin color, put 'n_' at the start of your color name!\n"..
		"If you happen to know the internal name of a super color not part of this list, you can use that too!" ..
		"\n")
	//Yeah so let's just say a friend by the name of Bloops helped this script not suck -Icezer
	elseif str == "default"
		p.scolor = str
		p.scolorstring = "Default"
		CONS_Printf(p,"Super Color set to Default!")
	elseif str == "none"
		p.scolor = str
		p.scolorstring = "None"
		CONS_Printf(p,"Super Color set to None!")
	elseif str:find('n_') != nil
	and R_GetColorByName(str:sub(str:find('n_')+2))
		p.scolor = R_GetColorByName(str:sub(str:find('n_')+2))
		p.scolorstring = "N_ Colour"
		CONS_Printf(p,"Super Color set!")
	elseif R_GetSuperColorByName(str)
		p.scolor = R_GetSuperColorByName(str)
	//	p.scolorstring = skincolors[R_GetColorByName(str)].name
		CONS_Printf(p,"Super Color set!")
		p.scolorstring = "Super Color"
	else
		CONS_Printf(p,"Please enter a valid Super Color.")
	end
end)

addHook("PlayerThink", function(p)
	if not (p and p.mo and p.mo.valid and p.powers[pw_super]) return end
	if (p.scolor == "default" or p.scolor == nil) return end
	if (p.scolor == "none")
		p.mo.color = p.skincolor
	--end
	--elseif p.scolor
	elseif p.scolor
		for i = 0, 4
			if p.mo.color == skins[p.mo.skin].supercolor + i
				if p.scolorstring == "N_ Colour"
					p.mo.color = R_GetColorByName(p.scolor)
				else
					p.mo.color = p.scolor + i
				end
			end
		end
	end
end)

//2.2.10 will let this hook set the ghost's colors properly, too.
//Thanks to Mari0shi06 for tweaking this to work better.
addHook("MobjThinker", function(ghost)
    if ghost and ghost.valid
		if not ((ghost.target) and (ghost.target.valid)) return end
		if not ((ghost.target.player) and (ghost.target.player.valid)) return end
		if (ghost.color == skins[ghost.target.skin].supercolor) or (ghost.color == skins[ghost.target.skin].supercolor+1) or (ghost.color == skins[ghost.target.skin].supercolor+2) or (ghost.color == skins[ghost.target.skin].supercolor+3) or (ghost.color == skins[ghost.target.skin].supercolor+4)
			if ghost.target.player.powers[pw_super] >= 2
				ghost.color = ghost.target.color
			end
		end
	end
end, MT_GHOST)