TombEngine
TombEngine copied to clipboard
Moveable:SetVisible() does not save when on timer
I have these lasers on timer so they will be invisible and visible based on timer. However, if I save+load, then the lasers do not disappear/appear as intended, and if they are invisible then the collision reappears.
https://github.com/MontyTRC89/TombEngine/assets/80340234/bbac49f8-2576-46a9-98bd-afd89e3e69d6
Code for the above
timedLaser = {}
function AddToTimedLaserTable()
for k, v in pairs(lasers) do
if (string.find(v:GetName(), "laser")) then
table.insert(timedLaser, v:GetName())
end
end
end
function CreateTimer()
TimeLaser = EventSequence.Create("Timer1", true, false, 7, LevelFuncs.TurnOffLaser, 7, LevelFuncs.TurnOnLaser)
end
LevelFuncs.StartTimer = function()
EventSequence.Get("Timer1"):Start()
end
LevelFuncs.TurnOnLaser = function()
for _, v in pairs(timedLaser) do
local j = GetMoveableByName(v)
j:SetVisible(true)
end
print("turn on")
end
LevelFuncs.TurnOffLaser = function()
for _, v in pairs(timedLaser) do
local i = GetMoveableByName(v)
i:MakeInvisible()
end
print("turn off")
end