Wall Lanterns Resurrected
Ignore the previous wall lantern solution as it doesn't work outside the editor. The lanterns you light don't survive save games because they were created via FX when I should have used objects instead. So, here is the revised fully functioning and simpler solution:
Code: Select all
defineObject{
name = "wall_lantern_fx_3",
class = "LightSource",
lightPosition = vec(-1.18, 1.85, 0),
lightRange = 12,
lightColor = vec(0.7, 0.5, 0.5),
brightness = 10,
castShadow = true,
particleSystem = "torch",
placement = "floor",
editorIcon = 88,
}
defineObject{
name = "wall_lantern_fx_2",
class = "LightSource",
lightPosition = vec(0, 1.85, -1.18),
lightRange = 12,
lightColor = vec(0.7, 0.5, 0.5),
brightness = 10,
castShadow = true,
particleSystem = "torch",
placement = "floor",
editorIcon = 88,
}
defineObject{
name = "wall_lantern_fx_1",
class = "LightSource",
lightPosition = vec(1.18, 1.85, 0),
lightRange = 12,
lightColor = vec(0.7, 0.5, 0.5),
brightness = 10,
castShadow = true,
particleSystem = "torch",
placement = "floor",
editorIcon = 88,
}
defineObject{
name = "wall_lantern_fx_0",
class = "LightSource",
lightPosition = vec(0, 1.85, 1.18),
lightRange = 12,
lightColor = vec(0.7, 0.5, 0.5),
brightness = 10,
castShadow = true,
particleSystem = "torch",
placement = "floor",
editorIcon = 88,
}
Define 4 LightSource objects - one for each facing position. The only difference between the four is the name and lightPosition. This has to be done because the convenient FX translate() function doesn't work with LightSource objects. They can't be moved. You also need to define a sound object:
Code: Select all
defineSound{
name = "wall_lantern_crackling",
filename = "assets/samples/env/torch_burning_01.wav",
loop = true,
volume = 0.5,
minDistance = 2,
maxDistance = 6,
}
Lastly, replace the logical lantern script. It's simpler now.
Code: Select all
defineObject{
name = "wall_lantern_logical",
class = "Alcove",
anchorPos = vec(0, 1.65, 0),
targetPos = vec(0, 1.65, 0),
targetSize = vec(0.2, 0.2, 0.2),
onInsertItem = function(self, item)
if item.name == "torch" or "everlasting_torch" then
spawn("wall_lantern_fx_"..self.facing, self.level, self.x, self.y, 0)
playSoundAt("wall_lantern_crackling", self.level, self.x, self.y)
self:destroy()
end
end,
placement = "wall",
replacesWall = false,
editorIcon = 84,
}
Don't forget the visual lantern script from my previous post.
I also added a new feature you can see at the end of a demo vid I put on the tube:
Wall Lanterns Resurrected