About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
Yamabushi
Apprentice


Joined: 29 Jul 2003
Posts: 101
Location: USA

PostPosted: Sat May 05, 2007 1:42 am   

script help
 
I had a script in zmud that kept track of the directions that I followed someone so I could reverse them and go back where I started following from.

I can't get the same script to work in Cmud.

Basically, I want to create a string of directions with a trigger on the text: "You follow XXX direction."

When you go a direction, it would evaluate the reverse of the direction, so N becomes S.

Then a separate alias would allow you to either go back all the rooms, or a specified number of rooms in your list.

I can post the old script if necessary, however if someone wants to script it clean I'd love something more efficient than what I had before (about anything would be).

Thanks,
Y
_________________
Yama
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat May 05, 2007 1:54 am   
 
It is always best to post your previous script even if it doesn't work in Cmud this way we know exactly what you want and we can cmudify and clean it up for you :p


#TRIGGER makepath {^You follow * (%t).} {#ADDITEM dirlist %1}
#ALIAS walkback {#EXECUTE %pathreverse(@dirlist)}
#ALIAS walkclear {dirlist=""}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Yamabushi
Apprentice


Joined: 29 Jul 2003
Posts: 101
Location: USA

PostPosted: Sat May 05, 2007 2:01 am   
 
Ok, here is what the old script was:

#ALIAS backtrackclear {@flipbackpath = "";@pathnumber = 0}
#ALIAS backtrack {#IF @pathnumber>0 {#IF @flipbackpath="" {#LOO @pathnumber,1 {#VAR flipbackpath %addItem( %reversedir( %item( @backpath, %{i})), @flipbackpath)}};@backsteps = %1;#IF %1="" {@backsteps = @pathnumber};#LOO 1,@backsteps {%exec( %item( @flipbackpath, 1));#VAR flipbackpath %delItem( %item( @flipbackpath, 1), @flipbackpath);@pathnumber = %eval( @pathnumber-1)}};#IF @pathnumber<=0 {#SAY "";#SAY End of path! Resetting Variables! Target is still @target!;%exec( );backtrackclear}}
#TRIGGER {You follow @target &%whuntdir.} {#VAR backpath %addItem( @huntdir, @backpath);@pathnumber = %eval( @pathnumber + 1)}
_________________
Yama
Reply with quote
Tech
GURU


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

PostPosted: Sat May 05, 2007 1:55 pm   
 
Here's a CMUD version of the script.. I think. (I didn't really have any test code). I commented the %exec, it didn't seem needed. And I used #ADD in one case instead of the %eval but that's just a matter of preference.

FYI to assign a value to a variable you type "backsteps = @pathnumber" or "backstep = %1". In other words don't use @backstep when assigning to the backstep variable.

Code:
#ALIAS backtrackclear {flipbackpath = ""
pathnumber = 0
}

#ALIAS backtrack {#IF (@pathnumber>0) {
  #IF (@flipbackpath=="") {
    #LOOP @pathnumber,1 {
       #VAR flipbackpath %addItem( %reversedir( %item( @backpath, %i)), @flipbackpath)
    }
  }
 
  backsteps = %1
 
  #IF (%1="") {
    backsteps = @pathnumber
  }
 
  #LOOP 1,@backsteps {
    // %exec( %item( @flipbackpath, 1))
    #EXEC %item( @flipbackpath, 1)
    #VAR flipbackpath %delItem( %item( @flipbackpath, 1), @flipbackpath);
    pathnumber = %eval( @pathnumber-1)
  }
}

#IF (@pathnumber<=0) {
  #SAY ""
  #SAY End of path! Resetting Variables! Target is still @target!
  // %exec( )
  backtrackclear
}

}

#TRIGGER {You follow @target &%whuntdir.} {#VAR backpath %addItem( @huntdir, @backpath)

//pathnumber = %eval( @pathnumber + 1)

#ADD pathnumber 1
}

_________________
Asati di tempari!
Reply with quote
Yamabushi
Apprentice


Joined: 29 Jul 2003
Posts: 101
Location: USA

PostPosted: Sat May 05, 2007 3:47 pm   
 
Thanks for all the help guys
_________________
Yama
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