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 Goto page 1, 2  Next
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Mon Oct 08, 2007 12:27 am   

Beginners script question
 
I would like to create a script which would look at the available directions, decide which way to go and then move in that direction and repeat until a condition is met. I have looked at the help files and what I have not found is how to capture input from the screen other that triggers. Below is a sample of the text.

How do I capture this and if my last direction was N then go east if available, then north if available then west if available.

[Exits: south west]
Room Description goes here.

I would like this to be a script which I can submit when I need it. Not something which would be triggered on its own.

Thanks for any information. (what I realy need is just how to capture the input from the screen)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Oct 08, 2007 12:59 am   
 
Parsing output from the screen is done with triggers. Take a look at this help file for an introduction to triggers, and this one for information on pattern matching.

That said, if what you're looking for is something to get you from place to place, you may get better results from CMUD's path system, or from its mapper. The path system allows you to create static paths between one place and another and replay them any time you like. The mapper lets you create a map of your MUD - you can then double-click on any room in the map to be taken to it.

If you're not looking for something to get you from place to place, more specific info would allow us to help you create something more fitting.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Mon Oct 08, 2007 2:20 am   
 
I would like to find my way through a changing area. From my starting point, which can change, i want to identify the exits, check the room description and then decide which way to go, move in that direction and repeat until I find what i am looking for.



[Exits: north east south west]
Room Description goes here.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Oct 08, 2007 2:49 am   
 
Do the exits change in this area? How do you know which room you're in? What're you looking for? Does that move too? How do you "decide which way to go"? Basically, you need to create a script that goes through the same logic that you do when looking for the item. You need to be very specific about how you go about searching for it.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Mon Oct 08, 2007 8:20 pm   Just looking for some direction
 
When ever you move into a new room the first thing you see is '[Exits: north east south west]' which lists the available directions in which you can move. Followed by the room description.

How do I check for what exits are availble while keeping track of the direction I just moved and perform some logic to determine the direction I wan\t to go in? And after I have moved how do I look at the room description to look for certian items and then check exits and move again if I dont find what i wanted.?

I am looking on for basic instructions or well documented examples of how to do this. I would like to do this myself so I can make additional scripts as well.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Oct 08, 2007 8:31 pm   
 
At the most basic level, you can use %pos or %match or %regex to determine if a string is part of another. You can use %replace or %subchar or %subregex to change one separator (the spaces between your room exits, for example) into pipes that're used as the separator for string lists, which can then be used for things like #forall, %expanddb and %ismember. It's hard to give you specific help, pointing you in the direction of examples and techniques you'll need, without knowing the specifics of your problem.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Mon Oct 08, 2007 8:50 pm   still lost
 
I am still lost. How do I get the script started and get the string to run any fo the functions on?
Reply with quote
JQuilici
Adept


Joined: 21 Sep 2005
Posts: 250
Location: Austin, TX

PostPosted: Mon Oct 08, 2007 9:01 pm   
 
Smudly wrote:
I am still lost. How do I get the script started and get the string to run any fo the functions on?

An alias (see #ALIAS in the CMUD Command Reference) is what you want. If you type the name of the alias at the prompt, the script runs.

At a slightly higher level, here's what I would suggest as a basic structure (gurus please feel free to correct me):

Create a class (see #CLASS) to hold a bunch of variables, triggers, and other scripts. For the sake of my example, I'll assume it's called '#CLASS AutoRoamUtil', and it should be DISABLED by default. There are two advantages to sticking (almost) all of your scripts into a class:
  • It keeps the namespaces clear, so that your variable names don't conflict with anyone else's
  • You can turn the class as a whole (and thus all of its triggers) on and off

In AutoRoamUtil, you create:
  • One or more triggers (see #TRIGGER) to capture the exits and any other information you need to decide where to go next, and store them into variables (see #VARIABLE, etc.) within the class.
  • An alias (see #ALIAS) which implements the logic for deciding which direction to go next (using the stored info), clears your variables, and issues the movement command (again, for the sake of the example, I'll call this 'DoAutoRoamStep').
  • A trigger which detects that you have seen all of the information you need for a given room (e.g. you've reached the end of the room description, you've hit a prompt, whatever), and calls DoAutoRoamStep.
  • A trigger that detects that you have reached your destination, and disables (see #T-) the class AutoRoamUtil (thus preventing any more automatic steps).
  • An alias to just disable class AutoRoamUtil (e.g. 'AbortAutoRoam'). This is purely for safety/sanity, so that you can manually bail out if your script goes wacky.

Finally, you create an alias OUTSIDE the AutoRoamUtil class (call it 'AutoRoam') that just enables (see #T+) the AutoRoamUtil class and sends 'look' to the MUD. That should cause your triggers to grab the info from the current room, issue the first step, and repeat until you get to your destination. Then, you can simply type 'AutoRoam' at your command prompt whenever you want this process to start up.

Without specific MUD output and/or a better idea of how you're making the decision, this is as close as I can get, but it should be a start.
_________________
Come visit Mozart Mud...and tell an imm that Aerith sent you!
Reply with quote
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Tue Oct 09, 2007 2:57 am   Still Dont Get It
 
Im sorry but I am having a real hard time grasping this.

What I want to do is

do a look to see what directions are available.
If I can go north move north if not then east it not then west if not then south
loop until find mithril
Look to see if there is gold in the room. If there is pick it up
if not
if my last move was north then go east if not then go north if not then go west if not then go south
If my last move was east then go south if not then go east if not then go north if not then go west
if my last move was south then go west if not then go south if not then go east if not then go north
if my last move was west then go north if not then go west if not then go south if not then go east
end loop
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Oct 09, 2007 7:59 am   
 
Now we're getting somewhere.

#class FindMithril disable
#trig {There is some mithril here} {get mithril;#untrigger MoveAlarm;#t- FindMithril}
#var LastMove "" ""
#oninput {^({north|south|east|west})$} {#var LastMove %1}
#var RoomExits ""
#trig {^~[Exits~: ([a-z ])~]$} {#var RoomExits %replace(%1," ","|");#alarm "MoveAlarm" {+2} {ChooseExit @LastMove}}
#alias ChooseExit {#if (%1) {#if (@LastMove="north") {#if %ismember(@RoomExits,"east") {#send "east"} {#if %ismember(@RoomExits,"north") {#send "north"} {#if %ismember(@RoomExits,"west") {#send "west"} {#if %ismember(@RoomExits,"south") {#send "south"}}}}} {#if (@LastMove="east") {...etc etc etc...}}} {#send %item(@RoomExits,1)}}
#class 0

Look up any of the commands and functions that you don't understand, and see if you can follow the logic. Basically, when you move a direction, it stores the direction, when you enter a room, it captures the exits, and then after giving a little bit of time for the "There is some mithril here" trigger to fire, if it's going to, it chooses the next exit based on the logic you have there. There's probably an easier way to do that logic, but I just woke up and I'm damned if I can see the pattern.

For clarity, here's an intented version of the incomplete ChooseExit alias. It's pretty confusing otherwise:

Code:
#if (%1) {
  #if (@LastMove="north") {
    #if %ismember(@RoomExits,"east") {
      #send "east"
    } {
      #if %ismember(@RoomExits,"north") {
        #send "north"
      } {
        #if %ismember(@RoomExits,"west") {
          #send "west"
        } {
          #if %ismember(@RoomExits,"south") {
            #send "south"
          }
        }
      }
    }
  } {
    #if (@LastMove="east") {
      ...etc etc etc...
    }
  }
} {
  #send %item(@RoomExits,1)
}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
JQuilici
Adept


Joined: 21 Sep 2005
Posts: 250
Location: Austin, TX

PostPosted: Tue Oct 09, 2007 10:54 pm   
 
Smudly, you may want to examine your logic for choosing the next direction. If I'm reading you right, it will be very easy for your character to get stuck in an infinite loop of four rooms (N, E, S, W, repeat forever).

But that aside, the structure Fang provided will work quite well. Just replace the guts of ChooseExit as needed to get the right behavior.
_________________
Come visit Mozart Mud...and tell an imm that Aerith sent you!
Reply with quote
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Wed Oct 10, 2007 12:08 am   Thanks for the help
 
thanks for taking the time to help with this. I will work through the example you have provided and see what I can learn from it.

Thanks for pointing out the issue with getting stuck going in a circle. I was aware of this possiblility and once I had this muchworking I was going to try and add additional logic to take care of that issue. I am trying to keep it basic until the syntax starts to sink in.

Thaks again for the assistance.
Reply with quote
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Wed Oct 10, 2007 3:24 am   Syntax error
 
Surprise surprise I am still having problems. Below is the script I am trying to run. When I run the script I get an unmatched bracket error where I have the *****. I managed to get rid of it once by removing all the spaces but then I received an illegal token error at the end of the script. I retyped the closing brackets and now I get the unmatched bracket error no matter how many I have there.




#class FindMithril disable
#trig {There is some mithril here} {get mithril;#untrigger MoveAlarm;#t- FindMithril}
#var LastMove "" ""
#oninput {^({north|south|east|west|down})$} {#var LastMove %1}
#var RoomExits ""
#trig {^~[Exits~: ([a-z ])~]$} {#var RoomExits %replace(%1," ","|");#alarm "MoveAlarm" {+2} {ChooseExit @LastMove}}
#alias ChooseExit {
#if (%ismember(@RoomExits,"down")) {#send "down"}
#if (%1) {
#if (@LastMove="north") {
#if (%ismember(@RoomExits,"east")) {#send "east"} {
#if (%ismember(@RoomExits,"north")) {#send "north"} {
#if (%ismember(@RoomExits,"west")) {#send "west"} {
#if (%ismember(@RoomExits,"south")) {#send "south"}}}}}******{
#if (@LastMove="east") {
#if (%ismember(@RoomExits,"south")) {#send "south"} {
#if (%ismember(@RoomExits,"east")) {#send "east"} {
#if (%ismember(@RoomExits,"north")) {#send "north"} {
#if (%ismember(@RoomExits,"west")) {#send "west"}}}}}{
#if (@LastMove="south") {
#if (%ismember(@RoomExits,"west")) {#send "west"} {
#if (%ismember(@RoomExits,"south")) {#send "south"} {
#if (%ismember(@RoomExits,"east")) {#send "east"} {
#if (%ismember(@RoomExits,"north")) {#send "north"}}}}}{
#if (@LastMove="west") {
#if (%ismember(@RoomExits,"north")) {#send "north"} {
#if (%ismember(@RoomExits,"west")) {#send "west"} {
#if (%ismember(@RoomExits,"south")) {#send "south"} {
#if (%ismember(@RoomExits,"east")) {#send "east"}}}}}}
#class 0
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Oct 10, 2007 3:54 am   
 
You're missing some spaces between closing braces and opening braces - one such place is where those stars are. Add them in and see if that helps.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Thu Oct 11, 2007 4:30 pm   Illegal Token
 
I added the spaces and now it says illegal token after #class 0

Sorry to be such a pain.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Oct 11, 2007 5:00 pm   
 
Illegal token is a general catchall error - it usually means you've created something that the parser just plain can't understand, not something that's obviously in error (undefined local variable, unmatched brace or whatever). Normally it indicates a spacing error or an inappropriate use of an arithmetic operator. Make sure you really have fixed the spacing.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Thu Oct 11, 2007 5:21 pm   updated Sript
 
#class FindMithril disable
#trig {There is some mithril here} {get mithril;#untrigger MoveAlarm;#t- FindMithril}
#var LastMove "" ""
#oninput {^({north|south|east|west|down})$} {#var LastMove %1}
#var RoomExits ""
#trig {^~[Exits~: ([a-z ])~]$} {#var RoomExits %replace(%1," ","|");#alarm "MoveAlarm" {+2} {ChooseExit @LastMove}}
#alias ChooseExit {
#if (%ismember(@RoomExits,"down")) {#send "down"}
#if (%1) {
#if (@LastMove="north") {
#if (%ismember(@RoomExits,"east")) {#send "east"} {
#if (%ismember(@RoomExits,"north")) {#send "north"} {
#if (%ismember(@RoomExits,"west")) {#send "west"} {
#if (%ismember(@RoomExits,"south")) {#send "south"}}}}} {
#if (@LastMove="east") {
#if (%ismember(@RoomExits,"south")) {#send "south"} {
#if (%ismember(@RoomExits,"east")) {#send "east"} {
#if (%ismember(@RoomExits,"north")) {#send "north"} {
#if (%ismember(@RoomExits,"west")) {#send "west"}}}}} {
#if (@LastMove="south") {
#if (%ismember(@RoomExits,"west")) {#send "west"} {
#if (%ismember(@RoomExits,"south")) {#send "south"} {
#if (%ismember(@RoomExits,"east")) {#send "east"} {
#if (%ismember(@RoomExits,"north")) {#send "north"}}}}} {
#if (@LastMove="west") {
#if (%ismember(@RoomExits,"north")) {#send "north"} {
#if (%ismember(@RoomExits,"west")) {#send "west"} {
#if (%ismember(@RoomExits,"south")) {#send "south"} {
#if (%ismember(@RoomExits,"east")) {#send "east"}}}}}}
#class 0
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Oct 11, 2007 6:13 pm   
 
Blimey, this is annoying. Here's the code of the ChooseExit alias that you've posted there, spaced in a more readable way:

Code:
#alias ChooseExit {#if (%ismember(@RoomExits,"down")) {#send "down"}
#if (%1) {
  #if (@LastMove="north") {
    #if (%ismember(@RoomExits,"east")) {
      #send "east"
    } {
      #if (%ismember(@RoomExits,"north")) {
        #send "north"
      } {
        #if (%ismember(@RoomExits,"west")) {
          #send "west"
        } {
          #if (%ismember(@RoomExits,"south")) {
            #send "south"
          }
        }
      }
    }
  } {
    #if (@LastMove="east") {#if (%ismember(@RoomExits,"south")) {
      #send "south"
    } {
      #if (%ismember(@RoomExits,"east")) {
        #send "east"
      } {
        #if (%ismember(@RoomExits,"north")) {
          #send "north"
        } {
          #if (%ismember(@RoomExits,"west")) {
            #send "west"
          }
        }
      }
    }[1]
  } {
    #if (@LastMove="south") {
      #if (%ismember(@RoomExits,"west")) {
        #send "west"
      } {
        #if (%ismember(@RoomExits,"south")) {
          #send "south"
        } {
          #if (%ismember(@RoomExits,"east")) {
            #send "east"
          } {
            #if (%ismember(@RoomExits,"north")) {
              #send "north"
            }
          }
        }
      }
    } {
      #if (@LastMove="west") {
        #if (%ismember(@RoomExits,"north")) {
          #send "north"
        } {
          #if (%ismember(@RoomExits,"west")) {
            #send "west"
          } {
            #if (%ismember(@RoomExits,"south")) {
              #send "south"
            } {
              #if (%ismember(@RoomExits,"east")) {
                #send "east"
              }
            }
          }
        }
      }
    }


You have one too many braces where I've marked [1]. You're also missing three braces at the end. In the future, space your scripts a little better to avoid this problem. But it's still not working! Very frustrating.

However, I just realised that this is a CMUD problem (can't believe it took me this long), and that makes things much easier thanks to the #switch command. Here's your script converted to using #switch. It should compile properly.

Code:
#alias ChooseExit {#if (%ismember(@RoomExits,"down")) {#send "down"}
#switch (%1)
  ("north") {
    #switch (%ismember(@RoomExits,"east")) {#send "east"}
      (%ismember(@RoomExits,"north")) {#send "north"}
      (%ismember(@RoomExits,"west")) {#send "west"}
      (%ismember(@RoomExits,"south")) {#send "south"}
  }
  ("east") {
    #switch (%ismember(@RoomExits,"south")) {#send "south"}
      (%ismember(@RoomExits,"east")) {#send "east"}
      (%ismember(@RoomExits,"north")) {#send "north"}
      (%ismember(@RoomExits,"south")) {#send "west"}
  }
  ("south") {
    #switch (%ismember(@RoomExits,"west")) {#send "west"}
      (%ismember(@RoomExits,"south")) {#send "south"}
      (%ismember(@RoomExits,"east")) {#send "east"}
      (%ismember(@RoomExits,"north")) {#send "north"}
  }
  ("south") {
    #switch (%ismember(@RoomExits,"west")) {#send "west"}
      (%ismember(@RoomExits,"south")) {#send "south"}
      (%ismember(@RoomExits,"east")) {#send "east"}
      (%ismember(@RoomExits,"north")) {#send "north"}
  }
  ("west") {
    #switch (%ismember(@RoomExits,"north")) {#send "north"}
      (%ismember(@RoomExits,"west")) {#send "west"}
      (%ismember(@RoomExits,"south")) {#send "south"}
      (%ismember(@RoomExits,"east")) {#send "east"}
  }  {
    #say Invalid direction: %1
  }
}


PS. A quick note about that #if %ismember(@RoomExits,down) part you added - you're aware that, should a room have a down exit, that this script will always move down, but having done so, it'll then run through the logic and decide which exit it would've taken from the room with the down exit, had it not had a down exit, and move in that direction as well? I don't think this'll cause any problems, but it might, and might be unintended.

PPS. I just realised that I'd intended to not use @LastMove in the alias at all, either. Fixed that too.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Fri Oct 12, 2007 2:20 am   Still doesnt work
 
I have included the complete class below which I have stored in a single file. When i try and execute it I get "Command List Expected after the first #switch. If I move ("north") up onto the same line as the switch I get an unexpected token before the second #switch.

Sorry to be such a pain but I just dont seem to be getting this at all.


#class FindMithril disable
#trig {There is some mithril here} {get mithril;#untrigger MoveAlarm;#t- FindMithril}
#var LastMove "" ""
#oninput {^({north|south|east|west|down})$} {#var LastMove %1}
#var RoomExits ""
#trig {^~[Exits~: ([a-z ])~]$} {#var RoomExits %replace(%1," ","|");#alarm "MoveAlarm" {+2} {ChooseExit @LastMove}}
#alias ChooseExit {#if (%ismember(@RoomExits,"down")) {#send "down"}
#switch (%1)
("north") {
#switch (%ismember(@RoomExits,"east")) {#send "east"}
(%ismember(@RoomExits,"north")) {#send "north"}
(%ismember(@RoomExits,"west")) {#send "west"}
(%ismember(@RoomExits,"south")) {#send "south"}
}
("east") {
#switch (%ismember(@RoomExits,"south")) {#send "south"}
(%ismember(@RoomExits,"east")) {#send "east"}
(%ismember(@RoomExits,"north")) {#send "north"}
(%ismember(@RoomExits,"south")) {#send "west"}
}
("south") {
#switch (%ismember(@RoomExits,"west")) {#send "west"}
(%ismember(@RoomExits,"south")) {#send "south"}
(%ismember(@RoomExits,"east")) {#send "east"}
(%ismember(@RoomExits,"north")) {#send "north"}
}
("south") {
#switch (%ismember(@RoomExits,"west")) {#send "west"}
(%ismember(@RoomExits,"south")) {#send "south"}
(%ismember(@RoomExits,"east")) {#send "east"}
(%ismember(@RoomExits,"north")) {#send "north"}
}
("west") {
#switch (%ismember(@RoomExits,"north")) {#send "north"}
(%ismember(@RoomExits,"west")) {#send "west"}
(%ismember(@RoomExits,"south")) {#send "south"}
(%ismember(@RoomExits,"east")) {#send "east"}
} {
#say Invalid direction: %1
}
}
#class 0
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 12, 2007 2:27 am   
 
Smudly: Please post your scripts within a [code] tag to preserve the spacing. Otherwise it's nearly impossible to help with this. For example, you would use:

[code]
put your script here
[/code]

in your forum post to get the script placed into a code box like Fang was using.

In the CMUD script editor, when you move the cursor before or after a } character, it will highlight the matching { in yellow. You can use this to make sure your braces all line up. Proper indentation and spacing of lines is *very* important in CMUD multiline scripts.

Fang wrote:
However, I just realised that this is a CMUD problem

Can you tell me more about exactly what the CMUD problem is?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Oct 12, 2007 2:44 am   
 
I meant that this is a question referring to CMUD, as opposed to a question referring to zMUD. That's why I originally suggested a big load of #ifs instead of a couple of #switches.

Zugg's right about the spacing - it's important in this example, too, it won't work without it. Editing your post, it seems that you have no spacing, and that'll cause problems. It was working fine on my end when I pasted the code I gave you onto the command line.

If a line has been indented since the previous command, CMUD ignores the line break. So this:

Code:
#say hello
  to
  you!

Will echo "hello to you!" to the screen, whereas this:

Code:
#say hello
to
you!

CMUD won't ignore the line breaks - it'll interpret them as breaks between commands and echo "hello" to the screen, and send "to" and "you!" to the MUD.

Finally, what do you mean by "stored in a single file"?
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Fri Oct 12, 2007 3:46 am   Script within code tags
 
Ok. Here is the script inbwtween code tags. By a single file I meant everything below is stored in a single text file and I am trying to execute it by going to Actions->Execute Script and selecting the text file.



Code:

#class FindMithril disable
#trig {There is some mithril here} {get mithril;#untrigger MoveAlarm;#t- FindMithril}
#var LastMove "" ""
#oninput {^({north|south|east|west|down})$} {#var LastMove %1}
#var RoomExits ""
#trig {^~[Exits~: ([a-z ])~]$} {#var RoomExits %replace(%1," ","|");#alarm "MoveAlarm" {+2} {ChooseExit @LastMove}}
#alias ChooseExit {#if (%ismember(@RoomExits,"down")) {#send "down"}
#switch (%1)
("north") {
#switch (%ismember(@RoomExits,"east")) {#send "east"}
(%ismember(@RoomExits,"north")) {#send "north"}
(%ismember(@RoomExits,"west")) {#send "west"}
(%ismember(@RoomExits,"south")) {#send "south"}
}
("east") {
#switch (%ismember(@RoomExits,"south")) {#send "south"}
(%ismember(@RoomExits,"east")) {#send "east"}
(%ismember(@RoomExits,"north")) {#send "north"}
(%ismember(@RoomExits,"south")) {#send "west"}
}
("south") {
#switch (%ismember(@RoomExits,"west")) {#send "west"}
(%ismember(@RoomExits,"south")) {#send "south"}
(%ismember(@RoomExits,"east")) {#send "east"}
(%ismember(@RoomExits,"north")) {#send "north"}
}
("south") {
#switch (%ismember(@RoomExits,"west")) {#send "west"}
(%ismember(@RoomExits,"south")) {#send "south"}
(%ismember(@RoomExits,"east")) {#send "east"}
(%ismember(@RoomExits,"north")) {#send "north"}
}
("west") {
#switch (%ismember(@RoomExits,"north")) {#send "north"}
(%ismember(@RoomExits,"west")) {#send "west"}
(%ismember(@RoomExits,"south")) {#send "south"}
(%ismember(@RoomExits,"east")) {#send "east"}
} {
#say Invalid direction: %1
}
}
#class 0
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Oct 12, 2007 3:52 am   
 
Okay, you need to add the spacing to the text file. Then it'll start working.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Smudly
Beginner


Joined: 07 Oct 2007
Posts: 24

PostPosted: Fri Oct 12, 2007 5:01 pm   Gettig closer
 
I have indented the code below and now I get no errors when the script executes. However nothing at all happens. I put in the #send "l" thinking it would activate the triggers. It does display the room description (including the exits) but it didnt trigger anything.

How does this keep track of the last direction i moved in? I see there is a last move variable but how does it get set?

Code:

#class FindMithril disable
#send "l"
#trig {There is some mithril here} {get mithril;#untrigger MoveAlarm;#t- FindMithril}
#var LastMove "" ""
#oninput {^({north|south|east|west|down})$} {#var LastMove %1}
#var RoomExits ""
#trig {^~[Exits~: ([a-z ])~]$} {#var RoomExits %replace(%1," ","|");#alarm "MoveAlarm" {+2} {ChooseExit @LastMove}}
#alias ChooseExit {#if (%ismember(@RoomExits,"down")) {#send "down"}
#switch (%1)
  ("north") {
     #switch (%ismember(@RoomExits,"east")) {#send "east"}
             (%ismember(@RoomExits,"north")) {#send "north"}
             (%ismember(@RoomExits,"west")) {#send "west"}
             (%ismember(@RoomExits,"south")) {#send "south"}
            }
  ("east") {
     #switch (%ismember(@RoomExits,"south")) {#send "south"}
             (%ismember(@RoomExits,"east")) {#send "east"}
             (%ismember(@RoomExits,"north")) {#send "north"}
             (%ismember(@RoomExits,"south")) {#send "west"}
           }
  ("south") {
     #switch (%ismember(@RoomExits,"west")) {#send "west"}
             (%ismember(@RoomExits,"south")) {#send "south"}
             (%ismember(@RoomExits,"east")) {#send "east"}
             (%ismember(@RoomExits,"north")) {#send "north"}
            }
  ("south") {
     #switch (%ismember(@RoomExits,"west")) {#send "west"}
             (%ismember(@RoomExits,"south")) {#send "south"}
             (%ismember(@RoomExits,"east")) {#send "east"}
             (%ismember(@RoomExits,"north")) {#send "north"}
            }
  ("west") {
     #switch (%ismember(@RoomExits,"north")) {#send "north"}
             (%ismember(@RoomExits,"west")) {#send "west"}
             (%ismember(@RoomExits,"south")) {#send "south"}
             (%ismember(@RoomExits,"east")) {#send "east"}
           } {
  #send Invalid direction: %1
 }
}
#class 0
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Oct 12, 2007 5:24 pm   
 
Look at the help file for the #oninput command. It gets set whenever you enter one of the directions in the list. If there are other directions you can move, you need to add them. "look" deliberately doesn't activate it because "look" isn't a direction.

Also, why did you add the "send l" to the text file? you seem to have gotten the wrong impression - once you've run the commands there, you never need to run them again. The aliases and triggers they create will persist across sessions - all you need to do is enable them.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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