Timer interval

Are you looking for fun Custom Dungeons that you could play or do you want to share your mod with others? Then this forum is for you!
Post Reply
ratman
Posts: 75
Joined: Fri Jan 10, 2020 1:13 am

Timer interval

Post by ratman » 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.

User avatar
Isaac
Posts: 2943
Joined: Fri Mar 02, 2012 10:02 pm

Re: Timer interval

Post by Isaac » Wed Mar 25, 2020 4:34 am

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.

ratman
Posts: 75
Joined: Fri Jan 10, 2020 1:13 am

Re: Timer interval

Post by ratman » Wed Mar 25, 2020 5:04 pm

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.

Zo Kath Ra
Posts: 827
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Timer interval

Post by Zo Kath Ra » Thu Mar 26, 2020 2:10 pm

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")

Zo Kath Ra
Posts: 827
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Timer interval

Post by Zo Kath Ra » Thu Mar 26, 2020 2:15 pm

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.

ratman
Posts: 75
Joined: Fri Jan 10, 2020 1:13 am

Re: Timer interval

Post by ratman » Thu Mar 26, 2020 6:25 pm

okay thanks.

Post Reply