 |
| Smudly |
Posted: Mon Oct 08, 2007 12:27 am
Beginners script question |
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Oct 12, 2007 5:50 pm |
The Actions->Execute Script might have a bug dealing with multi-line commands. You might want to just paste the entire script into the command line as Fang was suggesting.
|
|
|
|
 |
Smudly Beginner
Joined: 07 Oct 2007 Posts: 24
|
Posted: Sat Oct 13, 2007 1:58 am Your right I still dont get it |
I removed the send #l line and entered FindMithril on the command line and nothing happens. I then did a #T+ FindMithril then tried FindMithril again with the same results.
I also tried pasting the whole thing into the command line with the same results.
How do I get the script/trigger/alias started? |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Oct 13, 2007 2:06 am |
FindMithril isn't an alias, you don't type it onto the command line. It's the name of the class (or folder) that'll contain all the other stuff that runs the script.
To get it started, open the package editor and delete anything there called FindMithril. Close the editor, paste what I gave you at the start, but replace the old, incomplete #alias ChooseExit command with the new one that uses switch. Hit enter and all the settings'll be created.
To get it started once you've done that, do #t+ FindMithril to enable the FindMithril class folder, then move in a direction. It'll take over from there and disable itself once it finds some. If you want to disable it early (if it gets stuck in a loop, for example, which is a possibility) you can do #t- FindMithril to disable it again. |
|
|
|
 |
Smudly Beginner
Joined: 07 Oct 2007 Posts: 24
|
Posted: Sat Oct 13, 2007 2:24 am |
It is realy bugging me that this just is not sinking in. Why did I create the #Class findmithril if I am not going to use it.. If I am using it then wouldnt it have been better to create two separate files? Why do I have to delete findmithril and resubmit it to get it to work?
What should be in the script I execute? Everything except the first and last line? If I remove the findmithril class how do i stop it once I have started it? |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Oct 13, 2007 2:34 am |
Okay... this is going to take a bit of explaining. CMUD stores certain things in an internal database, and saves that database to disk as a .pkg file. The things that are saved in the pkg are triggers, aliases, functions, events and a few other things. A full list is here.
The #class command creates classes. Classes are folders - they're saved to the database, and their purpose is to organise the other settings. If a class is disabled, everything inside it is disabled as well - that's the purpose of the #t+ and #t- commands, to enable and disable the class FindMithril.
So the first thing that script I gave you does is create a folder called "FindMithril". This is then set as the current folder for all other commands that create settings. The #class 0 command restores the current class to the default, which is why it comes at the end.
The #var command creates variables or changes the current value of a variable. They only need to be created once - once you've run the #var command, the variable will be stored to the disk. The first parameter is the name of the variable - the second is the value (in this case it's blank) - and the fourth is the default value (also blank so it's removed when you restart to prevent the script from choosing the wrong direction when you first start the script).
The #oninput and #trig commands create triggers. Again, they only need to be created once - once they're created, they'll be stored in the database.
The #alias command creates aliases in the same way.
So the commands I've given you in this thread create a FindMithril class, and then create the triggers, aliases and variables that're used in the script. I should've made this clear at the start - you only need to delete the FindMithril class and its contents once, to make sure you've got no old versions of the aliases and triggers hanging around. Then you're free to run the commands I've given you to create the proper aliases and triggers. You only need to run those commands once to create the settings - after that, you just enable and disable the class to enable and disable the script.
Once the aliases and triggers are present and are going to do the right thing, you can enable the FindMithril class (which is disabled by default) and start it going by moving in a direction. |
|
|
|
 |
Smudly Beginner
Joined: 07 Oct 2007 Posts: 24
|
Posted: Sat Oct 13, 2007 2:41 am |
Am I looking for a file called Findmithril? If so I do not find any under the CMUD folder.
I have tried the #T+ and #T- commands and the most I get is an invalid direction error popping up occassionally when I am not doing anything. |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Oct 13, 2007 2:51 am |
No - the FindMithril class folder is a folder inside the CMUD database. The database is internal - it's contained in a file called YourSessionName.pkg. Open the settings editor, and you'll see the FindMithril class I'm talking about. You'll also see the triggers and aliases that the commands I gave you in the thread created.
You'll need to give more info on the invalid direction problem. You were very vague about how your MUD works - it's difficult for me to speculate on things that might be causing the problem. You'll probably have to fix it yourself, which'll require understanding how the script is working first. |
|
|
|
 |
Smudly Beginner
Joined: 07 Oct 2007 Posts: 24
|
Posted: Sat Oct 13, 2007 11:28 pm Nothing is happening. |
I looked in settings and fond the FindMithril class and deleted it. I then went to action and selected execute script and selected the previous script. On the command line I entered #T+ FindMithril followed by a look command. I get the room description below but nothing else happens
Inn of the Red dragon
[Exits: east south west up]
A disquiting place to sleep. Many differnt races have congregated here making the common room an uncomfortable blend of smells and noise....
To move in any direction I would enter n or north for north etc. Any ideas on why nothing is happening? |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Oct 13, 2007 11:34 pm |
Because "look" isn't a direction. It should've told you that, though. Find the trigger that's inside the FindMithril class and add a line #say "fired" to it. Save the trigger then try looking again to see if the trigger is firing.
|
|
|
|
 |
Smudly Beginner
Joined: 07 Oct 2007 Posts: 24
|
Posted: Sat Oct 13, 2007 11:46 pm |
The trigger ^({north|south|east|west|down})$ with body below fired but the second trigger- Exits - is not showing fired2
#var LastMove %1
#say "fired"
but the trigger ^~[Exits~: ([a-z ])~]$
#var RoomExits %replace(%1," ","|");#alarm "MoveAlarm" {+2} {ChooseExit @LastMove}
#say "fired2" |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Oct 13, 2007 11:59 pm |
You must've done something wrong (or perhaps not deleted an old version of this trigger - check) because that pattern matches all the room description examples you've given so far. What text didn't cause it to fire?
|
|
|
|
 |
Smudly Beginner
Joined: 07 Oct 2007 Posts: 24
|
Posted: Sun Oct 14, 2007 12:07 am |
I have played with it and now both triggers work and it gets to the alias chooseexit. I put a say command as the first line in the choose exit alias and it was displayed. However nothing else happens
|
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Oct 14, 2007 12:39 am |
Check the value that's being passed to the ChooseExit alias, and the value of the LastMove variable. What is it? It needs to be a valid exit (one of the four that ChooseExit handles) to work.
|
|
|
|
 |
Smudly Beginner
Joined: 07 Oct 2007 Posts: 24
|
Posted: Mon Oct 15, 2007 5:06 pm I think I figured it out |
Maybe some of this is sinking in after all. I traced it all the way to the ifs within thw switch statements ad the ismembr arguments are backwards. I will let you know once I have alittle more time to play with it if that took care of ecerything.
currently - (%ismember(@RoomExits,"north")) {#send "north"}
Should be - (%ismember("north",@RoomExits)) {#send "north"} |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Oct 15, 2007 5:09 pm |
Wtfhax. It was working here before I pasted it :| Perhaps I changed it and forgot to update the text file I was keeping it in?
|
|
|
|
 |
Smudly Beginner
Joined: 07 Oct 2007 Posts: 24
|
Posted: Fri Oct 19, 2007 5:28 am Not quite there after all |
I just keep going back and forth. I entered the following command on the command line but LastMove is always West.
#oninput {^({north|south|east|west|down})$} {#var LastMove %1} |
|
|
|
 |
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Fri Oct 19, 2007 9:24 am |
Do you have actually type, e.g. west, or do you just type "w", or do you have a macro, or a button? What command is sent to the mud?
|
|
|
|
 |
Smudly Beginner
Joined: 07 Oct 2007 Posts: 24
|
Posted: Fri Oct 19, 2007 4:09 pm Direction command |
In the mud you can type either W or West to go west. The script itself should be sending the complete word (See previus posts). The first line in the choose exits alias displays LastMove and it is always west even when I know East was sent.
|
|
|
|
 |
|
|
|