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
Kaotac
Beginner


Joined: 26 Mar 2007
Posts: 16
Location: Australia

PostPosted: Fri Jul 17, 2009 11:10 am   

Using a string of exits to auto walk?
 
I'm wanting to create a variable that will capture a long string of exits:
"Path: ne, ne, nw, ne, nw, w, nw, nw, w, w, sw, sw, s, s, w, nw, sw, s, se,
w, w, nw, nw, ne, n, ne, n, ne, n, nw, n, n, n"
and then when I use an alias like "caravanstart" it will send the command "lead caravan (next direction in string)"

I've seen a script that does this, but I couldn't make any sense of it at all, and it was for Zmud anyway.
Please help me out! :)
Reply with quote
Tech
GURU


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

PostPosted: Fri Jul 17, 2009 2:48 pm   
 
If it was for zMUD there's a high likelihood it would work in CMUD unchanged (or with few modifications).

You basically need to put the path into a string list and look on the string list.

Off the top of my head the code would look something like

Code:
#VAR Path %replace(@Path, ", ", "|")
#ALIAS caravanstart {lead caravan %pop(@Path)}
_________________
Asati di tempari!
Reply with quote
Kaotac
Beginner


Joined: 26 Mar 2007
Posts: 16
Location: Australia

PostPosted: Wed Jul 22, 2009 12:35 pm   
 
How do I exclude certain things from this? With:
Code:
H:198 M:259 E:894 W:1241 <eb>
Distance to Before the Kinsarmar Gate: 12.
Path: n, n, se, sw, sw, se, e, e, s, s, s, se
H:198 M:259 E:894 W:1241 <e->


I have this at the moment for "Path: * ."
Code:
t+ path_cap;#temp {~.~]$} {#t- path_cap;#ec  %ansi( 7)Path for caravan is:  %replace(  @path, "|", ", ").} "" {prompt}

But it captures and places in the variable the "path:" part, which I would like to exclude, and then it continues to capture and put in my prompt and anything else that comes after it. Anyone able to help with this, so that it only captures the directions?
Reply with quote
Tech
GURU


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

PostPosted: Wed Jul 22, 2009 5:19 pm   
 
The reason for this is that there is no '.' in your path statement. This trigger pattern should work better.

Code:
^Path:(*)$
_________________
Asati di tempari!
Reply with quote
Kaotac
Beginner


Joined: 26 Mar 2007
Posts: 16
Location: Australia

PostPosted: Thu Jul 23, 2009 9:56 am   
 
Yeah.. Didn't work. Maybe if I gave you the whole script? Someone who knows what they're doing might be able to understand it and change it to work the text I pasted from the game?
Code:

#CLASS {Caravans}
#ALIAS gocar {lead caravan %pop(path)}
#ALIAS findpath {#t+ caravan_start;#if (%1) {map path %1;#var @caravan_target %1} {map path @caravan_target}}
#VAR path {}
#TRIGGER {^You lead a caravan %w. ~(caravan~)$} {#if (%item( @path, 1)) {#ec %ansi( 7)Path remaining: %replace( @path, "|", ", ").;lead caravan %pop( path)} {#ec %ansi( 7)Path completed.}}
#TRIGGER "caravan_start" {^~[Path calculated in: %d microseconds.~]$} {#var path %null}
#TRIGGER  {^~[Path~:*} {#t+ path_cap;#temp {~.~]$} {#t- path_cap;#ec %ansi( 7)Path for caravan is: %replace( @path, "|", ", ").} "" {prompt}}
#TRIGGER "path_cap" {^(*)$} {#var temp {%1};#if (%left( @temp, 6)!=%left( @init_path, 6)) {#var path %concat( @path, ",", @temp);#var path %replace( @path, ",", "|");#var path %replace( @path, " ", "");#var path %replace( @path, "||", "|");#var path %replace( @path, "[Path:", "");#var path %replace( @path, ".]", "");#if %item( @path, 1)="") {#noop %pop( path)}} {#ec dance}} "" {disable}
#CLASS 0
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Jul 24, 2009 5:02 pm   
 
Your triggers seem to suggest that there are brackets around the "Path: ..." line, but you did not include any brackets like that in the mud output you quoted. Are there actually brackets in the mud output?

It looks to me like you've made this much too hard. The mud output you showed us has the entire path on a single line. If that's the case, you don't need a prompt trigger to initiate a second trigger to capture the path. You just need a single trigger, like Tech showed you. You're doing a bunch of replacements that don't seem necessary, like a period at the end, and doubled pipes. You have a trigger for "Path calculated in: %d microseconds", but you didn't present anything like that in your example output. If it is really that complicated, then you'll have to show us some examples of text from the mud demonstrating the complications. I started to write a much simpler script that would work with the mud text you presented, but I don't think it's worth working out until you clarify exactly what the mud output looks like.
Reply with quote
Kaotac
Beginner


Joined: 26 Mar 2007
Posts: 16
Location: Australia

PostPosted: Sun Jul 26, 2009 12:03 pm   
 
This was a script made by someone else to use text based mapper and the game recently added a new feature that works in a similar way.. so I was hoping to change the script so I could use the game based feature instead of needing to use the old mapper where you need to connect to the game through a proxy.

The text I used what is given by the game, but I haven't been able to change the settings to work with it :(
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Jul 27, 2009 7:47 pm   
 
If the mud output is changed that much, you should scrap your old stuff and start over. Your new triggers will be much much simpler than the old. Here's my quick attempt at it, in XML format:
Code:

<class name="Caravans" id="1">
  <alias name="gocar" id="2">
    <value>lead caravan  %pop(path)</value>
  </alias>
  <alias name="findpath" id="3">
    <value>#t+ caravan_start;#if (%1) {map path %1;#var  @caravan_target %1} {map path  @caravan_target}</value>
  </alias>
  <var name="path" type="String" id="4"/>
  <trigger priority="50" id="5">
    <pattern>^You lead a caravan %w. ~(caravan~)$</pattern>
    <value>#if (%item(  @path, 1)) {#ec  %ansi( 7)Path remaining:  %expandlist(  @path, ", ").;lead caravan  %pop(path)} {#ec  %ansi( 7)Path completed.}</value>
  </trigger>
  <trigger name="caravan_start" priority="70" id="7">
    <pattern>^Path: (*)$</pattern>
    <value>#VAR path %replace(%1, ", ", "|")
#t- caravan_start</value>
  </trigger>
</class>
Reply with quote
Kaotac
Beginner


Joined: 26 Mar 2007
Posts: 16
Location: Australia

PostPosted: Tue Jul 28, 2009 9:05 am   
 
Awesome! Works great. Though it only picks up a single line of exits.
How do I get it to pick up a second (or third) line?
Code:

Path: w, n, se, sw, sw, se, e, e, s, s, s, se, s, sw, s, nw, nw, n, nw, n, w,
n, w, n, nw, n, se, n, e, se, s, se, n
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jul 28, 2009 2:49 pm   
 
Ah, your example did not have exits extending onto a second line. Is it possible to change a setting on the mud to not wrap lines? You can let Cmud do your line wrapping for you. If so, that would probably solve the problem. If not, we'll have to do something a bit more complicated.
Reply with quote
Kaotac
Beginner


Joined: 26 Mar 2007
Posts: 16
Location: Australia

PostPosted: Wed Jul 29, 2009 8:32 am   
 
I'm afraid not. All IRE games wrap for you.. At least I can't find a way to change it.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jul 29, 2009 8:19 pm   
 
All right, here's a new version which, I think, will handle multiple lines. If the line ends in ", " it turns on another trigger which continues capturing lines until it gets a line that does not end in ", ", at which point it replaces the commas to make it a stringlist.
Code:

<class name="Caravans" id="144">
  <alias name="gocar" id="145">
    <value>lead caravan %pop(path)</value>
  </alias>
  <alias name="findpath" id="146">
    <value>#t+ caravan_start;#if (%1) {map path %1;#var  @caravan_target %1} {map path  @caravan_target}</value>
  </alias>
  <var name="path" type="String" id="147"/>
  <trigger priority="50" id="148">
    <pattern>^You lead a caravan %w. ~(caravan~)$</pattern>
    <value>#if (%item( @path, 1)) {#ec %ansi( 7)Path remaining:  %expandlist( @path, ", ").;lead caravan %pop(path)} {#ec %ansi( 7)Path completed.}</value>
  </trigger>
  <trigger name="caravan_start" priority="70" enabled="false" id="149">
    <pattern>^Path: (*)$</pattern>
    <value>#VAR path %1
#t- caravan_start
#if (%ends(%1, ", ") {#t+ caravan_continue} {#var path %replace(@path, ", ", "|")}</value>
  </trigger>
  <trigger name="caravan_continue" priority="1500" enabled="false" id="150">
    <pattern>(*)</pattern>
    <value>#var path %concat(@path, %1)
#if (!%ends(%1, ", ")) {
  #t- caravan_continue
  #var path %replace(@path, ", ", "|")
}</value>
  </trigger>
  <var name="caravan_target" id="151"/>
</class>
Reply with quote
Kaotac
Beginner


Joined: 26 Mar 2007
Posts: 16
Location: Australia

PostPosted: Thu Jul 30, 2009 2:33 am   
 
Hmm.. I used that and changed some tiny things (and added a button, a trigger and alias to stop the walker) so now I looks like
Code:
<class name="Caravans" id="676">
  <trigger priority="4680" id="475">
    <pattern>The hairs on your neck tingle from an unknown presence.</pattern>
    <value>caravanoff</value>
  </trigger>
  <button autosize="false" width="126" height="20" autopos="false" left="13" top="535" color="navy" textcolor="white" border="navy" priority="54" id="521">
    <caption>Lead Caravan</caption>
    <value>gocar</value>
    <tooltip>Lead Caravan</tooltip>
  </button>
  <alias name="gocar" id="677">
    <value>lead caravan %pop(path)</value>
  </alias>
  <alias name="cargoto" id="678">
    <value>#t+ caravan_start;#if (%1) {path find %1;#var  @caravan_target %1} {path find  @caravan_target}</value>
  </alias>
  <trigger priority="50" id="679">
    <pattern>^You lead a caravan %w.</pattern>
    <value>#if (%item( @path, 1)) {#ec %ansi( 7)Path remaining:  %expandlist( @path, ", ").;lead caravan %pop(path)} {#ec %ansi( 7)Path completed.}</value>
  </trigger>
  <trigger name="caravan_start" priority="70" id="680">
    <pattern>^Path: (*)$</pattern>
    <value>#VAR path %1
#t- caravan_start
#if (%ends(%1, ", ") {#t+ caravan_continue} {#var path %replace(@path, ", ", "|")}</value>
  </trigger>
  <trigger name="caravan_continue" priority="1500" enabled="false" id="681">
    <pattern>(*)</pattern>
    <value>#var path %concat(@path, %1)
#if (!%ends(%1, ", ")) {
  #t- caravan_continue
  #var path %replace(@path, ", ", "|")
}</value>
  </trigger>
  <alias name="caravanoff" id="682">
    <value>#var path {}</value>
  </alias>
  <var name="Path" id="683"/>
</class>

But for some reason when I try to use it I get:
Code:
H:202 M:259 E:910 W:1265 <eb> path find velincomm
Distance to A small, cluttered building: 51.
Path: e, se, d, s, s, s, s, s, s, s, s, s, se, s, sw, s, sw, s, sw, w, w, sw,
ERROR: Trigger "^Path: (*)$" fired but did not compile
w, sw, nw, w, sw, w, sw, sw, nw, sw, nw, w, nw, nw, nw, e, ne, ne, nw, n, n, n,
e, e, e, e, se, s, sw
H:202 M:259 E:910 W:1265 <e->

Kind of confusing why it isn't working.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Jul 30, 2009 2:47 am   
 
Hm. That trigger, exactly as you have it, seems to compile for me. Look around to see if you have any other old triggers with the pattern "^Path: (*)$"
Reply with quote
Kaotac
Beginner


Joined: 26 Mar 2007
Posts: 16
Location: Australia

PostPosted: Fri Jul 31, 2009 7:10 am   
 
Nope, only the one trigger with that pattern. Hmm.
Reply with quote
LuckyStephy
Newbie


Joined: 15 Jul 2011
Posts: 2

PostPosted: Fri Jul 15, 2011 1:55 pm   
 
So I've been literally breathing and eating this script for days. I found why the error message keeps popping up.

The pattern "^Path: (*)$"

needs to be:

"^Path: (.*)$

I'm by no means a expert. I'm actually FAR from it. But this seems to take away the message.

However, in fixing that. I hit, 'cargo' but it gives me an empty variable, it doesn't move in a direction. Please help?

This is what I'm currently working with. It's the same script just with the added '.' above.

Code:
<class name="Caravans" id="94">
  <alias name="gocar" id="95">
    <value>lead caravan %pop(path)</value>
  </alias>
  <alias name="findpath" id="96">
    <value>#t+ caravan_start;#if (%1) {map path %1;#var  @caravan_target %1} {map path  @caravan_target}</value>
  </alias>
  <var name="path" type="String" id="97"/>
  <trigger priority="50" id="98">
    <pattern>^You lead a caravan %w. ~(caravan~)$</pattern>
    <value>#if (%item( @path, 1)) {#ec %ansi( 7)Path remaining:  %expandlist( @path, ", ").;lead caravan %pop(path)} {#ec %ansi( 7)Path completed.}</value>
  </trigger>
  <trigger name="caravan_start" priority="70" enabled="false" id="99">
    <pattern>^Path: (.*)$</pattern>
    <value>#VAR path %1
#t- caravan_start
#if (%ends(%1, ", ") {#t+ caravan_continue} {#var path %replace(@path, ", ", "|")}</value>
  </trigger>
  <trigger name="caravan_continue" priority="1500" enabled="false" id="100">
    <pattern>(*)</pattern>
    <value>#var path %concat(@path, %1)
#if (!%ends(%1, ", ")) {
  #t- caravan_continue
  #var path %replace(@path, ", ", "|")
}</value>
  </trigger>
  <var name="caravan_target" id="101"/>
</class>


Does the '.' keep the caravan from moving?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Jul 15, 2011 5:30 pm   
 
I notice that the Path: (*) trigger has an #IF command that uses the %ends() function for the condition. This #IF condition does not have a closing ), which is probably why the trigger doesn' compile.
_________________
EDIT: I didn't like my old signature
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