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
haesus
Newbie


Joined: 07 Aug 2008
Posts: 5

PostPosted: Thu Aug 07, 2008 6:00 pm   

Help needed on path walking script and colecting herbs
 
Hi

I've got a small problem with a simple, as it seems, script.
Basically i d like to set up alias called say 'collecting'. When i type it id like to launch my 'so called script' to take a value from a variable for walking path lookin like this {n|nw|ne|ne|ne|n|finish}.
I want this alias to take first value and do a 'command 1' (eg 'search location')
and as a result MUD sends back result information

>You have found something

or

>You haven't found anything


Basically in MUD im playing on a long paths you get no more than two herbs, searching of a herb takes around 7-10 seconds, which is a bit of a long time. So i'd like to use a script which is going to work like this:

im inputing path to zMUD
#var path {se|e|ne|e|e|e|e}

and then my character goes on first location 'se'
starts to perform a search for herbs
'look for herbs
>You are looking for herbs. '
>You have found a small green leaf' [in this case result is positive so knowing that there are two herbs on location search one more time]

'look for herbs
>You are looking for herbs.
>You search entire area but you haven't found anything.'


In this situation id like sent to a MUD second direction from @path and perform search on second location and so on..

In case when character finds nothing in first search, move straight away to next location.




I ve been struggling with that loop on @path and still got no clue how to make it work. Please help!

Is there anyone who know how to code these few lines in ZMUD. If yes i really appreciate this.

I hope that what i've written is fairly clear, if not don'hestitate to ask any questions.

Thanks
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sun Aug 10, 2008 9:20 pm   
 
I understand the concept I think. Bear with me here.

Code:

#CLASS {HerbSearch}
#ALIAS Collect {
  #exec %item( @path, 1)
  lfb
  }
#ALIAS lfb {look for herb}
#VAR path {se|e|ne|e|e|e|e}
#REGEX "HerbLook" {You are looking for herbs\.$} {}
#COND {(*)$} {#if (!%begins( %line( "You have found"))) {lfb} {Collect}} {within|param=1}
#CLASS 0



Well, this piece of code is conveys the very first ideas I got. Most of it should perhaps be self-explainatory, but few things...

Basically I understood that there are two possibilities after you've done "look for herbs". Either you get the line saying you've found something in regard which you'll do the search once more or you'll get the message saying there ain't any herbs there in case you
have to move on.

So I made the HerbLook trigger with conditional. This conditional works in case either of the lines I spoke about appear directly
after "you look for herbs" line. Basically you can remove the Within Lines option and go with nothing at all, as well.

In that case though trigger has to be turned off during each possibilities it might fill - either you collect further, or you venture further.
Then you can add #t+ HerbLook into Collect alias value so that each time you move, the trigger will be activated.

Something like

#alias Collect {#exec %item(@path,1);#t+ HerbLook;lfb}

Notice that I put trigger enable *before* lfb. Its important because otherwise the message will be seen before trigger is actually active.

I'm not actively using ZMud at this point so I just made the code here, imported it to ZMud and checked it for errors. I didn't test it at all.

Hopefully it will work or at least convey you the basic principles for doing stuff that you want.

Prog
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
haesus
Newbie


Joined: 07 Aug 2008
Posts: 5

PostPosted: Tue Aug 12, 2008 1:42 pm   
 
Hi
I checked it . Its not working. It is not rolling throug the string list path. It gets first value all the time
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Tue Aug 12, 2008 2:36 pm   
 
Well, if otherwise it was OK, this change is easy.

Just add another variable that would have "fixed" list and each time you start the run, you load the "temporal" one with this one.

Code:

#CLASS {HerbSearch}
#VAR FixedPath {se|e|ne|e|e|e|e}
#ALIAS LoadPath {path=@{FixedPath}}
#ALIAS Collect {
  #if (!%null(@path)) {#exec %pop(path);lfb} {#SAY Path is completed. Reloading.;LoadPath;#exec %pop(path);lfb}
  }
#ALIAS lfb {look for herb}
#VAR path {se|e|ne|e|e|e|e}
#REGEX "HerbLook" {You are looking for herbs\.$} {}
#COND {(*)$} {#if (!%begins( %line( "You have found"))) {lfb} {Collect}} {within|param=1}
#CLASS 0


This should work however I haven't tested it because I don't have much time right now.
Btw, try to understand the code. Thats the best possible way to learn. Right now I'm not going into details only saying that
I incorporated into Collect alias the automatical reload and new direction execution as well, hopefully it turns out OK.


Prog
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