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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
DDMyth
Newbie


Joined: 11 Dec 2006
Posts: 9

PostPosted: Tue Mar 11, 2008 8:06 pm   

Scripting question (trigger+)
 
I'm trying to wrap my head around some way to make this work, so far, unsuccessfully. I'm trying to Capture about 20 lines that are sent between two others. I play Imperian, and those lines are whatever's between "Current Defences:" and "You are protected by %d defences.".

This is the output from the mud:
Current Defences:
You are blind.
You are deaf.
You have insomnia, and cannot easily go to sleep.
You have eaten the quince fruit and are extremely energetic.
You are protected by 4 defences.

and I'm not sure how I could go about this. I don't know which kind of multistate trigger to use, and I don't know how to "read" each of those into doing what I want it to do. For example, when it sees "You are deaf.", I want it to use an already defined alias called defgive and pass it %1 which should equal "deaf". The reason I can't just make it a sequential multi-state trigger is that those lines change, sometimes I'll have "You are deaf." and sometimes I won't, sometimes I'll have a few extra ones that weren't there before.

Should I make a list with each of these possibilities (i.e. #VA deflist {You are blind.|You are deaf.[...]) and have a loop run through them (roughly 35 entries)? I don't think so, because that would eat a whole lot of cpu power for that brief moment.

If anyone could help me out, I'd really appreciate it. Thanks!
Reply with quote
JQuilici
Adept


Joined: 21 Sep 2005
Posts: 250
Location: Austin, TX

PostPosted: Tue Mar 11, 2008 8:37 pm   
 
At first glance, I would suggest:
  1. Make a class 'Defences'
  2. Outside the class, make a trigger to turn the class on:
    Code:
    #trig {^Current Defences:} {#t+ Defences}

  3. Inside the class, make a trigger for each possible line you could see. E.g.
    Code:
    #trig {^You are blind.} {defgive} {Defences}

  4. Intside the class, make a trigger to turn the class off:
    Code:
    #trig {^You are protected by %d defences.} {#t- Defences} {Defences}

  5. Disable the class 'Defences'

That should turn on all your triggers only between those two lines. And it won't matter which ones show up, in what order, etc. This will fire off your response to each line as it shows up.

Now, if you need/want to do your responses in a different order than the lines appear, it'll be more complicated.

NOTE: I have not tested any of this code. I'm just writing off the top of my head.
_________________
Come visit Mozart Mud...and tell an imm that Aerith sent you!
Reply with quote
DDMyth
Newbie


Joined: 11 Dec 2006
Posts: 9

PostPosted: Tue Mar 11, 2008 9:03 pm   
 
Thanks, I'll try that right away. I appreciate all input. If anyone has a different way of doing it, feel free to mention it!
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Mar 11, 2008 10:19 pm   
 
You'll probably want to check the "disable on startup" box of the class just to make sure, too.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
DDMyth
Newbie


Joined: 11 Dec 2006
Posts: 9

PostPosted: Thu Mar 13, 2008 6:03 am   
 
Alright. I have that part working. Now I want to compare one list to another, and I'm trying to make it work. I'm trying to use a #LOOP to do this, and here it is:

#LOOP 22 {#IF (%ismember( %item( @tocheckvs, %i), @deflist)) {#SHOW {You don't have your %item( @tocheckvs, %i) defense!}}}

It's meant to compare strlist @tocheckvs to @deflist to find what @tocheckvs has that @deflist doesn't. Only problem, is, of course, it doesn't work like it's supposed to. I'm relatively new to this scripting, but I can't seem to find out what's wrong with the functions I'm calling, if I'm doing it wrong, or however.

Thanks.

EDIT:
I was wondering, is there a way to make a multiline "withinline|param=1" match one of either or? I can't seem to figure out how to do it. I.E. "You have eaten a hyssop stem" will be followed by either "You go blind" or "It does nothing". Any way to jimmy it up, considering ZMUD doesn't seem to like having two different multistate triggers with the same first pattern?
Thanks again!
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Mar 13, 2008 10:52 am   
 
{You go blind|It does nothing}

And for your other question, use #forall instead of #loop.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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