magic door
Posted: Thu Dec 25, 2014 8:53 pm
I wanted a magic door so I try this:
I think that modifying the forcefield object will be better, but I did not find the forcefield definition in the asset pack:
so, I'm using 2 objects, a modified magic bridge which is named magic_door_particle and a door used to block the party:
the magic_door, it is always a plateform:
the magic door particle:
then the code for a door, which use a custom sound: the custom sound has to be blank, but at least some seconds long or it will make an error.
So when opening this door, you will hear no sound.
(the best way to do it is to open any sound in audacity, select the sound and use the amplification tool, in the effect tab, then set the amplification to the lowest value. This will reduce the sound volume to 0)
you have to place them both on the same square, by watching the correct orientation of the 2 objects.
set the magic_door_block as following in the editor:
unselect the frame and the model box
a screenshot:
I think that modifying the forcefield object will be better, but I did not find the forcefield definition in the asset pack:
so, I'm using 2 objects, a modified magic bridge which is named magic_door_particle and a door used to block the party:
the magic_door, it is always a plateform:
SpoilerShow
Code: Select all
defineObject{
name = "magic_door",
baseObject = "base_floor_decoration",
components = {
{
class = "Particle",
particleSystem = "magic_door_part",
},
{
class = "Light",
color = vec(1.5,1.0,1.25),
brightness = 5,
range = 3,
castShadow = false,
offset = vec(0, -0.25, 0),
fillLight = true,
onUpdate = function(self)
self:setBrightness((math.noise(Time.currentTime() + 12) * 0.5 + 0.5 + 0.1) * 15)
end,
},
{
class = "Platform",
},
{
class = "Sound",
sound = "magic_bridge_ambient"
},
{
class = "Controller",
onInitialActivate = function(self)
self.go.platform:enable()
end,
onInitialDeactivate = function(self)
self.go.platform:disable()
self.go.particle:stop()
self.go.light:fadeOut(0)
self.go.sound:fadeOut(0)
end,
onActivate = function(self)
self.go.platform:enable()
self.go.particle:start()
self.go.light:fadeIn(0.1)
self.go.sound:fadeIn(0.1)
end,
onDeactivate = function(self)
self.go.platform:disable()
self.go.particle:stop()
self.go.light:fadeOut(0.5)
self.go.sound:fadeOut(0.1)
end,
onToggle = function(self)
if self.go.platform:isEnabled() then
self:deactivate()
else
self:activate()
end
end,
},
},
editorIcon = 276,
}
SpoilerShow
Code: Select all
defineParticleSystem{
name = "magic_door_part",
emitters = {
-- fog
{
emissionRate = 10,
emissionTime = 0,
maxParticles = 100,
boxMin = {-1.5,0.0,1.5},
boxMax = { 1.5,4.0,1.5},
sprayAngle = {0,360},
velocity = {0.1,0.4},
objectSpace = true,
texture = "assets/textures/particles/fog.tga",
lifetime = {3,3},
color0 = {0.15, 0.1, 0.125},
opacity = 0.2,
fadeIn = 2,
fadeOut = 2,
size = {1, 2},
gravity = {0,0,0},
airResistance = 0.1,
rotationSpeed = 0.3,
blendMode = "Additive",
},
-- stars
{
emissionRate = 300,
emissionTime = 0,
maxParticles = 600,
boxMin = {-1.5,0.0,1.5},
boxMax = { 1.5,4.0,1.5},
sprayAngle = {0,30},
velocity = {0.0,0.1},
objectSpace = true,
texture = "assets/textures/particles/glitter_silver.tga",
lifetime = {1,1.7},
color0 = {1.5,1.0,1.25},
opacity = 1,
fadeIn = 0.1,
fadeOut = 0.5,
size = {0.05, 0.15},
gravity = {0,-0.5,0},
airResistance = 0.1,
rotationSpeed = 2,
blendMode = "Additive",
},
-- stars
{
emissionRate = 400,
emissionTime = 0,
maxParticles = 400,
boxMin = {-1.5,0.0,1.5},
boxMax = { 1.5,4.0,1.5},
sprayAngle = {0,30},
velocity = {0.0,0.1},
objectSpace = true,
texture = "assets/textures/particles/glitter_silver.tga",
lifetime = {1,1},
color0 = {1.5*1.5, 1.0*1.5, 1.25*1.5},
opacity = 1,
fadeIn = 0.1,
fadeOut = 0.5,
size = {0.05, 0.25},
gravity = {0,-0.2,0},
airResistance = 0.1,
rotationSpeed = 2,
blendMode = "Additive",
},
}
}
So when opening this door, you will hear no sound.
(the best way to do it is to open any sound in audacity, select the sound and use the amplification tool, in the effect tab, then set the amplification to the lowest value. This will reduce the sound volume to 0)
SpoilerShow
Code: Select all
defineObject{
name = "magic_door_block",
baseObject = "base_door",
components = {
{
class = "Model",
model = "assets/models/env/dungeon_door_wooden.fbx",
staticShadow = true,
},
{
class = "Model",
name = "frame",
model = "assets/models/env/dungeon_door_frame.fbx",
},
{
class = "Door",
openVelocity = 10,
closeVelocity = 0,
closeAcceleration = -20,
sparse = true,
openSound = "no_sound",
closeSound = "no_sound",
lockSound = "no_sound",
-- killPillars = true,
},
},
}
set the magic_door_block as following in the editor:
unselect the frame and the model box
a screenshot:
SpoilerShow
