|
Lyrael Beginner
Joined: 17 Mar 2004 Posts: 17 Location: USA
|
Posted: Wed Jun 07, 2006 9:05 am
Simple Script for a scripting n00b |
Hi all,
I tried to find something similar to this in the forums - and I'm sure it's there - but couldn't find it.
What I'd like to do is this:
Repeat several actions in a loop until a specific pattern (phrase) is received from the MUD.
Is there an example of this type of script somewhere?
Thanks in advance for any assistance. |
|
|
|
birkoff Beginner
Joined: 01 Jun 2006 Posts: 16
|
Posted: Wed Jun 07, 2006 9:33 am |
do you want the loop to be time-controlled (as in looping every 500 ms for example), or run the loop every line recieved, until the line recieved is matched?
|
|
|
|
Lyrael Beginner
Joined: 17 Mar 2004 Posts: 17 Location: USA
|
Posted: Wed Jun 07, 2006 10:21 am |
The latter of the two:
Specifically I want to automate the following:
>reel line (wait for: You pull your line in.)
>cast line (wait for: You cast your line)
>watch line (wait for: You feel a tug on your line)
repeat the above until..
>You're line snaps!
(Then I've got to re-string the pole and run the script again)
No need to wait for the fish being caught yet - my skill isn't high enough - this script is just for repeating the task to gain skill until I have to restring the pole. (Though I'm sure I could use it for other things too)
Does that help at all?
And thanks for replying :) |
|
|
|
birkoff Beginner
Joined: 01 Jun 2006 Posts: 16
|
Posted: Wed Jun 07, 2006 10:41 am |
one more thing - does the line snap anytime between those actions, or after a specific action (e.g. reel line)?
|
|
|
|
Lyrael Beginner
Joined: 17 Mar 2004 Posts: 17 Location: USA
|
Posted: Wed Jun 07, 2006 11:35 am |
It's never done it for me (the snap line) - but I suppose it's conceivable it could - but it would always come after watch line - never after reel line.
Since I know I can't catch any fish for quite awhile - I don't have to worry about >set hook, tug line left, tug line right or loosen line
I'm hoping with some examples, I might learn how to customize/modify some script examples on my own eventually. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Wed Jun 07, 2006 11:45 am |
You can use a multi-state trigger for this:
#TRIGGER "lineTrigger" {You pull your line in.} {cast line}
#COND {You cast your line} {watch line}
#COND {You feel a tug on your line} {reel line}
And then you would have another trigger that detects when the line snaps and resets everything:
#TRIGGER {Your line snaps!} {string pole;#STATE "lineTrigger" 0;reel line}
The multi-state trigger will be in a different state depending on the part of the sequence it is. Each state looks for a different message from the MUD before sending the command and proceeding to the next step. If at any point the line snaps, the second trigger will see this and re-string the pole. After this, it resets the multi-state trigger to its initial state and reels the line once more to restart the sequence. Once you have these triggers created, all you need to do to start the sequence is to enter the first "reel line" command.
Note: I corrected what I assumed to be a typo in the pattern for the second trigger. If this typo is how the MUD actually sends it, then change the pattern. |
|
_________________ Kjata |
|
|
|
Lyrael Beginner
Joined: 17 Mar 2004 Posts: 17 Location: USA
|
Posted: Wed Jun 07, 2006 12:07 pm |
Wow, totally impressed and grateful for the quick response.
Thanks very much - that helped a great deal! (And yes, it was a typo on my part).
And one final question - how do I break out of the trigger when I want to stop the loop? |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Wed Jun 07, 2006 12:14 pm |
You can use the #T- command to disable the trigger. Like this:
#T- lineTrigger
When you want to enable it again use:
#T+ lineTrigger
And to reset it, use:
#STATE "lineTrigger" 0 |
|
_________________ Kjata |
|
|
|
birkoff Beginner
Joined: 01 Jun 2006 Posts: 16
|
Posted: Wed Jun 07, 2006 12:24 pm |
ok, i think this may work:
the main trigger:
Code: |
#ONINPUT "fishing" {^StartFishing} {} "" {notrig}
#COND {*} {#send {reel line}} {reparse}
#COND {^You pull your line} {#send {cast line}}
#COND {^You cast your line} {#send {watch line}}
#COND {^You feel a tug on your line} {#state {fishing} (1)} |
and the snap detector:
Code: |
#TRIGGER "snapdetect" {^Your line snaps} {#state {fishing} (0)} |
try it out.. i hope its okay.
to start fishing, type "startfishing"
P.S.
this may prove helpful: http://www.zuggsoft.com/library/trigadv.htm |
|
|
|
Lyrael Beginner
Joined: 17 Mar 2004 Posts: 17 Location: USA
|
Posted: Fri Jun 09, 2006 12:15 am |
Thanks again for the help. It works!
|
|
|
|
|
|