[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Auto Walker

Auto Walker

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1 2  

Posted by Jon   (7 posts)  [Biography] bio
Date Mon 02 Apr 2001 10:21 PM (UTC)
Message
Hi,

I was wondering how I can make a wilderness walker script for the mud I play, medievia.

I found one for mudmaster but I don't know how to convert it. What I want it to do is allow me to type, start "direction" and it would start walking the direction and search the room exits for the one that says "Trail through the wilderness" and go that direction.

Also, if possible can you post any scripting that has to be don in JScript?

I'm no programmer, so I use Thaeldan's scripts which are all in JScript.

Thanks,

Jon

Here is the url to the mudmaster script.. maybe you can get a clearer picture of what I want to do by looking at it?


http://members.nbci.com/tmbg/mm/autotrade.zip
[Go to top] top

Posted by Nick Gammon   Australia  (23,043 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 03 Apr 2001 02:17 AM (UTC)
Message
I'll try to do sample scripts in the language that a particular poster asks for. To do all three languages (VBscript, JScript and Perlscript) for every question triples my workload. :)

Rather than looking at the MudMaster script, perhaps just post a log of the sorts of things you see, and what you expect the script do.

I would guess that we need a trigger to match on "Trail through the wilderness" and send an appropriate command to go that way, but the exact format of the MUD output will be critical to getting the script to work right.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jon   (7 posts)  [Biography] bio
Date Reply #2 on Tue 03 Apr 2001 06:36 PM (UTC)
Message
"A Sturdy, Wooden Bridge"
"A Well-Traveled Road"
"A Well-Traveled Road"
"A gravel path"

Here are the exits that its possible the client can see, I want the script to see one of these rooms and walk in that direction,
the problem is ;

Obvious exits:
North - A Gravel Path
East - A Clear River
South - A Gravel Path
West - A Clear River

their are 2 exits that have the same name while on a path, I want to be able to type something like "travels" for south "traveln" for north ect..
and MUSHclient would if I typed travels, omit north from the possible exits, and only match on exits that go south, east or west, then send the direction to the mud.


Thanks for any help you can provide :)

Jon
[Go to top] top

Posted by Nick Gammon   Australia  (23,043 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 04 Apr 2001 11:53 PM (UTC)

Amended on Sat 07 Apr 2001 08:14 AM (UTC) by Nick Gammon

Message
This has certainly been an interesting challenge. :)

I haven't tested my script on Medievia as I don't have a character there, but based on the MudMaster script this should work.

Just copy the script from between the lines and paste into your script file. This is written in Jscript.

Note: The changes mentioned in subsequent posts have been incorporated into the code below.



// Auto-walker for Medievia

// ----------------------------------------------------------
// This function installs the auto-walker
// ----------------------------------------------------------

function InstallAutoWalker ()
  {

  // set up triggers

  world.AddTrigger ("walk_trigger",  
        "^(North|South|East|West)\\s+-\\s+" +
        "(A Sturdy, Wooden Bridge|A Well-Traveled Road|" +
        "On a Winding Forest Trail|A gravel path)$", 
        "", 
        8 + 32 + 1024, // keep evaluating / regexp / replace
        -1, 0, "", 
        "On_Trigger_Walker_Direction");  // function to call

  world.AddTrigger ("west_trigger",  
        "^West\\s+-\\s+.+$", 
        "", 
        8 + 32 + 1024, // keep evaluating / regexp / replace
        -1, 0, "", 
        "On_Trigger_West");  // function to call

  world.AddTrigger ("destination_trigger",  
        "* says, '* is * from this intersection'.", 
        "", 
        1024, // replace existing
        -1, 0, "", 
        "On_Trigger_Walker_Destination");  // function to call

  // set up aliases

  world.AddAlias ("start_walker_alias", "startwalk", "", 1 + 1024, "On_Start_Walk");
  world.AddAlias ("stop_walker_alias", "stopwalk", "", 1 + 1024, "On_Stop_Walk");
  world.AddAlias ("do_walker_alias", "walk *", "", 1 + 1024, "On_Do_Walk");

  // set up variables
  world.SetVariable ("direction", "");   // no direction yet
  world.SetVariable ("destination", "");   // no destination yet
  world.SetVariable ("direction_count", 0);  // no count yet
  world.SetVariable ("disable_direction", "");   // no disabled direction yet

  world.note ("Auto walker installed.");

  }	// end of InstallAutoWalker

// ----------------------------------------------------------
// This function removes the auto-walker
// ----------------------------------------------------------

function RemoveAutoWalker ()
  {
  world.DeleteTrigger ("walk_trigger");
  world.DeleteTrigger ("west_trigger");
  world.DeleteTrigger ("destination_trigger");
  world.DeleteTimer ("walk_timer");
  world.DeleteAlias ("start_walker_alias");
  world.DeleteAlias ("stop_walker_alias");
  world.DeleteAlias ("do_walker_alias");
  world.note ("Auto walker removed.");
  }  // end of RemoveAutoWalker 

// ----------------------------------------------------------
// This function starts the auto-walker
// ----------------------------------------------------------

function On_Start_Walk (strName, strOutput, wildcardsVB)
  {
  world.note ("Walker started.");
  world.EnableTrigger ("walk_trigger", true);
  world.EnableTrigger ("west_trigger", true);
  world.EnableTrigger ("destination_trigger", true);
  world.Send (world.GetVariable ("direction"));
  }  // end of On_Start_Walk

// ----------------------------------------------------------
// This function stops the auto-walker
// ----------------------------------------------------------

function On_Stop_Walk (strName, strOutput, wildcardsVB)
  {
  world.note ("Walker stopped.");
  world.EnableTrigger ("walk_trigger", false);
  world.EnableTrigger ("west_trigger", false);
  world.EnableTrigger ("destination_trigger", false);
  world.DeleteTimer ("walk_timer");
  }  // end of On_Stop_Walk 

// ----------------------------------------------------------
// This function walks to the specified destination
// ----------------------------------------------------------

function On_Do_Walk (strName, strOutput, wildcardsVB)
  {
  wildcards = VBArray(wildcardsVB).toArray();	

  sDestination = wildcards [0];

  // remember the destination
  world.SetVariable ("destination", sDestination);
  world.SetVariable ("direction", "");   // no direction yet
  world.SetVariable ("direction_count", 0);  // no count yet
 
  world.Note ("Destination is now " + sDestination);
  On_Start_Walk (0, 0, 0);	// enable trigger
  world.Send ("say where " + world.GetVariable ("destination"));
  }  // end of On_Do_Walk 

// ----------------------------------------------------------
// This function is called when "walk_trigger" fires
// eg.
// North - A Gravel Path 
// East - A Clear River 
// South - A Gravel Path 
// West - A Clear River 
// ----------------------------------------------------------

function On_Trigger_Walker_Direction (strTriggerName, strTriggerLine, wildcardsVB)
{
wildcards = VBArray(wildcardsVB).toArray();	

sDirection = wildcards [0];

// don't count disabled directions
if (sDirection == world.GetVariable ("disable_direction"))
  return;

// count directions that we could go in
world.SetVariable ("direction_count", 
                   parseInt (world.GetVariable ("direction_count")) + 1);
// remember the direction
world.SetVariable ("direction", sDirection);

}	// end of On_Trigger_Walker_Direction

// ----------------------------------------------------------
// This function is called when we go west
// ----------------------------------------------------------

function On_Trigger_West (strTriggerName, strTriggerLine, wildcardsVB)
{

  // set up 1-second timer 
  
  world.AddTimer ("walk_timer", 0, 0, 1, "", 
                  1 + 4 + 1024, // enabled / one shot / replace existing
                  "On_Timer_Walker");   // function to call

}	// end of On_Trigger_West 

// ----------------------------------------------------------
// This function is called when "destination_trigger" fires
// eg. Lianydd says, 'Agreilith is North from this intersection'.
// ----------------------------------------------------------

function On_Trigger_Walker_Destination (strTriggerName, strTriggerLine, wildcardsVB)
{
wildcards = VBArray(wildcardsVB).toArray();	

sDirection = wildcards [2];

switch (sDirection.toLowerCase())
  {
  case "north": sDisabledDirection = "South"; break;
  case "south": sDisabledDirection = "North"; break;
  case "east": sDisabledDirection = "West"; break;
  case "west": sDisabledDirection = "East"; break;
  default: return;
  }  // end of switch

// disable reciprocal direction
world.SetVariable ("disable_direction", sDisabledDirection);
world.SetVariable ("direction", "");   // no direction yet
world.SetVariable ("direction_count", 0);  // no count yet

// go in specified direction
world.Send (sDirection);

}	// end of On_Trigger_Walker_Destination

// ------------------------------------------
// This is called when the walker time fires
// -------------------------------------------
function On_Timer_Walker (strTimerName)
{

if (parseInt (world.GetVariable ("direction_count")) == 1)
  world.Send (world.GetVariable ("direction"));
else
  world.Send ("say where " + world.GetVariable ("destination"));

world.SetVariable ("direction_count", 0);  // no count yet

}	// end of On_Timer_Walker




To install the auto-walker

Type: /InstallAutoWalker ()

This will execute the function InstallAutoWalker which sets up the various triggers needed for the auto-walker.

To remove the auto-walker

Type: /RemoveAutoWalker ()

This removes the triggers set up by the InstallAutoWalker.

To start walking automatically

Type: walk castle

where "castle" is the name of the place you are heading for.

It will start by saying "where castle" so it can find the initial direction to walk.

To temporarily stop the auto-walker

Type: stopwalk

This disables the triggers so you will stop walking automatically.

To restart the auto-walker

Type: startwalk

This recommences walking in the last direction it was heading.




Let me know if you have problems with it.

How it works

InstallAutoWalker sets up three triggers:

1. To match on the desired paths we can take:

"A Sturdy, Wooden Bridge"
"A Well-Traveled Road"
"A Well-Traveled Road"
"A gravel path"

A regular expression is used to match on any one of the above, in combination with north, south, east or west.

2. To match on "West - (anywhere)" - when we get "West" then we get ready to walk in the desired direction.

3. To match on "* says, '* is * from this intersection'.".

The "*" is a wildcard, and is used to match on the response to saying "where location".

We also set up three aliases, startwalk, stopwalk, and walk, to handle the interface between the player and the script.

Once we start walking the triggers match on the appropriate paths above, and count how many match. If only one matches, we go that way. Otherwise we say "where location" and wait for the other trigger to match, which tells us which way to go.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jon   (7 posts)  [Biography] bio
Date Reply #4 on Thu 05 Apr 2001 02:24 AM (UTC)
Message
Thanks alot for making this script for me! :)

But it kills me to say (because you put so much time into it) that it doesn't work :( I installed the script and went to an intersection where I typed walk med the person responded and MUSHclient recognized the direction and went one room that way and stopped, it doesn't seem to be recognizing the exits, another thing is in your explanation of the how the script works you said that if it sees more than one thing that matches it says "where location" to find out which way to go.. That wouldn't work, the characters that reply to "where location" are only found in intersections.

Here is what happend, I copied and pasted out of mushclient because the log didn't show the script;

A Gravel Path

A retired Medievia Guardsman stands here giving directions.
Obvious exits:
North - A Gravel Path
East - A Dense, Forested Wilderness
South - A Gravel Path
West - A Gravel Path

<481hp 247m 576mv 100br>


<481hp 247m 576mv 100br>
Destination is now med
Walker started.

say where med


<481hp 247m 579mv 100br> You say, 'Where med'.

A Retired Medievia Guardsman says, 'City of Medievia is South from this intersection'.
South
It's far off in the distance.

<481hp 247m 579mv 100br> A Gravel Path
Obvious exits:
North - A Gravel Path
East - A Dense, Forested Wilderness
South - A Gravel Path
West - A Dense, Forested Wilderness

-Jon
[Go to top] top

Posted by Nick Gammon   Australia  (23,043 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Thu 05 Apr 2001 02:40 AM (UTC)
Message
Hmmm - I was just browsing through the script when I realised that the forum had changed a couple of backslashes, which is probably why it didn't work.

In particular the lines:


"^(North|South|East|West)\\s+-\\s+" +


and


"^West\\s+-\\s+.+$",


should have two backslashes in a row. This is because JScript treats a single backslash as a special character, so you need to key in two backslashes into a literal, which then become a single backslash in the regular expression, which is what I really wanted.

So, either fix up those two lines (as shown above) or just re-copy and paste the entire lot, as I have now fixed it up in the earlier posting.

Because of that problem, the trigger probably didn't match, which is why it just sat there.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (23,043 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Thu 05 Apr 2001 02:43 AM (UTC)
Message
Quote:

In your explanation of the how the script works you said that if it sees more than one thing that matches it says "where location" to find out which way to go.. That wouldn't work, the characters that reply to "where location" are only found in intersections.


Well, that is what the MudMaster script did, but in any case, if the "where location" doesn't work, just force it by (say) typing "north", which will then take you to a new room, and then the trigger will match and the script will keep running.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (23,043 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Thu 05 Apr 2001 03:01 AM (UTC)

Amended on Thu 05 Apr 2001 03:02 AM (UTC) by Nick Gammon

Message
Two more things ...

1. I just amended the script (above) again, to add the "keep evaluating" flag. Without that, I think you would have had a problem if the correct direction was West, depending on which West trigger matched first. With "keep evaluating" set, it will do both triggers.

2. The original MudMaster script had the matching lines "gagged" so that you don't see them. I didn't do that because I wanted to see what the script was doing, for debugging purposes, as well as general interest. If you wanted to gag the matching lines, you could add another trigger like this:



  world.AddTrigger ("gag_trigger",  
        "^(((North|South|East|West)\\s+-\\s+)|(Obvious exits:)).+$", 
        "", 
        4 + 8 + 32 + 1024, // gag / keep evaluating / regexp / replace
        -1, 0, "", "");




You would also need to enable and disable "gag_trigger" where the other ones are enabled and disabled.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (23,043 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Thu 05 Apr 2001 03:42 AM (UTC)
Message

By the way, the documentation for the various scripting functions is at:

http://www.mushclient.com/functions.htm


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jon   (7 posts)  [Biography] bio
Date Reply #9 on Thu 05 Apr 2001 06:09 AM (UTC)
Message
That \\ was the answer to the problem of it not going more than a room, now it walks the direction from the where command, then goes one room further using the trigger then It says where "location", I tried manualy moving one room ahead and when I got into the room it would say where "location" thats it....

Is there any way to make it disable the trigger that makes it go the opposite direction from what the where says, after the where tells it a direction?

eg.

Says the city of medievia is south.
trigger disables exits to the north
and follows route in any direction but north


Thanks, :)

- Jon
[Go to top] top

Posted by Nick Gammon   Australia  (23,043 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Thu 05 Apr 2001 06:38 AM (UTC)
Message
OK, just remove this one line from the function On_Timer_Walker.

Then it will never go in the direction that has been established as the "wrong" way.



world.SetVariable ("disable_direction", "");   // no disabled direction now

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jon   (7 posts)  [Biography] bio
Date Reply #11 on Thu 05 Apr 2001 09:41 PM (UTC)
Message
Ok , Is there anyway you can have MUSHclient do the "say where" thing if there are more than 3 exits that match the exits trigger?

Removing the line that you said to made it work great, until it got to an intersection where the characters that respond to the where command, are, because there are always 3 or more exits that match when you run into one of those rooms, fortunatly the "where location" thing will work in those rooms :)

Hehe I really appreciate all the time you've put into this :)

Thanks,

-Jon
[Go to top] top

Posted by Nick Gammon   Australia  (23,043 posts)  [Biography] bio   Forum Administrator
Date Reply #12 on Thu 05 Apr 2001 11:41 PM (UTC)
Message
It should do that now. In this function here:



function On_Timer_Walker (strTimerName)
{

if (parseInt (world.GetVariable ("direction_count")) == 1)
  world.Send (world.GetVariable ("direction"));
else
  world.Send ("say where " + world.GetVariable ("destination"));

world.SetVariable ("direction_count", 0);  // no count yet

}	// end of On_Timer_Walker



This goes in the specified direction if the number of matching exits is 1, otherwise it says "where location".

Is this not working? Can you post a log of the relevant part of the walk? Also, look at Configuration -> Scripting -> Variables and see what values are in:

* destination
* direction
* direction_count
* disable_direction




- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jon   (7 posts)  [Biography] bio
Date Reply #13 on Fri 06 Apr 2001 12:18 AM (UTC)

Amended on Fri 06 Apr 2001 01:15 AM (UTC) by Nick Gammon

Message
here is a log of what happens;


<475hp 201m 556mv 100br>
Destination is now med
Walker started.

say where med


<475hp 201m 556mv 100br> You say, 'Where med'.

Alfred says, 'City of Medievia is South from this intersection'.
South
It's off in the distance.

<475hp 201m 556mv 100br> A Gravel Path
Obvious exits:
North - A Gravel Path
East - A Dense, Forested Wilderness
South - A Gravel Path
West - Beautiful Gardens

<475hp 201m 552mv 100br>
South
A Gravel Path
Obvious exits:
North - A Gravel Path
East - A Dense, Forested Wilderness
South - A Gravel Path
West - A Dense, Forested Wilderness

<476hp 204m 551mv 100br>
South
A Gravel Path
Obvious exits:
North - A Gravel Path
East - A Dense, Forested Wilderness
South - A Gravel Path
West - A Dense, Forested Wilderness

<476hp 204m 547mv 80br>
South
A Gravel Path
Obvious exits:
North - A Gravel Path
East - A Dense, Forested Wilderness
South - A Sturdy Wooden Bridge
West - A Dense, Forested Wilderness

<477hp 207m 546mv 70br>
At 6 o'clock, tens of miles away in the distance you notice a large, silver dragon appear responding to someone's plea.

<477hp 207m 546mv 100br>
South

<477hp 207m 546mv 100br> A Sturdy Wooden Bridge
Obvious exits:
North - A Gravel Path
East - A Clear River
South - A Gravel Path
West - A Clear River

<477hp 207m 542mv 100br>
South
A Gravel Path
Obvious exits:
North - A Sturdy Wooden Bridge
East - A Dense, Forested Wilderness
South - A Gravel Path
West - A Dense, Forested Wilderness

<478hp 210m 541mv 100br>
South

A Gravel Path

A man-sized statue of a golden dragon stands in the center of the intersection.
Obvious exits:
North - A Gravel Path
East - A Dense, Forested Wilderness
South - A Gravel Path
West - A Gravel Path



The room with 3 exits it doesn't do anything in, how can you make it say where "location" in one of those rooms?

at the time these where the variables,

destination = med
direction = West
direction_counter = 1
disable_direction = North

Also, I typed say where med myself, to see if it would go on, but it went one room west and stopped



say where med
You say, 'Where med'.

The statue says, 'City of Medievia is West from this intersection'.
West
It's not far from here.

<485hp 247m 559mv 100br> A Gravel Path
Obvious exits:
North - A Dense, Forested Wilderness
East - A Gravel Path
South - A Dense, Forested Wilderness
West - A Gravel Path



At the time, these where in the variables

destination = med
direction = West
direction_count = 1
disable_direction = east

-Jon
[Go to top] top

Posted by Nick Gammon   Australia  (23,043 posts)  [Biography] bio   Forum Administrator
Date Reply #14 on Fri 06 Apr 2001 12:37 AM (UTC)
Message
Have you repasted the entire script from the earlier message? By the looks of it, it isn't processing the West trigger properly. There are two triggers for West, namely:

West - A Gravel Path
West - (anything)

If the "keep evaluating" flag isn't set, then it will only process the first one (which it looks like it has, because it has the "direction" variable as "West") but not the second one, which sets off the timer. The timer then decides whether to walk or say "where".

Since it hasn't done either of those things, I think the second trigger hasn't fired. In my original post, there was a bug, and that would have happened.

To make sure we are using the same script, just copy and repaste the lot - I have since amended the script above to include the corrections we have talked about.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


49,242 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]