Timer?
Timer?
It seems that timer works a little differently than in LoG1. I can't figure out how to use them so that they don't start at the beginning of the game/level.. I tried to use pressure plates so that as pressure plate is activated it starts the timer and when it is deactivated it would stop it. But the timer runs without waiting for the activation? O.o
Is this a bug, or am I missing something?
Is this a bug, or am I missing something?
Re: Timer?
Select the timer, then under "Components" you will see a checkbox in front of "timer". Leave it checked for the timer to start immediately, and uncheck it to disable the timer until explicitly started.
Re: Timer?
I'll add my question here, as it got buried in that general thread without an answer. If this has been covered in some tutorial or somewhere else, I would appreciate a nudge to right direction.
What does the "currentLevelOnly" do in timers? It seems that timers pause even without it when you're in a different level. And is there a way to make them tick even when you're not in the same level as the timer?
What does the "currentLevelOnly" do in timers? It seems that timers pause even without it when you're in a different level. And is there a way to make them tick even when you're not in the same level as the timer?
Re: Timer?
Timers keep running when the box isn't checked. However they only run in a 1:1 timescale if you are in the same level as the timer. The farther away you are from the timer, the less often it will update. This was done to save performance. If you need accurate timing across levels you can set up a timer in each level that get enabled on entering the level (and disable the previous timer).zeltak wrote:I'll add my question here, as it got buried in that general thread without an answer. If this has been covered in some tutorial or somewhere else, I would appreciate a nudge to right direction.
What does the "currentLevelOnly" do in timers? It seems that timers pause even without it when you're in a different level. And is there a way to make them tick even when you're not in the same level as the timer?
Re: Timer?
Alright, thanks. I was trying to figure out a way to accomplish what I wanted. But I didn't think of the easy solution of double timers. Thanks.
Re: Timer?
The party can be given Counters and Timers as components...
You can create a party timer with this code that will not suffer timescale issues
(I tested it by printing the counter value each second, and then jumping down a bunch of pits)
Place the definition in your init.lua
You can create a party timer with this code that will not suffer timescale issues
(I tested it by printing the counter value each second, and then jumping down a bunch of pits)
Place the definition in your init.lua
SpoilerShow
Code: Select all
-----------------------------------------------party timer
defineObject{
name = "party",
baseObject = "party",
components = {
{
class = "Counter",
name = "partycounter",
},
{
class = "Timer",
name = "partytimer",
timerInterval = 1.0,
triggerOnStart = true,
onActivate = function(self)
self.go.partycounter:increment()
local v = self.go.partycounter:getValue()
return hudPrint("Time = "..v.."")
end
},
}
}
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Timer?
wow, what an easy perfect solution! any downside?
Finished Dungeons - complete mods to play
Re: Timer?
I have not found anything yet...
But that has me feeling quite suspicious haha
Going to keep running some more tests today,
I am hoping I can use it as a standardiser for other timers....
or just base timed scripts off the party timer.... hopefully it works as intended!
But that has me feeling quite suspicious haha
Going to keep running some more tests today,
I am hoping I can use it as a standardiser for other timers....
or just base timed scripts off the party timer.... hopefully it works as intended!
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Timer?
Ok, I have made a simple script for giving the party water breathing for 60 seconds
and the timing is based from the partytimer
just add a connector from partytimer to oa spawned waterBreathCounter and set onActivate (partytimer) to decrement waterBreathCounter
add a connector from waterBreathCounter to game script and set onActivate (waterBreathCounter ) to activate the clean up (waterBreathStop())script
I tested this out by connecting a pressure plate to the script and then starting the party on the plate square
that way partytimer (or partycounter) should = waterBreathCounter even if we go jumping down pits for a minute
and the timing is based from the partytimer
just add a connector from partytimer to oa spawned waterBreathCounter and set onActivate (partytimer) to decrement waterBreathCounter
add a connector from waterBreathCounter to game script and set onActivate (waterBreathCounter ) to activate the clean up (waterBreathStop())script
I tested this out by connecting a pressure plate to the script and then starting the party on the plate square
that way partytimer (or partycounter) should = waterBreathCounter even if we go jumping down pits for a minute
SpoilerShow
Code: Select all
function waterBreath()
local t = party.partytimer
local c = findEntity("waterBreathCounter")
if c ~= nil then
c:destroy()
end
t:removeConnector("onActivate", "waterBreathCounter", "decrement")
spawn("counter",party.level,party.x,party.y,party.elevation,party.facing,"waterBreathCounter")
waterBreathCounter.counter:setValue(60)
t:addConnector("onActivate", "waterBreathCounter", "decrement")
waterBreathCounter.counter:addConnector("onActivate", "game", "waterBreathStop")
playSound("generic_spell")
for i = 1, 4, 1 do
if party.party:getChampion(i):isAlive() then
party.party:getChampion(i):setCondition("water_breathing", 10)
end
end
end
function waterBreathStop()
local t = party.partytimer
local c = findEntity("waterBreathCounter")
if c then
c:destroy()
end
t:removeConnector("onActivate", "waterBreathCounter", "decrement")
for i = 1, 4, 1 do
if party.party:getChampion(i):isAlive() then
party.party:getChampion(i):removeCondition("water_breathing")
end
end
hudPrint("this works")
end
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)