Page 1 of 1
Timer interval
Posted: Wed Mar 25, 2020 3:13 am
by ratman
How much time is the timer interval? If I set it to 27 I would expect it to count 27 seconds and then activate, but it seems to activate at random times. Thanks in advance for the help.
Re: Timer interval
Posted: Wed Mar 25, 2020 4:34 am
by Isaac
ratman wrote: ↑Wed Mar 25, 2020 3:13 am
How much time is the timer interval? If I set it to 27 I would expect it to count 27 seconds and then activate, but it seems to activate at random times. Thanks in advance for the help.
It depends on the relative location of the timer; timers that are not on the same map level as the party have reduced processing.
If you MUST have a precise timer, [and assuming Grimrock2] then create it as a timer component on the party object.
Re: Timer interval
Posted: Wed Mar 25, 2020 5:04 pm
by ratman
I'm new to the game. How would I create a timer component on the party object?
Also I've encountered a new problem. I have it so that when the party steps onto the pressure plate, It starts the timer, but the timer starts before they've stepped on it.
Re: Timer interval
Posted: Thu Mar 26, 2020 2:10 pm
by Zo Kath Ra
ratman wrote: ↑Wed Mar 25, 2020 5:04 pm
How would I create a timer component on the party object?
Put this code in a script entity:
Code: Select all
function timerTick()
print(Time.currentTime())
end
party:createComponent("Timer")
party.timer:addConnector("onActivate", self.go.id, "timerTick")
The standard values are:
currentLevelOnly = false
disableSelf = false
timerInterval = 1
triggerOnStart = false
To change these values:
party.timer:setCurrentLevelOnly(true)
party.timer:setDisableSelf(true)
party.timer:setTimerInterval(27)
party.timer:setTriggerOnStart(true)
If you want to attach multiple timers to the party, you must give them names.
Example:
Code: Select all
function timerTick1()
print("timerTick1", Time.currentTime())
end
function timerTick2()
print("timerTick2", Time.currentTime())
end
party:createComponent("Timer", "timer_1")
party.timer_1:setTimerInterval(5)
party.timer_1:addConnector("onActivate", self.go.id, "timerTick1")
party:createComponent("Timer", "timer_2")
party.timer_2:setTimerInterval(10)
party.timer_2:addConnector("onActivate", self.go.id, "timerTick2")
To remove a component when you don't need it anymore:
party:removeComponent("timer")
party:removeComponent("timer_1")
party:removeComponent("timer_2")
Re: Timer interval
Posted: Thu Mar 26, 2020 2:15 pm
by Zo Kath Ra
ratman wrote: ↑Wed Mar 25, 2020 5:04 pm
I have it so that when the party steps onto the pressure plate, It starts the timer, but the timer starts before they've stepped on it.
You need to disable the Timer component.
In the dungeon editor, click on the timer and remove the check mark next to Components -> timer.
If the check mark is set, the timer starts running automatically as soon as the dungeon has been loaded.
Re: Timer interval
Posted: Thu Mar 26, 2020 6:25 pm
by ratman
okay thanks.