Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Sun Jun 17, 2007 7:10 pm   

Package Alarm Triggers
 
I have a session, we'll char "CharA" and another session, called "CharB", as well as a package called "Idler".

Idler is enabled for CharA, but not for CharB (intentional)... and Idler utilizes an #ALARM trigger with a +10:00 timer on it (though that is changeable). Now, I'd like for the #ALARM trigger to remain in the Idler package (if for nothing more than code cleanliness' sake), but I've noticed that if my CharB session has focus, the ALARM trigger does not fire on CharA. Is there a way to ensure this occurs?

I'm using 1.26, but I noticed the same behavior in 1.33 before I downgraded for mapper compatibility.

And in case you're going to question the wisdom of having Idler as a package instead of just a class, I was going to upload it to the library as soon as I worked out the kinks in multi-session functionality.

Is it possible for the ALARM trigger to fire even if the only window the package is loaded for is in the background? ...or will I have to redesign the script to create the ALARM in the active package window. If the latter is the case, how do I tell one package to create a trigger in another (or in a window)? Do I use the :CharA:#TR.... syntax?
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Jun 18, 2007 5:15 pm   
 
To create a trigger in another window, you can do this:
Code:

#CLASS //Windowname/Classname
#TRIGGER {pattern} {commands}
#CLASS 0

Alarms utilize Windows Timers, which require a Window Handle to run. Thus, alarms only really work when defined within an actual window. I'm not sure what really happens when you define a window in a separate module or package that doesn't have a Window Handle. It's probably not going to work. Usually what happens when you execute an alarm is that it will get assigned to the current window that has keyboard focus. So the alarm will not be running within the context of your package, it will be running in the context of the current window. In any case, there has been little testing of this kind of stuff.

Also, each alarm can only be active for a single window at a time (again, because Windows needs a Window Handle for the timer). By putting an alarm in an external package, you are allowing multiple windows to share the same single package, which means that now you can have multiple windows trying to share a single timer. Again, this won't work because a timer can only be assigned to a single window handle, so the alarm might get assigned to the wrong window and now work in the window that you think it should.

Until CMUD has a method for handling multiple "instances" of settings, things that use window handles, such as timer and buttons should really stay within a single window.
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Tue Jun 19, 2007 10:22 pm   
 
Hrmm, ok... I wasn't entirely sure how CMud was handling packages at the moment. I'm afraid I thought that a package instance was loaded for each session it was enabled for.

Knowing this, I will have to redesign this package before I export it to the library.

This brings me one question... as this is an anti-idle script of sorts, I have a trigger in the Idler class that's basically #ONINPUT {^} {...lots of code...}. Is there a way to determine within the executing code of that trigger, which window/session/whatever it occurred in? If so, can I assign that to a local variable for use in loading/saving settings/etc... something akin to:
Code:

$idlesession = %getmethewindowthishappenedin()
$lastcommandtime = %db(//$idlesession/Idler/@IdlerVars,LastCommandTime)
... more code...
#ALARM "//$idlesession/Idler/Idler_VoidTrig" {+10:00} {Idler_AntiVoid}


Basically, how should I structure the complex //$variable/class/@var so that CMud parses it correctly, assuming that I do NOT want to use the old #CLASS yadayada ...code... #CLASS 0 style of coding? (Because if another trigger fires during that execution, all sorts of "bad stuff" will happen). Also, will the "trigger_id" optional argument for #TR and #ALARM allow me to specify the window/class via a similar syntax, or will I be forced to use a #CLASS //session/class ..#CLASS 0 for just that one trigger-creation operation?

I may've written this all out badly, but if there's anything I can include to make it more obvious what I want to do, please ask...
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Wed Jun 20, 2007 5:58 am   
 
OK... updating. I tried the obvious %window variable... unfortunately it returns the active window, instead of the window that raised the trigger, so that's not useable.

Zugg, I have been trying to figure out your //windowname/classname syntax... I tried it with a #VAR command:
Code:

#VAR //CharA/Idler/TestVar {testing}

Unfortunately the syntax coloring in 1.26 and the script execution interpreted the // as a comment and the rest of the line was ignored... something I need to change here?
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Jun 20, 2007 4:14 pm   
 
I believe you want %curwin and %session. You can find more info on both at Predefined Variables help topic.
_________________
Asati di tempari!
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Wed Jun 20, 2007 10:51 pm   
 
Thanks for the reply, however %curwin and %session don't help at all, either....

Here's what I'm trying to do.

Let's say I have 3 sessions/windows, we'll call them CharA, CharB, and CharC.
Let's say I have package "Idler" enabled on CharA and CharB, with a trigger in it that could fire from either screen.

If CharC has focus, and something in CharA fires the trigger, I want a variable that returns "CharA". If CharB fires the trigger, I want "CharB".

Currently, both %window and %curwin would return "CharC" regardless of which window actually fired the trigger.

%session doesn't appear to return anything... at least not something I can figure out how to handle (#ECHO shows blank string)

From what I can tell, this behavior is the same, regardless of where the trigger resides: in Package "Idler", or in either CharA or CharB windows.
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Jun 25, 2007 5:34 pm   
 
Thinjon100: The color syntax highlighting in 1.26 isn't going to work...you need to use v1.33 for the color highlighting to work properly with this.

I'll take a look at %window and %curwin. Right now it looks like they both return the window that currently has keyboard focus. I'll see if I can change this so that they return the window that caused the OnInput trigger to fire.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net