Area enter lights
Attach to an Area in Module editor. Tag its light placements "arrival_lamp". Area self has properties, but no placement lights.
-- Attach to an Area in Module editor. Tag its light placements "arrival_lamp".
-- Area self has properties, but no placement lights.
local light_effect = { tags = {"arrival_lamp"} }
function OnEnter(character)
local objects = Area.FindByTag("arrival_lamp")
for i = 1, #objects do
local lights = objects[i]:GetLights()
for j = 1, #lights do lights[j].Enabled = true end
end
end
function OnExit(character)
local objects = Area.FindByTag("arrival_lamp")
for i = 1, #objects do
local lights = objects[i]:GetLights()
for j = 1, #lights do lights[j].Enabled = false end
end
endDoor opened lights
Attach to a Door Script component. Tag target light placements "door_lamp". Engine-read names must keep their spelling.
-- Attach to a Door Script component. Tag target light placements "door_lamp".
-- Engine-read names must keep their spelling.
local light_effect = { tags = {"door_lamp"} }
function OnOpened(user)
local objects = Area.FindByTag("door_lamp")
for i = 1, #objects do
local lights = objects[i]:GetLights()
for j = 1, #lights do
lights[j].Enabled = not lights[j].Enabled
end
end
end
-- Empty lifecycle success still completes durably.
function OnClosed(user)
endLever torches
exported_properties / light_effect / OnUsed are read by the engine: do not rename them. Light-only OnUsed: every tagged Light and the lever's optional lamp toggle.
-- exported_properties / light_effect / OnUsed are read by the engine: do not rename them.
-- Light-only OnUsed: every tagged Light and the lever's optional lamp toggle.
local exported_properties = {
target_tag = { type = "string", default = "crypt_torch" },
}
local light_effect = { tags = { "$target_tag" }, self = true }
function OnUsed(user)
local objects = Area.FindByTag(self:GetProperty("target_tag") :: string)
for i = 1, #objects do
-- Self is handled once below even if the author also tags the lever.
if objects[i] ~= self then
local lights = objects[i]:GetLights()
for j = 1, #lights do
lights[j].Enabled = not lights[j].Enabled
end
end
end
local lamps = self:GetLights()
for i = 1, #lamps do
lamps[i].Enabled = not lamps[i].Enabled
end
endModule start
Attach to the Module Script card. Inspect the isolated play save's owner counter.
-- Attach to the Module Script card. Inspect the isolated play save's owner counter.
function OnModuleStart()
local starts = GetUses() + 1
if IsFirstStart() then starts = 1 end
SetUses(starts)
PublishUses(starts)
end