 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Nov 20, 2007 1:58 am
Opinion about how Shared Alarms should work |
In v2.12 you can put an Alarm in a global or external module and it gets "shared" between the existing windows. In other words, when the alarm fires, CMUD loops through each module/window and executes the alarm within any module/window that can "see" the alarm.
Right now, the order in which the module/windows are executed is the order in which the modules were created and loaded.
But I was thinking that I might want to tweak this. Obviously the module that contains the alarm can "see" it. So in addition to any windows that might execute the alarm, the alarm is also going to be executed within it's own module at some point.
So, should the alarm execute within it's own module First, or Last? If executed first, then it could initialize some stuff. But if it is executed Last, then it can do cleanup (like disabling itself).
Seems like executing Last would be an advantage for those who want to disable the alarm when it has finished executing in all of the other windows. But I'm interested in opinions on this. Oh, obviously this is only related to repeating alarms. Alarms that fire once actually have a bug in v2.12 in that they get removed after they fire in the first window and they don't get executed in other windows after that. This bug is fixed in 2.13. |
|
|
|
 |
Tarn GURU
Joined: 10 Oct 2000 Posts: 873 Location: USA
|
Posted: Tue Nov 20, 2007 3:02 am Re: Opinion about how Shared Alarms should work |
| Zugg wrote: |
So, should the alarm execute within it's own module First, or Last? If executed first, then it could initialize some stuff. But if it is executed Last, then it can do cleanup (like disabling itself).
|
Hmm.
Ideal world:
First, but the list of "listeners" should be fixed when it fires.
Disabling should apply to the next time it would have fired, not the current time.
If the package/module which owns the alarm needs to send a separate message to subsequent listeners for this firing, a variable can be used.
-Tarn |
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Nov 20, 2007 3:37 am |
| Quote: |
| Disabling should apply to the next time it would have fired, not the current time. |
Hmm, now that's an interesting idea. What do people think about this? If one of the module/windows does a #T- on the alarm, should it go ahead and fire in the rest of the windows and then just disable itself after it has fired in each window? Or should #T- be immediate? If the #T- gets delayed until each window has fired, then I can see calling it's own module First. |
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Tue Nov 20, 2007 12:11 pm |
I think Tarn is right. Owning module/window first, then any other that can see it. After all modules have had thier chance then any #Tą or deletion of a temporary alarm would occur. I am making the not so small assumption that a trigger creating a temporary alarm would create it in the window just the same as it does with a variable.
As a side note I did have a few odd hiccups with global alarms, but as soon as I corrected them to be - instead of * they all worked perfectly. I think the change is good and some sort of compatibility note will help those that still have to transition from zMud. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Tue Nov 20, 2007 2:24 pm |
I would expect that if I have set an alarm up to be global then anything that happens within it would be global as well. So if I use a #T- then the alarm would do its job everywhere then turn itself off everywhere.
I would NOT necessarily wait for the alarm to fire again before disabling itself however. I would suggest something more along the lines of a timeout threshold.
If the alarm will fire again within say five seconds then have it turn itself off right before the next time it would have fired again. On the other hand if the alarm will fire again in ten or more minutes you might want to disable the alarm sooner based on a predetermined timeout period. This is all just blowing in the wind however. If you could set it up so that the alarm could turn itself off instantly after it has run in all modules/windows that would be great. |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Nov 21, 2007 11:40 pm |
So, I thought about this a bit more. One problem is that an alarm cannot execute without a window. So this whole decision of whether the alarm executes in it defined module first or last is moot...in a shared module the alarm cannot execute at all.
And this is what most people would expect I think. For example, what if the alarm script sent something to the MUD, or called #SAY to display text? Where should that text get displayed? If it is displayed in the current window, then you'd see the text in the current window twice: once for the alarm executing within it's own defined module, and once for the alarm executing within the current window.
So, 2.13 isn't going to execute the alarm within it's current module at all. If the alarm is defined within a window, then of course it executes only within that window. But if the alarm is defined in a shared module, then the alarm just executes within each *window* that can see the alarm. |
|
|
|
 |
Asilient_1 Apprentice
Joined: 26 Apr 2007 Posts: 113
|
Posted: Thu Nov 22, 2007 1:26 am |
While the solution you have come to isn't necessarily bad, how about having the option to specify a window for alarms in modules? As I'm seeing it, having an alarm firing in several windows could be more taxing than it has to be.
| Quote: |
| Syntax: #ALA id {timepattern} {commands} class |
Where "class" is it could be class/window, etc. I'm not entirely too certain how that would work out if you have class/windows with similar or the same names.
Alternatively, a change to syntax to set the window in a different way might be needed.
Not entirely sure how possible this is and have only glanced at posts at best.
Hope this is along the lines of what you were looking for. |
|
|
|
 |
Tarn GURU
Joined: 10 Oct 2000 Posts: 873 Location: USA
|
Posted: Thu Nov 22, 2007 1:48 am |
| Zugg wrote: |
So, 2.13 isn't going to execute the alarm within it's current module at all. If the alarm is defined within a window, then of course it executes only within that window. But if the alarm is defined in a shared module, then the alarm just executes within each *window* that can see the alarm. |
If there's some shared module alias that needs to execute periodically, doesn't this result in lots of unnecessary bookkeeping to regulate how often it executes? Example: you have 3 windows, and want the alias in the shared module to execute if any are open, but only once even if more than one is open.
-Tarn |
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Nov 22, 2007 2:28 am |
This has no effect on aliases. It only effects alarms and it only effects alarms that are defined in a *module*. Normal alarms in windows work the same way they always have. If you want an alarm to only run within a certain window, you can already create it in that window using the normal #alarm syntax:
| Quote: |
| Syntax: #ALA id {timepattern} {commands} class |
That syntax already works and creates the alarm within the specified class. If that class is within a window, then the alarm only executes in that window just like it always has.
So, there isn't any "unnecessary bookkeeping". When an alarm fires (it's time expires), CMUD runs the alarm within any window that has access to the alarm. An alarm within a window isn't visible to any other window. So it's simple and straightforward, and it doesn't break any existing alarms. |
|
|
|
 |
Asilient_1 Apprentice
Joined: 26 Apr 2007 Posts: 113
|
Posted: Thu Nov 22, 2007 2:33 am |
I meant if they're in a module, you could specify a windowname for them to route to, rather than going through all windows that can see that alarm.
|
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Thu Nov 22, 2007 3:36 am |
That was part of what the change for using -time properly was for. If an alarm of the form #ALARM {-5} {do stuff} is in a shared module then it will only 'do stuff' in a window that is online. We all got in the habit of using * instead of -, and changing the way alarms work made that distinction more important.
Zugg already said quite clearly that an alarm defined in a window only fires within that window, so that is set. That means we already have 2 ways to make the alarm only work in specific windows.
Now lets say we need to distribute an alarm that only operates in 1 window of each session that is loaded. CMud doesn't do it for us automatically, just like if we distribute a package with triggers that depend on states they won't work too well for a multiplayer. I am fine with having to code around that limitation. I am not about to ask Zugg to write my scripts for me. The alarm that would do it by the way, totally untested but something I am planning on putting in my little toolbox package.
| Code: |
#CLASS UniAlarm
#VAR Sessions {} {}
#ALARM "OneWindwPerSession" {*5} {#THREAD ResetUniAlarm {#WAIT 1000;Sessions="1";#LOOP 2,100 {Sessions=%concat(@Sessions,"-","%i")};Sessions=%replace(@Sessions,"-","|")};#IF (%ismember(%sessionnum,@Sessions) {#DELITEM Sessions {%sessionnum};put commands here}}
#CLASS 0 |
You really have to look through the Predefined Variables every version to find all the new goodies Zugg made. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Nov 22, 2007 5:08 am |
Also, it's actually very easy in your alarm to perform different actions for different windows. The new %context variable gives the name of the window that the alarm is being executed within. So if you only want the alarm to do something in a specific window, just test the %context variable.
|
|
|
|
 |
Tarn GURU
Joined: 10 Oct 2000 Posts: 873 Location: USA
|
Posted: Thu Nov 22, 2007 6:24 pm |
| Zugg wrote: |
This has no effect on aliases. It only effects alarms and it only effects alarms that are defined in a *module*. Normal alarms in windows work the same way they always have. If you want an alarm to only run within a certain window, you can already create it in that window using the normal #alarm syntax:
| Quote: |
| Syntax: #ALA id {timepattern} {commands} class |
That syntax already works and creates the alarm within the specified class. If that class is within a window, then the alarm only executes in that window just like it always has.
So, there isn't any "unnecessary bookkeeping". When an alarm fires (it's time expires), CMUD runs the alarm within any window that has access to the alarm. An alarm within a window isn't visible to any other window. So it's simple and straightforward, and it doesn't break any existing alarms. |
I don't think I made myself clear, but maybe I'm failing to understand something obvious.
Example:
I have a shared module with an alias that I'd like to run once every second (to update shared variables). If the alarm can't fire in the module, then the alias has to be called from someplace the alarm does fire. In this case, assume that I don't know which window(s) will be open (multiplaying, chat windows that might be open or closed, etc.). It seems to require extra bookkeeping to make sure that the alias is run once and only once per second.
-Tarn |
|
|
|
 |
Tech GURU

Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Nov 23, 2007 3:49 am |
Definitely should run first, and I think it should disable immediately. I can see the fixed 'listener' list being handy, but more often than not I only want my alarm fired in one window so I think the immediate T- would be what I want. Now granted you could make an argument for not doing so, but I think my approach represent the 90% usage case. Of course I could be wrong.
|
|
_________________ Asati di tempari! |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Nov 26, 2007 4:50 pm |
I think you guys are still confusing global alarms with normal alarms. If you only want an alarm to run once within a single window, then you should be using a normal alarm within that window. Remember that using the #ALARM command to create a new alarm *will* create the alarm by default in the current window. So this will continue to work the way you expect.
What we are talking about here is global alarms that you add to some external package/module. This alarm would probably not be a "run once" alarm, but would be something that runs at an interval. You control which windows run this alarm by enabling/disabling the package that contains the alarm in each window.
But when multiple windows have access to the same global alarm, then that alarm is always going to run within each window that sees it. Doing a #T- in one window won't prevent it from running within other windows. If you need to do this, just use a variable and set it to 1 and then check that variable within the alarm to prevent it from running more than once. |
|
|
|
 |
|
|
|