Any way to delay a task?
Hello
I want to know if there is a way to delay a currently running task (adding n to the remaining task time). I know the method change_task exists but I checked and I haven't found a way to get the remaining time for a specific task. Any help would be appreciated. |
Re: Any way to delay a task?
Quote:
You could use a thinking entity. You can test this in game by using 'set' at 1:00 on the game clock. If you do not use 'add', the task will complete at 0:55. Each time you use 'add', it will add 1 second. So using 'add' twice after doing 'set', will make it end at 0:53. PHP Code:
|
Re: Any way to delay a task?
Euhm It's probaly me but why repeating the think every 1.0 second?
PHP Code:
|
Re: Any way to delay a task?
I did consider that but didn't have time to make sure it worked correctly. Did you test?
I think you may have to not add onto the existing g_TaskTime, but just add onto the existing next think value. I think your method will compound the time with each addition. My thought is that would work if you += it to the game time value when the task was created. Plus you have to take into consideration multiple tasks with different intervals happening. I'm looking at this on a phone mind you |
Re: Any way to delay a task?
If that's the only way, I was thinking about creating another task, that repeats itself every second, thus increasing the integer by 1 each time.
But I wonder which method would be less resource intensive. |
Re: Any way to delay a task?
Quote:
timer delays with 1 second? |
Re: Any way to delay a task?
Quote:
When I want to delay the main task, simply I use change_timer with the value from the counter task. I don't know if a constant repeating task would be more resource intensive like the entity method Bugsy suggested. |
Re: Any way to delay a task?
Task creation is an expensive operation, avoid it if you can. I can make this easier to use, or even build it into your code for you.
|
| All times are GMT -4. The time now is 09:21. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.