Re: exported.writes inside a hook threadlock?

"Joshua M. Berne" <berne-7iHiS5+6wm7SUeElwK9/[email protected]>
Newsgroups gmane.comp.games.mud.client.lyntin
Message-ID <[email protected]>
I think the problem in your original program was that you were trying to
use write_user_data in the wrong place, or for the wrong thing.. or
something.  It's for writingg user data out to the ui, and this just goes
back off the hook you were already listening to.

You can listen to that hook, but instead call exported.lyntin_command() to
send a command back to the session when something happens.  Or if you
prefer do session.writeSocket("..\n") in order to put raw data to the
mud.  (Do this only if you absolutely don't want any processing done on
what you send out.)

The distinction you'll find in the action module is that it hooks to the
mud_filter_hook, but since it doesn't eat the data coming in, that's
really not even a neccessity.    Mud-filter also limits itself ot just
data from the mud, not lyntin messages and other such thigns, so you might
actually want to focus on that.

a valid hook function to register would be:

def do_stuff(args):
  message = args["data"]
  session = args["session"]
  if message.find("kicks you in the ass") != -1:
    exported.lyntin_command("kickd sven",internal=1,session=session)
  return message

the internal is so it doesn't show up in the history.  The rest is pretty
self-explanatory.  Then just do 
  exported.hook_register("mud_filter_hook",do_stuff)

in load()  and you're done.

On Mon, 12 Apr 2004 [email protected] wrote:

> 
> --> Monday, April 12, 2004, 3:51:50 PM, [email protected] wrote:
> 
> > On Mon, 12 Apr 2004 [email protected] wrote:
> >>
> >> --> Monday, April 12, 2004, 3:29:49 PM, [email protected] wrote:
> >>
> >> > On Mon, 12 Apr 2004 [email protected] wrote:
> >> >>
> >> >> Because I want to know how to do it in a module. The "actions"
> >> >> I will be implementing are complex and deal with multiple lines
> >> >> of text at different times among other things.
> >>
> >> > Ok.  Well, in that case I would either take the existing action module
> >> > and extend it to add the functionality you need or use it as a basis
> >> > to implement the functionality you need.
> >>
> >> > The action module is in lyntin/modules/action.py
> >>
> >> Can anyone show me how to parse text from a mud an act on them apart
> >> from using actions? I know how to use actions and I know I cannot use
> >> them now. I don't want more action-like functionality, I want to write a
> >> complex Python module. I have tried but run into this infinite loop
> >> problem, am I supposed to be using another hook?
> >>
> >> The documentation in engine.py made me think to_user_hook was my only
> >> option, but sometimes I see other hooks elsewhere, and really I am not
> >> sure what hook I would want to use to begin with...
> >>
> >> Is there another reason this question is so difficult to answer?
> 
> 
> > I think the difficulty in answering your question to your liking so far is
> > that you haven't really provided a specific enough question to answer.
> 
> > What you're describing is exactly what the action module does, though
> > you've added the additional issue of "wanting to do things over multiple
> > lines" which the action module does not do (at least, I don't think it
> > does--I certainly don't use it for that).
> 
> > I suggested you read through the action module and base your module on the
> > structure there.  The hooks you want to use will be the same.  The things
> > you want to do will likely be done the same.  The differences between your
> > module and the action module will be whatever you need to change to solve
> > your specific problem which you've outlined very vaguely.
> 
> > I've answered your question as best as I can.  My advice is to go look at
> > the code in lyntin/modules/action.py and model your module after that one.
> 
> > If that's still a crummy answer, provide more specifics as to what you're
> > trying to do.  Usage scenarios might help.
> 
> Well, can you provide an example of this hardcoded as a module :
> 
>   1. Mud sends "Tom kicks you"
>   2. Lyntin sends back "kick Tom"
> 
> If you read my first question again it seems the primary problem
> I have is the infinite loop and to_user_hook misunderstanding.
> 
> Am I simply using the wrong hook?
> 
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> Lyntin-devl mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/lyntin-devl
> 




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.