|
ReedN Wizard
Joined: 04 Jan 2006 Posts: 1279 Location: Portland, Oregon
|
Posted: Thu Apr 02, 2009 2:31 pm
What's the best way to lengthen the time until an alarm fires? |
I have a case where I have about 30 alarm triggers and during normal operation I want them to fire with their normal amount of time, such as:
*2
*1.5
*1.8
etc...
However, when I'm afflicted with a certain thing I'd like to lengthen those alarm times by a constant amount so that I have a little bit longer time until they fire, such as:
*%eval(2+@additional_time)
*%eval(1.5+@additional_time)
*%eval(1.8+@additional_time)
I've played around with this and () doesn't work for evaluating the expression. I need to use the %eval() function to get this to operate. However, I recall that the use of %eval() was discouraged for performance reasons. Is there a better way to do this? And if I use %eval() am I going to run into performance issues? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Apr 02, 2009 2:36 pm |
Use the %alarm function. %alarm can return the current time, and then you can add something on. It'll look like:
#call %alarm("some alarm",(%alarm("some alarm")+5000)) |
|
|
|
ReedN Wizard
Joined: 04 Jan 2006 Posts: 1279 Location: Portland, Oregon
|
Posted: Thu Apr 02, 2009 2:50 pm |
That's a really nice way to extend a single alarm or a small group of alarms, but in this case I have 30+ at least. However, you've got me thinking about this method and wondering if I could possibly track down all the ways I enable these... If so I could execute the alarm time addition right where I enable them. I'll have to so some testing on this.
If it turns out that the %eval() is the only practical way of doing this, is there going to be a performance issue with it? How often would Cmud evaluate that alarm *%eval(5+@var) statement? |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Thu Apr 02, 2009 3:10 pm |
Even if you were going to do it that way, you wouldn't want to use %eval(). *$newtime should work, and just have $newtime = 5 + @var.
|
|
|
|
ReedN Wizard
Joined: 04 Jan 2006 Posts: 1279 Location: Portland, Oregon
|
Posted: Thu Apr 02, 2009 6:56 pm |
The %eval is in the trigger string area of the alarm. Where a pattern normally is.
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Thu Apr 02, 2009 8:23 pm |
Yes, I understood that. And I have just verified that the following works:
Code: |
<alias name="foobar" id="32">
<value>$testtime = 100 + 400
#alarm "testtime" *$testtime {#show test}</value>
</alias>
|
That makes an alarm whose pattern is *500. So, it doesn't need an %eval(). |
|
|
|
ReedN Wizard
Joined: 04 Jan 2006 Posts: 1279 Location: Portland, Oregon
|
Posted: Fri Apr 03, 2009 2:08 am |
If I wanted to create them every time, then that would work great. The %alarm() function looks the best for just modifying them instead of creating them every time.
|
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Fri Apr 03, 2009 1:47 pm |
I am curious about the original observation about %eval() too. That's interesting.
If you need to write 30 variables into memory that in itself will be a draining task, however would %eval() in the pattern write 30 variables a millisecond into memory? If that were true oh boy. Anyway, why does the %eval() need to be in the alarm when the %alarm() function can update the alarm times with %eval() from an alias? You could use trigger names not times for update reference and call the set from a database variable as trigger_name=old_time. I suppose also a list would work, but I like to read names.
That seems a task load to me too but not interminable. I wonder what this system looks like when it fires in game. |
|
|
|
ReedN Wizard
Joined: 04 Jan 2006 Posts: 1279 Location: Portland, Oregon
|
Posted: Fri Apr 03, 2009 2:54 pm |
I tried it out and it turns out Fang's suggestion worked like a charm. It turned out to be the easiest to modify them right when they were enabled.
|
|
|
|
|
|