Page 1 of 1

More then 1 of the same class?

Posted: Fri Jan 20, 2017 7:00 pm
by vanblam
Is there a way to add a second light and particle to an object?

Code: Select all

defineObject{
	name = "ud_chandelier",
	components = {
		{
			class = "Model",
			model = "mod_assets/vb_models/models_under_d/env/ud_chandelier.fbx",
			staticShadow = true,
		},
		{
			class = "Light",
			range = 3.5,
			color = vec(1.3, 0.68, 0.35),
			brightness = 6,
			castShadow = true,
			staticShadows = true,
			offset = vec(0, 1.7, -0.63),
			onUpdate = function(self)
				local noise = math.noise(Time.currentTime()*3 + 123) * 0.5 + 0.9
				self:setBrightness(noise * 9)
			end,
		},
		{
			class = "Particle",
			particleSystem = "ud_candle",
			offset = vec(0, 1.7, -0.63),
		},
	},
	placement = "floor",
	editorIcon = 88,
	minimalSaveState = true,
	tags = { "VB","Under Dungeon" },
}

Re: More then 1 of the same class?

Posted: Fri Jan 20, 2017 7:06 pm
by zimberzimber
Define any component as you would normally, and give it a different name.

Code: Select all

       components = {
          {
             class = "Light",
             range = 3.5,
             color = vec(1.3, 0.68, 0.35),
             brightness = 6,
             castShadow = true,
             staticShadows = true,
             offset = vec(0, 1.7, -0.63),
             onUpdate = function(self)
                local noise = math.noise(Time.currentTime()*3 + 123) * 0.5 + 0.9
                self:setBrightness(noise * 9)
             end,
          },
          {
             class = "Light",
             name = "secondLight",
             range = 5,
             color = vec(1.3, 0.68, 0.35),
             brightness = 6,
             castShadow = true,
             staticShadows = true,
          },

Re: More then 1 of the same class?

Posted: Fri Jan 20, 2017 7:12 pm
by vanblam
Awesome thank you :) .. Had a feeling it was something simple :P