Making a Red Ceiling Light

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
spikedsynapse
Posts: 4
Joined: Sun Dec 07, 2014 4:53 am

Making a Red Ceiling Light

Post by spikedsynapse »

This may be old hat and the "wrong" way to do it, but clone object doesnt seem to work for me... and this works.
(also i am a noob to modding,scripting, and such)

I wanted to make a red ceiling light asset. Here is how i did it.

Step One:

I copied the asset definition for castle_ceiling_light from the new asset pack (HOORAY ITS OUT)

I changed the color codes of that object and placed it in the objects.lua file under my mod. I also pointed to a new particle system(castle_ceiling_light_red) that I defined in a similar way(below)

Code: Select all

defineObject{
	name = "castle_ceiling_light_Red",
	components = {
		{
			class = "Light",
			type = "spot",
			spotAngle = 90,
			rotation = vec(-90, 0, 0),
			spotSharpness = 0.7,
			offset = vec(0, 4.5, 0),
			range = 20,
			--color = vec(1, 0.1, 0.1),
			color = math.saturation(vec(0.47, 0.1, 0.1), 0.9),
			brightness = 6,
			castShadow = true,
			shadowMapSize = 1024,
			--debugDraw = true,
		},
		{
			class = "Light",
			name = "pointlight",
			type = "point",
			offset = vec(0, 4.5, 0),
			range = 6,
			--color = vec(0.45, 0.8, 1.55),
			color = math.saturation(vec(1, 0.1, 0.1), 0.9),
			brightness = 5,
		},
		
		{
			class = "Particle",
			particleSystem = "castle_ceiling_light_red",
			offset = vec(0, 4.75, 0),
		},
		{
			class = "Controller",
			onActivate = function(self)
				self.go.light:enable()
				self.go.pointlight:enable()
				self.go.particle:enable()
			end,
			onDeactivate = function(self)
				self.go.light:disable()
				self.go.pointlight:disable()
				self.go.particle:disable()
			end,
			onToggle = function(self)
				if self.go.light:isEnabled() then
					self.go.light:disable()
					self.go.pointlight:disable()
					self.go.particle:disable()
				else
					self.go.light:enable()
					self.go.pointlight:enable()
					self.go.particle:enable()
				end
			end,
		},
	},
	placement = "floor",
	editorIcon = 88,
}
Step 2
I looked up the asset definitions for castle_ceiling_light I duplicated the file and created a file called castle_ceiling_light_red. I changed the code below and now i have an asset in the particles directory called "castle_ceiling_light_red.lua"

Code: Select all

defineParticleSystem{
	name = "castle_ceiling_light_red",
	emitters = {
		-- glow
		{
			spawnBurst = true,
			emissionRate = 1,
			emissionTime = 0,
			maxParticles = 1,
			boxMin = {0, 0,-0.1},
			boxMax = {0, 0,-0.1},
			sprayAngle = {0,30},
			velocity = {0,0},
			texture = "assets/textures/particles/glow.tga",
			lifetime = {1000000, 1000000},
			color0 = {1, 0, 0},
			opacity = 1,
			fadeIn = 0.1,
			fadeOut = 0.1,
			size = {3, 3},
			gravity = {0,0,0},
			airResistance = 1,
			rotationSpeed = 0,
			depthBias = 1,
			blendMode = "Additive",
		},

		-- flames
		{
			emissionRate = 30,
			emissionTime = 0,
			maxParticles = 100,
			boxMin = {-0.03, -0.07, 0.03},
			boxMax = { 0.03, -0.07,  -0.03},
			sprayAngle = {0,10},
			velocity = {0.1, 0.4},
			texture = "assets/textures/particles/goromorg_lantern.tga",
			frameRate = 45,
			frameSize = 64,
			frameCount = 16,
			lifetime = {0.25, 0.85},
			colorAnimation = false,
			color0 = {1.5, 0, 0},
			opacity = 1,
			fadeIn = 0.15,
			fadeOut = 0.3,
			size = {0.17, 0.015},
			gravity = {0,0,0},
			airResistance = 1.0,
			rotationSpeed = 1,
			blendMode = "Additive",
			depthBias = 0,
			objectSpace = true,
		},

		-- inner glow
		--{
		--	spawnBurst = true,
		--	emissionRate = 1,
		--	emissionTime = 0,
		--	maxParticles = 1,
		--	boxMin = {0,0,0},
		--	boxMax = {0,0,0},
		--	sprayAngle = {0,30},
		--	velocity = {0,0},
		--	texture = "assets/textures/particles/glow.tga",
		--	lifetime = {1000000, 1000000},
		--	colorAnimation = false,
		--	color0 = {0.07, 0.11, 0.23},
		--	opacity = 1,
		--	fadeIn = 0.1,
		--	fadeOut = 0.1,
		--	size = {0.5, 0.5},
		--	gravity = {0,0,0},
		--	airResistance = 1,
		--	rotationSpeed = 0,
		--	blendMode = "Additive",
		--	depthBias = 0.1,
		--	objectSpace = true,
		--},

		-- outer glow
		{
			spawnBurst = true,
			emissionRate = 1,
			emissionTime = 0,
			maxParticles = 1,
			boxMin = {0,0,0},
			boxMax = {0,0,0},
			sprayAngle = {0,30},
			velocity = {0,0},
			texture = "assets/textures/particles/glow.tga",
			lifetime = {1000000, 1000000},
			colorAnimation = false,
			color0 = {1, 0, 0},
			opacity = 0.75,
			fadeIn = 0.1,
			fadeOut = 0.1,
			size = {1.25, 1.25},
			gravity = {0,0,0},
			airResistance = 1,
			rotationSpeed = 0,
			blendMode = "Additive",
			depthBias = 0.1,
			objectSpace = true,
		}
	}
}
Step 3

finally I added the particles definition to the init.lua file so that it would load propperly

Code: Select all

import "mod_assets/particles/castle_ceiling_light_red.lua"
now everything seems to work propperly and I have a nice red light.

Hopefully this is simple enough for someone like me to follow without having to spend the hours I did trying to figure this out. Also if there is an easier way to do this (cloneObject does not work(at least as i see it in the forum)) please let me know.
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Making a Red Ceiling Light

Post by Grimfan »

Very nice. I was about to start this process myself and having a reference point helps a lot.

I salute you! :D
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Making a Red Ceiling Light

Post by Drakkan »

seems nice, need to try that for fireflies :)
thanks for sharing
Breath from the unpromising waters.
Eye of the Atlantis
Post Reply