Randomized color stool

Randomized color stool. Titler says it all, basically you use it for… RANDOM colors. As well as an option for random alpha. Hell, maybe even something to randomize the color of everything in X amount of distance.

To be used for the “I want this mass amount of prims colored, but don’t feel like being anal about what I want, I’ll let a random color be decided” moments. It’ll allow me to identify individual prims better, spice things up, etc etc.

I actually have wanted this for things I build for a while, so I will give you free sex and cookies and beer if you do this for me. :smug:

Done in the form of console commands, type “colour” in console to see commands.

[lua]
function ColourCommands( ply ) – Print all the commands in console
ply:PrintMessage( HUD_PRINTCONSOLE, “colour_random” )
ply:PrintMessage( HUD_PRINTCONSOLE, “colour_random_a” )
ply:PrintMessage( HUD_PRINTCONSOLE, “colour_random_object alpha(true/false)” )
ply:PrintMessage( HUD_PRINTCONSOLE, “colour_random_objects onlyprop_physics?(true/false) alphatoo?(true/false) range?(number - default 500)” )
end
concommand.Add( “colour”, ColourCommands )

function RandomColour( ply ) – Generates a random colour for the Colour Tool
ply:ConCommand( "colour_r "…math.random( 0, 255 ) )
ply:ConCommand( "colour_g "…math.random( 0, 255 ) )
ply:ConCommand( "colour_b "…math.random( 0, 255 ) )
end
concommand.Add( “colour_random”, RandomColour )

function RandomAlpha( ply ) – Generates a random alpha digit for the Colour Tool
ply:ConCommand( "colour_a "…math.random( 1, 255 ) )
end
concommand.Add( “colour_random_a”, RandomAlpha )

function ApplyRandomColour( ply, cmd, args ) – Applies a random colour to the object you’re looking at
if args[ 1 ] == nil then
ply:PrintMessage( HUD_PRINTCONSOLE, “colour_random_object alpha(true/false)” )
end

alpha = nil
if tostring( args[ 1 ] ) == "true" or tostring( args[ 1 ] ) == "1" then
    alpha = math.random( 1, 255 )
else
    alpha = 255
end

local trace = ply:GetEyeTrace()
if trace.HitNonWorld then
    trace.Entity:SetColor( math.random( 0, 255 ), math.random( 0, 255 ), math.random( 0, 255 ), alpha )
end

end
concommand.Add( “colour_random_object”, ApplyRandomColour )

function ApplyRandomColours( ply, cmd, args ) – Applies a random colour to the objects in range
range = nil
if args[ 3 ] then
range = args[ 3 ]
else
if args[ 3 ] == nil then
ply:PrintMessage( HUD_PRINTCONSOLE, “colour_random_objects onlyprop_physics?(true/false) alphatoo?(true/false) range?(number - default 500)” )
end
range = 500
end

for k, v in pairs( ents.FindInSphere( ply:GetPos(), range ) ) do
    if v:IsValid() and not v:IsPlayer() and not v:IsNPC() then
        if ( args[ 1 ] == "true" and v:GetClass() == "prop_physics" ) or args[ 1 ] ~= "true" then
            alpha = nil
            if tostring( args[ 2 ] ) == "true" or tostring( args[ 2 ] ) == "1" then
                alpha = math.random( 1, 255 )
            else
                if args[ 2 ] == nil then
                    ply:PrintMessage( HUD_PRINTCONSOLE, "colour_random_objects onlyprop_physics?(true/false) alphatoo?(true/false) range?(number - default 500)" )
                end
                alpha = 255
            end
            v:SetColor( math.random( 0, 255 ), math.random( 0, 255 ), math.random( 0, 255 ), alpha )
        elseif args[ 1 ] == nil then
            ply:PrintMessage( HUD_PRINTCONSOLE, "colour_random_objects onlyprop_physics?(true/false) alphatoo?(true/false) range?(number - default 500)" )
        end
    end
end

end
concommand.Add( “colour_random_objects”, ApplyRandomColours )
[/lua]

Commands are as follows;
colour - command help
colour_random - give the colour tool a random colour
colour_random_a - give the colour tool a random alpha digit
colour_object “alpha (“true”/“false”)” - give the object you’re looking at a random colour
colour_objects “prop_physics only? (“true”/“false”)” “alpha (“true”/“false”)” “range” - give the objects in range a random colour

Put in a lua file in lua/autorun/server

Enjoy

P.S. Hold the sex. :slight_smile: