@name Material Selector
@persist Material:table Prop:table Index
@persist LIB_BUTTON_FUNCTIONDOWN:table
@persist LIB_BUTTON_ONHOVER:table
@persist LIB_BUTTON_ONHOVER_SHOW:number
@persist LIB_BUTTON_FUNCTIONUP:table
@persist LIB_BUTTON_TOGGLE:table
@persist LIB_BUTTON_STATE:table
@persist LIB_BUTTON_SCALE:table
@persist LIB_BUTTON_COLOR_ON:vector
@persist LIB_BUTTON_COLOR_OFF:vector
@persist LIB_BUTTON_HOLD:number
@persist LIB_BUTTON_LAST_PRESSED:number
@model models/sprops/cuboids/height12/size_1/cube_12x12x12.mdl
#exit() # Remove this line to make code work

# <BUTTON>
if( first( ) ) {
    
    runOnKeys( owner( ), 1 )
    LIB_BUTTON_FUNCTION = table( )
    LIB_BUTTON_TOGGLE = table( )
    LIB_BUTTON_STATE = table( )
    LIB_BUTTON_SCALE = table( )
    LIB_BUTTON_COLOR_ON = vec( 0, 255, 0 )
    LIB_BUTTON_COLOR_OFF = vec( 255 )
    LIB_BUTTON_ONHOVER_SHOW = 1
    LIB_BUTTON_LAST_PRESSED = 0
    
    function vector hologramGetPlaneUp( PLAYER:entity, INDEX:number ) {
        local EYE_LOCATION = PLAYER:shootPos( )
        local EYE_DIRECTION = PLAYER:eye( )
        local HOLO_ENTITY = holoEntity( INDEX )
        local HOLO_UP = HOLO_ENTITY:up( )
        return ( EYE_LOCATION + ( HOLO_UP:dot( HOLO_ENTITY:pos( ) - EYE_LOCATION ) / ( HOLO_UP:dot( EYE_DIRECTION ) ) ) * EYE_DIRECTION )
    }
    
    function buttonCreate( INDEX:number, TOGGLE:number, FUNCTION_DOWN:string, FUNCTION_UP:string ) {
        local SCALE = holoScaleUnits( INDEX )
        LIB_BUTTON_SCALE[ INDEX, number ] = ( SCALE:x( ) + SCALE:y( ) ) / 4
        LIB_BUTTON_FUNCTIONDOWN[ INDEX, string ] = FUNCTION_DOWN
        LIB_BUTTON_FUNCTIONUP[ INDEX, string ] = FUNCTION_UP
        LIB_BUTTON_TOGGLE[ INDEX, number ] = TOGGLE
        LIB_BUTTON_STATE[ INDEX, number ] = 0
        LIB_BUTTON_ONHOVER[ INDEX, number ] = 0
    }
    
    function number buttonGetState( INDEX ) {
        return LIB_BUTTON_STATE[ INDEX, number ]
    }
    
    function buttonSetColors( On:vector, Off:vector ) {
        LIB_BUTTON_COLOR_ON = On
        LIB_BUTTON_COLOR_OFF = Off
    }
}
if( LIB_BUTTON_ONHOVER_SHOW ) {
    if( clk( ) & LIB_BUTTON_ONHOVER:count( ) <= 30 ) {
        local KEY = LIB_BUTTON_FUNCTIONDOWN:keys( )
        for( I = 1, KEY:count( ) ) {
            local X = KEY[ I, number ]
            if( LIB_BUTTON_STATE[ X, number ] == 1 ) {
                holoColor( X, LIB_BUTTON_COLOR_ON )
            } else {
                holoColor( X, LIB_BUTTON_COLOR_OFF )
            }
            local Pointer = hologramGetPlaneUp( owner( ), X )
            if( Pointer:distance( holoEntity( X ):pos( ) ) <= LIB_BUTTON_SCALE[ X, number ] ) {
                if( LIB_BUTTON_STATE[ X, number ] == 1 ) {
                    holoColor( X, vec( 0, 255, 127.5 ) )
                } else {
                    holoColor( X, vec( 0, 255, 255 ) )
                }
            }
        }
    }
}

if( keyClk() ) {
    local PLAYER = keyClk()
    local KEY_PRESSED = keyClkPressed()
    local DOWN = PLAYER:keyPressed( KEY_PRESSED ) ? 1 : 0
    
    if( KEY_PRESSED == "e" | KEY_PRESSED == "mouse_right" ) {
        local INDEX = -1
        local KEY = LIB_BUTTON_FUNCTIONDOWN:keys( )
        for( I = 1, KEY:count( ) ) {
            local X = KEY[ I, number ]
            local Pointer = hologramGetPlaneUp( PLAYER, X )
            if( Pointer:distance( holoEntity( X ):pos( ) ) <= LIB_BUTTON_SCALE[ X, number ] ) {
                INDEX = X
            }
        }
        if( INDEX > 0 ) {
            if( DOWN == 1 ) {
                if( LIB_BUTTON_STATE[ INDEX, number ] == 0 ) {
                    LIB_BUTTON_LAST_PRESSED = INDEX
                    LIB_BUTTON_HOLD = INDEX
                    LIB_BUTTON_STATE[ INDEX, number ] = 1
                    holoColor( INDEX, LIB_BUTTON_COLOR_ON )
                    soundPlay( randint( 2e8 ), soundDuration( "common/wpn_moveselect.wav" ), "common/wpn_moveselect.wav" )
                    if( LIB_BUTTON_FUNCTIONDOWN[ INDEX, string ] != "" ) {
                        if( LIB_BUTTON_FUNCTIONDOWN:exists( INDEX ) ) {
                            LIB_BUTTON_FUNCTIONDOWN[ INDEX, string ]( PLAYER )
                        }
                    }
                } elseif( LIB_BUTTON_STATE[ INDEX, number ] == 1 & LIB_BUTTON_TOGGLE[ INDEX, number ] == 1 ) {
                    LIB_BUTTON_STATE[ INDEX, number ] = 0
                    holoColor( INDEX, LIB_BUTTON_COLOR_OFF )
                    soundPlay( randint( 2e8 ), soundDuration( "common/wpn_denyselect.wav" ), "common/wpn_denyselect.wav" )
                    if( LIB_BUTTON_FUNCTIONUP[ INDEX, string ] != "" ) {
                        if( LIB_BUTTON_FUNCTIONUP:exists( INDEX ) ) {
                            LIB_BUTTON_FUNCTIONUP[ INDEX, string ]( PLAYER )
                        }
                    }
                }
            } elseif( DOWN == 0 ) {
                if( LIB_BUTTON_TOGGLE[ LIB_BUTTON_HOLD, number ] == 0 & LIB_BUTTON_HOLD > 0 & LIB_BUTTON_STATE[ LIB_BUTTON_HOLD, number ] == 1 ) {
                    LIB_BUTTON_STATE[ LIB_BUTTON_HOLD, number ] = 0
                    holoColor( LIB_BUTTON_HOLD, LIB_BUTTON_COLOR_OFF )
                    #soundPlay( randint( 2e8 ), soundDuration( "common/wpn_denyselect.wav" ), "common/wpn_denyselect.wav" )
                    if( LIB_BUTTON_FUNCTIONUP[ LIB_BUTTON_HOLD, string ] != "" ) {
                        if( LIB_BUTTON_FUNCTIONUP:exists( LIB_BUTTON_HOLD ) ) {
                            LIB_BUTTON_FUNCTIONUP[ LIB_BUTTON_HOLD, string ]( PLAYER )
                        }
                    }
                    LIB_BUTTON_HOLD = 0
                }
            }
        } else {
            if( LIB_BUTTON_HOLD > 0 & LIB_BUTTON_TOGGLE[ LIB_BUTTON_HOLD, number ] == 0 ) {
                LIB_BUTTON_STATE[ LIB_BUTTON_HOLD, number ] = 0
                holoColor( LIB_BUTTON_HOLD, LIB_BUTTON_COLOR_OFF )
                #soundPlay( randint( 2e8 ), soundDuration( "common/wpn_denyselect.wav" ), "common/wpn_denyselect.wav" )
                if( LIB_BUTTON_FUNCTIONUP[ LIB_BUTTON_HOLD, string ] != "" ) {
                    if( LIB_BUTTON_FUNCTIONUP:exists( LIB_BUTTON_HOLD ) ) {
                        LIB_BUTTON_FUNCTIONUP[ LIB_BUTTON_HOLD, string ]( PLAYER )
                    }
                }
                LIB_BUTTON_HOLD = 0
            }
        }
    }
}
# </BUTTON>

if( first( ) ) {
    
    Index = 1
    propSpawnUndo( 0 )
    Material = table(
        "Models/effects/comball_sphere",
        "Models/effects/comball_tape",
        "Models/effects/splodearc_sheet",
        "Models/effects/vol_light001",
        "WTP/camoflage_1",
        "WTP/camoflage_2",
        "WTP/camoflage_3",
        "WTP/camoflage_4",
        "WTP/carbonfibre_1",
        "WTP/carbonfibre_2",
        "WTP/chrome_1",
        "WTP/chrome_2",
        "WTP/chrome_2",
        "WTP/chrome_3",
        "WTP/chrome_4",
        "WTP/chrome_5",
        "WTP/chrome_6",
        "WTP/chrome_7",
        "WTP/cloth_1",
        "WTP/cloth_2",
        "WTP/leather_1",
        "WTP/leather_1a",
        "WTP/leather_1b",
        "WTP/leather_2",
        "WTP/leather_2a",
        "WTP/metal_1",
        "WTP/metal_2",
        "WTP/metal_2b",
        "WTP/metal_2c",
        "WTP/metal_3",
        "WTP/metal_4",
        "WTP/metal_5",
        "WTP/metal_5b",
        "WTP/metal_5c",
        "WTP/metal_5d",
        "WTP/metal_6",
        "WTP/metal_6b",
        "WTP/metal_7",
        "WTP/metal_7b",
        "WTP/metal_7c",
        "WTP/paint_1",
        "WTP/paint_2",
        "WTP/paint_3",
        "WTP/paint_4",
        "WTP/paint_5",
        "WTP/plastic_1",
        "WTP/plastic_2",
        "WTP/track_1b",
        "WTP/track_2b",
        "WTP/track_3b",
        "WTP/track_4b",
        "WTP/track_5b",
        "WTP/track_6b",
        "WTP/track_7b",
        "WTP/wood_1a",
        "WTP/wood_1b",
        "WTP/wood_1c",
        "WTP/wood_2",
        "WTP/wood_3",
        "brick/brick_model",
        "debug/env_cubemap_model",
        "hunter/myplastic",
        "models/Combine_Helicopter/helicopter_bomb01",
        "models/Items/boxart1",
        "models/XQM//Deg360",
        "models/XQM//LightLinesGB",
        "models/XQM//LightLinesRed",
        "models/XQM//SquaredMat",
        "models/XQM//WoodTexture_1",
        "models/XQM/BoxFull_diffuse",
        "models/XQM/CellShadedCamo_diffuse",
        "models/XQM/CinderBlock_Tex",
        "models/XQM/JetBody2TailPiece_diffuse",
        "models/XQM/LightLinesRed_tool",
        "models/XQM/PoleX1_diffuse",
        "models/XQM/Rails/gumball_1",
        "models/XQM/SquaredMatInverted",
        "models/XQM/WoodPlankTexture",
        "models/XQM/BoxFull_diffuse",
        "models/airboat/airboat_blur02",
        "models/alyx/emptool_glow",
        "models/antlion/antlion_innards",
        "models/balloon/balloon_hl2",
        "models/balloon/balloon_milfman",
        "models/balloon/balloon_nips",
        "models/barnacle/roots",
        "models/combine_advisor/body9",
        "models/combine_advisor/mask",
        "models/combine_scanner/scanner_eye",
        "models/dav0r/hoverball",
        "models/debug/debugwhite",
        "models/dog/eyeglass",
        "models/effects/comball_glow1",
        "models/effects/comball_glow2",
        "models/effects/portalrift_sheet",
        "models/effects/slimebubble_sheet",
        "models/effects/splode1_sheet",
        "models/effects/splode_sheet",
        "models/error/new light1",
        "models/flesh",
        "models/gibs/metalgibs/metal_gibs",
        "models/gibs/woodgibs/woodgibs01",
        "models/gibs/woodgibs/woodgibs02",
        "models/gibs/woodgibs/woodgibs03",
        "models/items/boxsniperrounds",
        "models/player/player_chrome1",
        "models/props_animated_breakable/smokestack/brickwall002a",
        "models/props_building_details/courtyard_template001c_bars",
        "models/props_buildings/destroyedbuilldingwall01a",
        "models/props_buildings/plasterwall021a",
        "models/props_c17/FurnitureFabric003a",
        "models/props_c17/FurnitureMetal001a",
        "models/props_c17/fisheyelens",
        "models/props_c17/frostedglass_01a",
        "models/props_c17/frostedglass_01a_dx60",
        "models/props_c17/furniturefabric001a",
        "models/props_c17/furniturefabric002a",
        "models/props_c17/FurnitureMetal001a",
        "models/props_c17/gate_door02a",
        "models/props_c17/metalladder001",
        "models/props_c17/metalladder002",
        "models/props_c17/metalladder003",
        "models/props_c17/paper01",
        "models/props_canal/canal_bridge_railing_01a",
        "models/props_canal/canal_bridge_railing_01b",
        "models/props_canal/canal_bridge_railing_01c",
        "models/props_canal/canalmap_sheet",
        "models/props_canal/coastmap_sheet",
        "models/props_canal/metalcrate001d",
        "models/props_canal/metalwall005b",
        "models/props_canal/rock_riverbed01a",
        "models/props_combine/Combine_Citadel001",
        "models/props_combine/citadel_cable",
        "models/props_combine/citadel_cable_b",
        "models/props_combine/com_shield001a",
        "models/props_combine/combine_door01_glass",
        "models/props_combine/combine_fenceglow",
        "models/props_combine/combine_interface_disp",
        "models/props_combine/combine_intmonitor001_disp",
        "models/props_combine/combine_monitorbay_disp",
        "models/props_combine/combinethumper002",
        "models/props_combine/health_charger_glass",
        "models/props_combine/masterinterface01c",
        "models/props_combine/masterinterface_alert",
        "models/props_combine/metal_combinebridge001",
        "models/props_combine/pipes01",
        "models/props_combine/pipes03",
        "models/props_combine/portalball001_sheet",
        "models/props_combine/prtl_sky_sheet",
        "models/props_combine/stasisfield_beam",
        "models/props_combine/stasisshield_sheet",
        "models/props_combine/tpballglow",
        "models/props_combine/tprings_globe",
        "models/props_combine/tprings_sheet",
        "models/props_combine/tprotato1_sheet",
        "models/props_combine/weaponstripper_sheet",
        "models/props_debris/building_template010a",
        "models/props_debris/building_template012d",
        "models/props_debris/building_template022j",
        "models/props_debris/composite_debris",
        "models/props_debris/concretefloor013a",
        "models/props_debris/concretefloor020a",
        "models/props_debris/concretewall019a",
        "models/props_debris/metalwall001a",
        "models/props_debris/plasterceiling008a",
        "models/props_debris/plasterwall009d",
        "models/props_debris/plasterwall021a",
        "models/props_debris/plasterwall034a",
        "models/props_debris/plasterwall034d",
        "models/props_debris/plasterwall039c",
        "models/props_debris/plasterwall040c",
        "models/props_debris/tilefloor001c",
        "models/props_foliage/driftwood_01a",
        "models/props_foliage/oak_tree01",
        "models/props_foliage/tree_deciduous_01a_trunk",
        "models/props_interiors/metalfence007a",
        "models/props_junk/TrafficCone001a",
        "models/props_junk/plasticcrate01a",
        "models/props_junk/plasticcrate01b",
        "models/props_junk/plasticcrate01c",
        "models/props_junk/plasticcrate01d",
        "models/props_junk/plasticcrate01e",
        "models/props_junk/ravenholmsign_sheet",
        "models/props_lab/Tank_Glass001",
        "models/props_lab/cornerunit_cloud",
        "models/props_lab/door_klab01",
        "models/props_lab/generatorconsole_disp",
        "models/props_lab/security_screens",
        "models/props_lab/warp_sheet",
        "models/props_lab/security_screens2",
        "models/props_lab/xencrystal_sheet",
        "models/props_pipes/GutterMetal01a",
        "models/props_pipes/Pipesystem01a_skin3",
        "models/props_pipes/destroyedpipes01a",
        "models/props_pipes/pipemetal001a",
        "models/props_pipes/pipeset_metal",
        "models/props_pipes/pipeset_metal02",
        "models/props_pipes/pipesystem01a_skin1",
        "models/props_pipes/pipesystem01a_skin2",
        "models/props_vents/borealis_vent001",
        "models/props_vents/borealis_vent001b",
        "models/props_vents/borealis_vent001c",
        "models/props_wasteland/dirtwall001a",
        "models/props_wasteland/concretewall066a",
        "models/props_wasteland/concretewall064b",
        "models/props_wasteland/concretefloor010a",
        "models/props_wasteland/lighthouse_stairs",
        "models/props_wasteland/metal_tram001a",
        "models/props_wasteland/quarryobjects01",
        "models/props_wasteland/rockcliff02a",
        "models/props_wasteland/rockgranite02a",
        "models/props_wasteland/rockcliff04a",
        "models/props_wasteland/rockcliff02c",
        "models/props_wasteland/rockcliff02b",
        "models/props_wasteland/tugboat01",
        "models/props_wasteland/tugboat02",
        "models/props_wasteland/wood_fence01a",
        "models/props_wasteland/wood_fence01a_skin2",
        "models/rendertarget",
        "models/roller/rollermine_glow",
        "models/screenspace",
        "models/shadertest/predator",
        "models/shadertest/shader3",
        "models/shadertest/shader4",
        "models/shadertest/shader5",
        "models/shiny",
        "models/spawn_effect",
        "models/vortigaunt/pupil",
        "models/weapons/v_crossbow/rebar_glow",
        "models/weapons/v_crowbar/crowbar_cyl",
        "models/weapons/v_grenade/grenade body",
        "models/weapons/v_slam/new light1",
        "models/weapons/v_slam/new light2",
        "models/weapons/v_smg1/texture5",
        "models/weapons/v_stunbaton/w_shaft01a",
        "models/weapons/w_smg1/smg_crosshair",
        "models/wireframe",
        "phoenix_storms/Airboat",
        "phoenix_storms/Blue_steel",
        "phoenix_storms/Fender_chrome",
        "phoenix_storms/fender_white",
        "phoenix_storms/Fender_wood",
        "phoenix_storms/Future_vents",
        "phoenix_storms/FuturisticTrackRamp_1-2",
        "phoenix_storms/Indenttiles2",
        "phoenix_storms/Indenttiles_1-2",
        "phoenix_storms/MetalSet_1-2",
        "phoenix_storms/Metalfloor_2-3",
        "phoenix_storms/OfficeWindow_1-1",
        "phoenix_storms/Pro_gear_side",
        "phoenix_storms/airboat_blur02",
        "phoenix_storms/amraam",
        "phoenix_storms/barrel",
        "phoenix_storms/barrel_fps",
        "phoenix_storms/black_brushes",
        "phoenix_storms/black_chrome",
        "phoenix_storms/Blue_steel",
        "phoenix_storms/bluemetal",
        "phoenix_storms/bomb",
        "phoenix_storms/camera",
        "phoenix_storms/cannon",
        "phoenix_storms/car_tire",
        "phoenix_storms/checkers_map",
        "phoenix_storms/chrome",
        "phoenix_storms/cigar",
        "phoenix_storms/concrete3",
        "phoenix_storms/concrete2",
        "phoenix_storms/concrete1",
        "phoenix_storms/concrete0",
        "phoenix_storms/construct/concrete_barrier00",
        "phoenix_storms/construct/concrete_barrier2_00",
        "phoenix_storms/construct/concrete_pipe_00",
        "phoenix_storms/cube",
        "phoenix_storms/explo_barrel",
        "phoenix_storms/egg",
        "phoenix_storms/dome_side",
        "phoenix_storms/dome",
        "phoenix_storms/fender",
        "phoenix_storms/Fender_chrome",
        "phoenix_storms/fender_white",
        "phoenix_storms/Fender_wood",
        "phoenix_storms/glass",
        "phoenix_storms/gear_top",
        "phoenix_storms/gear",
        "phoenix_storms/Future_vents",
        "phoenix_storms/grey_chrome",
        "phoenix_storms/grey_steel",
        "phoenix_storms/heli",
        "phoenix_storms/Indenttiles2",
        "phoenix_storms/mat/mat_phx_carbonfiber2",
        "phoenix_storms/mat/mat_phx_carbonfiber",
        "phoenix_storms/lag_sign",
        "phoenix_storms/iron_rails",
        "phoenix_storms/mat/mat_phx_metallic",
        "phoenix_storms/mat/mat_phx_metallic2",
        "phoenix_storms/mat/mat_phx_plastic",
        "phoenix_storms/mat/mat_phx_plastic2",
        "phoenix_storms/metal",
        "phoenix_storms/metal_plate",
        "phoenix_storms/metal_wheel",
        "phoenix_storms/metalbox",
        "phoenix_storms/metalbox2",
        "phoenix_storms/metalfence004a",
        "phoenix_storms/Metalfloor_2-3",
        "phoenix_storms/MetalSet_1-2",
        "phoenix_storms/output_jack",
        "phoenix_storms/mrtire",
        "phoenix_storms/mrref2",
        "phoenix_storms/middle",
        "phoenix_storms/pack2/black",
        "phoenix_storms/pack2/bluelight",
        "phoenix_storms/pack2/chrome",
        "phoenix_storms/pack2/darkblue",
        "phoenix_storms/pack2/interior_top",
        "phoenix_storms/pack2/interior_sides",
        "phoenix_storms/pack2/glass",
        "phoenix_storms/pack2/darkgrey",
        "phoenix_storms/pack2/metalbox2",
        "phoenix_storms/pack2/panel",
        "phoenix_storms/pack2/redlight",
        "phoenix_storms/pack2/train_floor",
        "phoenix_storms/pro_gear_top2",
        "phoenix_storms/potato",
        "phoenix_storms/point1",
        "phoenix_storms/plastic",
        "phoenix_storms/ps_grass",
        "phoenix_storms/road",
        "phoenix_storms/roadside",
        "phoenix_storms/scrnspace",
        "phoenix_storms/smallwheel",
        "phoenix_storms/simplyMetallic2",
        "phoenix_storms/simplyMetallic1",
        "phoenix_storms/side",
        "phoenix_storms/spheremappy",
        "phoenix_storms/stripes",
        "phoenix_storms/t_light",
        "phoenix_storms/thruster",
        "phoenix_storms/trains/track_beamside",
        "phoenix_storms/torpedo",
        "phoenix_storms/top",
        "phoenix_storms/tiles2",
        "phoenix_storms/trains/track_beamtop",
        "phoenix_storms/trains/track_plate",
        "phoenix_storms/trains/track_plateside",
        "phoenix_storms/white_brushes",
        "phoenix_storms/wire/pcb_green",
        "phoenix_storms/wire/pcb_blue",
        "phoenix_storms/window",
        "phoenix_storms/white_fps",
        "phoenix_storms/wire/pcb_red",
        "phoenix_storms/wood",
        "phoenix_storms/wood_dome",
        "phoenix_storms/wood_side",
        "sprops/textures/gear_metal",
        "sprops/sprops_plastic",
        "sprops/sprops_grid_orange_12x12",
        "sprops/sprops_grid_12x12",
        "sprops/textures/sprops_cfiber1",
        "sprops/textures/sprops_cfiber2",
        "sprops/textures/sprops_chrome",
        "sprops/textures/sprops_chrome2",
        "sprops/textures/sprops_metal1",
        "sprops/textures/sprops_metal2",
        "sprops/textures/sprops_metal3",
        "sprops/textures/sprops_metal4",
        "sprops/textures/sprops_metal5",
        "sprops/textures/sprops_metal6",
        "sprops/textures/sprops_rubber",
        "sprops/textures/sprops_rubber2",
        "sprops/textures/sprops_wood1",
        "sprops/textures/sprops_wood2",
        "sprops/textures/sprops_wood3",
        "sprops/textures/sprops_wood4",
        "sprops/trans/lights/light_plastic",
        "sprops/trans/misc/beam_side",
        "sprops/trans/misc/ls_m1",
        "sprops/trans/misc/ls_m2",
        "sprops/trans/misc/tracks_wood",
        "sprops/trans/wheels/wheel_d_rim1",
        "sprops/trans/wheels/wheel_d_rim2",
        "models/props/CS_militia/RoofEdges",
        "models/props/CS_militia/boulder01",
        "models/props/CS_militia/milceil001",
        "models/props/CS_militia/militiarock",
        "models/props/CS_militia/militiarockb",
        "models/props/CS_militia/milwall006",
        "models/props/CS_militia/rocks01",
        "models/props/CS_militia/roofbeams01",
        "models/props/CS_militia/roofbeams02",
        "models/props/CS_militia/roofbeams03",
        "models/props/cs_assault/dollar",
        "models/props/cs_assault/fireescapefloor",
        "models/props/cs_assault/metal_stairs1",
        "models/props/cs_assault/moneytop",
        "models/props/cs_assault/moneywrap",
        "models/props/cs_assault/moneywrap02",
        "models/props/cs_assault/pylon",
        "models/props/cs_office/clouds",
        "models/props/cs_office/file_cabinet2",
        "models/props/cs_office/file_cabinet3",
        "models/props/cs_office/offinspa",
        "models/props/cs_office/offinspb",
        "models/props/cs_office/offinspc",
        "models/props/cs_office/offinspd",
        "models/props/cs_office/offinspf",
        "models/props/cs_office/offinspg",
        "models/props/cs_office/screen",
        "models/props/cs_office/snowmana",
        "models/props/de_inferno/de_inferno_boulder_03",
        "models/props/de_inferno/infflra",
        "models/props/de_inferno/infflrd",
        "models/props/de_inferno/inftowertop",
        "models/props/de_inferno/offwndwb_break",
        "models/props/de_inferno/roofbits",
        "models/props/de_inferno/tileroof01",
        "models/props/de_inferno/woodfloor008a",
        "models/props/de_nuke/nukconcretewalla",
        "models/props/de_nuke/nukecardboard",
        "models/props/de_tides/clouds",
        "models/cheeze/wires/metal_texture",
        "dev/bloom",
        "effects/tvscreen_noise001a",
        "debug/showz",
        "effects/flashlight/caustics"
    )
    
    function buffer( ) {
        while( Index <= 25 & propCanCreate( ) ) { Index++, Prop:pushEntity( propSpawn( "models/holograms/hq_rcube_thin.mdl", entity( ):toWorld( vec(0, 0, 0 ) ), ang(0), 1 ) ) }
        if( Index <= 25 ) { timer( "buffer", 0.25 ) } else {
            local X = 1
            for( I = 1, 5 ) { 
                for( J = 1, 5 ) { 
                    Prop[ X, entity ]:setPos( entity( ):toWorld( vec( 0, ( -12.5 / 2 ) -( 12.5 * 2.5 ) + J * 12.5, ( 12.5 * 7 ) - ( I * 12.5 ) ) ) ), 
                    Prop[ X, entity ]:propMakePersistent( 1 )
                    X++
                }
            }
            print( "Materials available: " + Material:count( ) )
            holoCreate(1, entity():toWorld( vec(0, -40, 44 ) ), vec(1,1,0.01), ang(90,0,0), vec(255), "hq_cylinder" )
            holoParent(1, entity() )
            buttonCreate(1,0,"","")
            holoCreate(2, entity():toWorld( vec(0, -40, 56 ) ), vec(1,1,0.01), ang(90,0,0), vec(255), "hq_cylinder" )
            holoParent(2, entity() )
            buttonCreate(2,0,"","")
            Index = 1
            timer( "parent", 10 )
            interval(1)
        }
    } buffer( )
    function changeSet( N:number ) {
        Index += ( 5 * N )
        for( I = 1, 25 ) { Prop[ I, entity ]:setMaterial( Material[ ( Index + I ) % Material:count( ), string ] ) }
        #if( Index > Material:count( ) ) { Index = 1 } elseif( Index < 1 ) { Index = Material:count( ) - 25 }
    }
    function up( P:entity ) { changeSet( -1 ) }
    function down( P:entity ) { changeSet( 1 ) }
}



if( clk( "buffer" ) ) { buffer( ) } elseif( keyClk( ) ) {
    local Player = keyClk()
    local Key = keyClkPressed()
    if( Key == "e" & Player:keyPressed( Key ) == 1 ) {
        local E = owner( ):aimEntity( )
        if( E:isValid( ) ) {
            local M = E:getMaterial( )
            concmd( "material_override " + M )
            print( "material_override set to " + M )
            entity():setMaterial( M )
        }
    }
} elseif( clk( ) ) {
    interval( 150 )
    if( buttonGetState( 1 ) ) { down( owner() ) }
    if( buttonGetState( 2 ) ) { up( owner() ) }
    if( !entity():isPlayerHolding() ) {
        entity():propFreeze( 1 )
    }
}

if( clk( "parent" ) ) {
    for( I = 1, 25 ) { 
        Prop[ I, entity ]:parentTo( entity() )
        Prop[ I, entity ]:propFreeze( 0 )
    }
}
