Understanding Entity - changing a vehicle's skin

I extracted an addon using GMA and was trying to edit the skin. I used VTFEdit and, if I remove the addon, it works. I’m trying to find a way to ‘copy’ so I can use this in addition.

I discovered the SetMaterial command, but I have NO idea where I would use that or how to reference whatever is referring to the entity is… for example, here is one of the lua files that I use to create a spawn menu entry to spawn the vehicle. :


AddCSLuaFile()

EMV_DEBUG = false


local name = "Fire Chief Suburban"

local A = "AMBER"
local R = "RED"
local DR = "D_RED"
local B = "BLUE"
local W = "WHITE"
local CW = "C_WHITE"
local SW = "S_WHITE"

local EMV = {}

EMV.Siren = 7

EMV.Color = nil
EMV.Skin = 9

EMV.BodyGroups = {
	{ 4, 1 }
}

EMV.Props = {}

EMV.Meta = {
	takedown = {
		AngleOffset = -90,
		W = 6.9,
		H = 6.9,
		Sprite = "sprites/emv/emv_whelen_6x2",
	},
	f_round = {
		AngleOffset = -90,
		W = 8.1,
		H = 7.5,
		Sprite = "sprites/emv/emv_whelen_src",
		Scale = 1.4
	},
	liberty_takedown = {
		AngleOffset = -90,
		W = 3.6,
		H = 3.6,
		Sprite = "sprites/emv/emv_whelen_tri",
		WMult = 1,
		Scale = 1.2
	},
	f_ang = {
		AngleOffset = -90,
		W = 15.8,
		H = 15,
		Sprite = "sprites/emv/emv_whelen_corner",
		Scale = 1.6
	},
	r_ang = {
		AngleOffset = 90,
		W = 15.8,
		H = 15,
		Sprite = "sprites/emv/emv_whelen_corner",
		Scale = 1.6
	},
	r_round = {
		AngleOffset = 90,
		W = 8.1,
		H = 7.5,
		Sprite = "sprites/emv/emv_whelen_src",
		Scale = 1.4
	},
	r_rect = {
		AngleOffset = 90,
		W = 6.2,
		H = 6.2,
		Sprite = "sprites/emv/emv_whelen_rectangle",
		Scale = 1.4
	},
	r_3led = {
		AngleOffset = 90,
		W = 6,
		H = 6,
		Sprite = "sprites/emv/emv_whelen_mini_3",
		Scale = 1.2
	},
	f_3led = {
		AngleOffset = -90,
		W = 5.9,
		H = 5.8,
		Sprite = "sprites/emv/emv_whelen_mini_3",
		Scale = 1.2
	},
	skirt = {
		AngleOffset = -90,
		W = 5.9,
		H = 5.8,
		Sprite = "sprites/emv/emv_whelen_mini_3",
		Scale = 1.2
	},
	grille = {
		AngleOffset = -90,
		W = 5.98,
		H = 5.8,
		Sprite = "sprites/emv/emv_whelen_mini_3",
		Scale = 1.2,
		VisRadius = 20
	},
	headlight = {
		AngleOffset = -90,
		W = 7,
		H = 7,
		Sprite = "sprites/emv/light_circle",
		Scale = 3,
		VisRadius = 0
	},
	reverse_lights = {
		AngleOffset = 90,
		W = 4,
		H = 3,
		Sprite = "sprites/emv/square_src",
		Scale = 1
	},
	tail_light = {
		AngleOffset = 90,
		W = 5,
		H = 5.7,
		Sprite = "sprites/emv/square_src",
		Scale = 1.8
	},
}

EMV.Positions = {

	[ 1] = { Vector(-3.65, 14.35, 92.95), Angle(0,0,0), "f_round" },
	[ 2] = { Vector( 3.65, 14.35, 92.95), Angle(0,0,0), "f_round" },

	[ 3] = { Vector(-10.3, 14.35, 92.95), Angle(0,0,0), "f_round" },
	[ 4] = { Vector( 10.3, 14.35, 92.95), Angle(0,0,0), "f_round" },

	[ 5] = { Vector(-26.41, 11.7, 92.95), Angle(0, 32.4,0), "f_ang" },
	[ 6] = { Vector( 26.41, 11.7, 92.95), Angle(0, -32.4,0), "f_ang" },

	[ 7] = { Vector(-26.41, 2, 92.95), Angle(0, -32.4,0), "r_ang" },
	[ 8] = { Vector( 26.41, 2, 92.95), Angle(0, 32.4,0), "r_ang" },

	[ 9] = { Vector(-16.9, -.75, 92.95), Angle(0,0,0), "r_round" },
	[10] = { Vector( 16.9, -.75, 92.95), Angle(0,0,0), "r_round" },

	[11] = { Vector(-10.3, -.75, 92.95), Angle(0,0,0), "r_round" },
	[12] = { Vector( 10.3, -.75, 92.95), Angle(0,0,0), "r_round" },

	[13] = { Vector(-3.65, -.75, 92.95), Angle(0,0,0), "r_round" },
	[14] = { Vector( 3.65, -.75, 92.95), Angle(0,0,0), "r_round" },

	[15] = { Vector(-16.96, 15.0, 92.95), Angle(0,0,0), "liberty_takedown" },
	[16] = { Vector( 16.96, 15.0, 92.95), Angle(0,0,0), "liberty_takedown" },

	[17] = { Vector(-31.4, 6.8, 92.84), Angle(0,90,0), "liberty_takedown" },
	[18] = { Vector( 31.4, 6.8, 92.95), Angle(0,-90,0), "liberty_takedown" },

	[19] = { Vector(-18.8, 40.2, 83), Angle(0,0,0), "f_3led" },
	[20] = { Vector( 18.8, 40.2, 83), Angle(0,0,0), "f_3led" },

	[21] = { Vector(-12.9, 40.2, 83), Angle(0,0,0), "f_3led" },
	[22] = { Vector( 12.9, 40.2, 83), Angle(0,0,0), "f_3led" },

	[23] = { Vector(-17.62, 133.3, 50.8), Angle(0,8,0), "grille" },
	[24] = { Vector( 17.62, 133.3, 50.8), Angle(0,-8,0), "grille" },

	[25] = { Vector(-9.7, 134.29, 50.8), Angle(0,7,0), "grille" },
	[26] = { Vector( 9.7, 134.29, 50.8), Angle(0,-7,0), "grille" },

	[27] = { Vector(-26.32, -115.2, 84.6), Angle(0,-14,0), "r_3led" },
	[28] = { Vector( 26.32, -115.2, 84.6), Angle(0,14,0), "r_3led" },

	[29] = { Vector(-20.5, -116.3, 84.6), Angle(0,-7,0), "r_3led" },
	[30] = { Vector( 20.5, -116.3, 84.6), Angle(0,7,0), "r_3led" },

	[31] = { Vector(-14.6, -116.9, 84.6), Angle(0,-5,0), "r_3led" },
	[32] = { Vector( 14.6, -116.9, 84.6), Angle(0,5,0), "r_3led" },

	[31] = { Vector(-14.6, -116.9, 84.6), Angle(0,-5,0), "r_3led" },
	[32] = { Vector( 14.6, -116.9, 84.6), Angle(0,5,0), "r_3led" },

	[33] = { Vector(-36.7, -38.7, 19.6), Angle(0,90,0), "skirt" },
	[34] = { Vector( 36.7, -38.7, 19.6), Angle(0,-90,0), "skirt" },

	[35] = { Vector(-36.7, -6, 19.6), Angle(0,90,0), "skirt" },
	[36] = { Vector( 36.7, -6, 19.6), Angle(0,-90,0), "skirt" },

	[37] = { Vector(-36.7, 26.55, 19.6), Angle(0,90,0), "skirt" },
	[38] = { Vector( 36.7, 26.55, 19.6), Angle(0,-90,0), "skirt" },

	[39] = { Vector(-36.7, 59.2, 19.6), Angle(0,90,0), "skirt" },
	[40] = { Vector( 36.7, 59.2, 19.6), Angle(0,-90,0), "skirt" },

	[41] = { Vector( -40, -124.8, 53.1 ), Angle( 0,-21,-2 ), "reverse_lights" },
	[42] = { Vector( 40, -124.8, 53.1 ), Angle( 0,21, -2 ), "reverse_lights" },

	[43] = { Vector( -37.8, 124.8, 48.15 ), Angle( 0,0,0 ), "headlight" },
	[44] = { Vector( 37.8, 124.8, 48.15 ), Angle( 0,0,0 ), "headlight" },

}


EMV.Sections = {
	["lightbar"] = {
		{
			{ 1, R }, { 2, R }, { 3, R }, { 4, R }, { 9, R }, { 10, R }, { 11, R }, { 12, R }, { 13, R }, { 14, R },
		},
		{
			{ 1, R }, { 3, R }, { 9, R }, { 11, R }, { 13, R }, 
		},
		{
			{ 2, R }, { 4, R }, { 10, R }, { 12, R }, { 14, R }, 
		},
		{
			{ 1, R }, { 2, R }, { 13, R }, { 14, R }
		},
		{
			{ 3, R }, { 4, R }, { 11, R }, { 12, R }
		},
		{
			{ 9, R }, { 10, R }
		},

	},
	["corner"] = {
		[1] = {
			{ 5, R }, { 6, R }, { 7, R }, { 8, R },
		},
		[2] = {
			{ 5, R }, { 7, R },
		},
		[3] = {
			{ 6, R }, { 8, R },
		},
	},
	["rear"] = {
		[1] = {
			{ 27, R }, { 28, R }, { 29, W }, { 30, W }, { 31, R }, { 32, R }, 
		},
		[2] = {
			{ 27, R }, { 28, R }, { 31, R }, { 32, R },
		},
		[3] = {
			{ 29, W }, { 30, W },
		}
	},
	["grille"] = {
		{
			{ 23, R }, { 24, R }, { 25, W }, { 26, W }, 
		},
		{ { 24, R } },
		{ { 26, W } },
		{ { 25, W } },
		{ { 23, R } },
		{
			{ 23, R }, { 24, R }, 
		},
		{
			{ 25, W }, { 26, W }, 
		},
	},
	["side"] = {
		{
			{ 33, W }, { 34, W }, { 35, R }, { 36, R }, { 37, R }, { 38, R }, { 39, R }, { 40, R }, 
		},
		{ { 33, W }, { 34, W }, },
		{ { 35, R }, { 36, R }, },
		{ { 37, W }, { 38, W }, },
		{ { 39, R }, { 40, R }, },
		{ { 35, R }, { 36, R }, {39, R }, { 40, R } },
		{ { 33, W }, { 34, W }, { 37, W }, { 38, W } },
	},
	["dash"] = {
		{ { 19, R }, { 20, R }, { 21, R }, { 22, R }, },
		{ { 19, R }, { 20, R }, },
		{ { 21, R }, { 22, R }, },
	},
	["takedown"] = {
		{
			{ 15, W }, { 16, W }, { 17, W }, { 18, W }, 
		},
		{
			{ 15, W }, { 17, W },  
		},
		{
			{ 16, W }, { 18, W }, 
		},
	},
	["reverse"] = {
		{ { 41, R } },
		{ { 42, R } },
	},
	["headlights"] = {
		{ { 43, SW, {16, 0, 0} }, { 44, SW, {16, 0, 10} }, },
	}
}

EMV.Patterns = {
	["lightbar"] = {
		["all"] = {
			1
		},
		["code2"] = {
			2, 2, 2, 0, 3, 3, 3, 0
		},
		["code3"] = {
			4, 5, 6, 5, 4, 0, 4, 0, 5, 0, 5, 0, 6, 0, 6, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 2, 2, 0, 3, 3, 0, 2, 0, 2, 0, 3, 0, 3, 0
		}
	},
	["corner"] = {
		["all"] = {
			1
		},
		["alt"] = {
			2, 2, 2, 2, 3, 3, 3, 3
		},
		["code2"] = {
			2, 2, 2, 2, 3, 3, 3, 3
		},
		["code3"] = {
			2, 0, 2, 0, 3, 0, 3, 0
		}
	},
	["rear"] = {
		["all"] = {
			1
		},
		["code1"] = {
			2, 2, 2, 0, 3, 3, 3, 0, 0
		},
		["code2"] = {
			2, 2, 0, 2, 2, 0, 3, 3, 3, 0
		},
		["code3"] = {
			2, 0, 2, 0, 3, 0, 3, 0
		}
	},
	["grille"] = {
		["all"] = {
			1
		},
		["code1"] = {
			2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 0, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 0
		},
		["code2"] = {
			6, 6, 6, 0, 6, 6, 6, 0, 7, 7, 7, 0, 7, 7, 7, 0
		},
		["code3"] = {
			2, 3, 4, 5, 0, 5, 4, 3, 2, 1, 0, 1, 0, 1, 0, 6, 6, 0, 7, 7, 0, 6, 6, 0, 7, 7, 0, 6, 6, 0, 7, 7, 0
		}
	},
	["side"] = {
		["all"] = {
			1
		},
		["code3"] = {
			2, 2, 3, 3, 4, 4, 5, 5, 2, 3, 4, 5, 2, 3, 4, 5, 2, 3, 4, 5, 2, 3, 4, 5, 6, 6, 0, 6, 6, 0, 6, 6, 0, 7, 7, 0, 7, 7, 0, 7, 7, 0, 6, 6, 7, 7, 6, 6, 7, 7, 6, 6, 7, 7, 6, 6, 7, 7
		}
	},
	["dash"] = {
		["all"] = {
			1
		},
		["code3"] = {
			2, 3, 1, 3, 2, 1
		}
	},
	["takedown"] = {
		["all"] = {
			1
		},
		["code3"] = {
			2, 2, 3, 3,
		}
	},
	["reverse"] = {
		["code3"] = {
			1, 0, 1, 0, 2, 0, 2, 0
		}
	},
	["headlights"] = {
		["wigwag"] = {
			1
		}
	}
}


EMV.Sequences = {
	Sequences = {
		{
			Name = "CRUISE",
			Components = {
				["lightbar"] = "all",
				["corner"] = "all",
				["rear"] = "all",
				["grille"] = "all",
				["side"] = "all",
				["dash"] = "all",
				["takedown"] = "all",
			}
		},
		{
			Name = "CODE 1",
			Components = {
				["corner"] = "alt",
				["rear"] = "code1",
				["grille"] = "code1",
				["takedown"] = "all",
			}
		},
		{
			Name = "CODE 2",
			Components = {
				["corner"] = "alt",
				["lightbar"] = "code2",
				["rear"] = "code2",
				["grille"] = "code2",
			}
		},
		{
			Name = "CODE 3 ",
			Components = {
				["corner"] = "code3",
				["lightbar"] = "code3",
				["rear"] = "code3",
				["grille"] = "code3",
				["side"] = "code3",
				["dash"] = "code3",
				["takedown"] = "code3",
				["reverse"] = "code3",
				["headlights"] = "wigwag"
			},
			Disconnect = {
				14, 15
			}
		}
	}
}


local V = {
				// Required information
				Name =	name,
				Class = "prop_vehicle_jeep",
				Category = "AAAA Test Menu",

				// Optional information
				Author = "LoneWolfie, Schmal",
				Information = "vroom vroom",
				Model =	"models/LoneWolfie/chev_suburban_pol.mdl",
			
				KeyValues = {				
						vehiclescript =	"scripts/vehicles/LWCars/chev_suburban.txt"
					    },
				IsEMV = true,
				EMV = EMV,
				HasPhoton = true,
				Photon = "lw_suburban"

}

list.Set( "Vehicles", V.Name, V )

if EMVU then EMVU:OverwriteIndex( name, EMV ) end
if Photon then Photon:OverwriteIndex( name, PI ) end

Sorry but people usually want the whole script. Now, in there, how would I use the SetMaterial command and what is my “entity” is it V? the table containing all that vehicle information? I thought it might be but that didn’t work. I’ve looked and googled SetMaterial and GetName and read about entities but I am clearly missing something…