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
nutsnbolts
Apprentice


Joined: 01 May 2002
Posts: 188
Location: USA

PostPosted: Fri Jun 07, 2002 5:48 pm   

Text file into Mud
 
Is there anyway to use a text file that has a list of equipment per line and send it into the mud? Better yet, allow a search within a mud to search the txt file then output it on the mud.

Here is an example of one line in the text file.

#DATA a symbol of the magi=<neck> -- 0.500kg 1H 1B 0A 0L +5Ma glow



Sup
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Fri Jun 07, 2002 6:08 pm   
 
This is pretty much related to the script we gave you to capture the info from the text file and populate your db with it. You can use pretty much the same commands and variables. You should look at the help files for #FILE, #FORALL, #WHILE, #UNTIL, and %read,%grep.
Reply with quote
nutsnbolts
Apprentice


Joined: 01 May 2002
Posts: 188
Location: USA

PostPosted: Fri Jun 07, 2002 10:26 pm   
 
ahh...It was just a thought. Maybe avoid the entire DB thingamagig.

Sup
Reply with quote
nutsnbolts
Apprentice


Joined: 01 May 2002
Posts: 188
Location: USA

PostPosted: Sat Jun 08, 2002 8:10 pm   
 
Can someone help me create a script that pulls information from a file (eq lists), such as this in a text file.


a symbol of the magi=<neck> -- 0.500kg 1H 1B 0A 0L +5Ma glow
a symbol of the stars=<neck> -- 0.500kg 1H 1B 0A 0L +3Ma glow
a symbol of the night=<neck> -- 0.500kg 1H 1B 0A 0L +4Ma glow


In the mud, I want to be able to say, ID symbol

This will then access my text file and look for anything with symbol in it and output in the mud in a say command, the listings of symbols. Also, if there are more than 5, I would like to list the 5 items and then have it say, too many finds, please be more specific and I could even type, say ID a symbol of the magi and it would only bring this one item.

However, on the other hand, don't forget to put some kind of latency so that it doesn't crash my zmud when it tries to list it too fast.


Sup
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Jun 09, 2002 11:34 am   
 
#ALIAS ID {#VAR matches %grep(1, "%-1");#IF (!@matches) {#SAY No matches found.} {#IF (%numitems(@matches) > 5) {#SAY Too many matches.;#SAY Outputing first five matches:;#LOOP 1,5 {#SAY %read(1, %item(@matches, %i))}} {say Items matching '%-1' are:;#FORALL @matches {say %read(1, %i))}}}}

This assumes that the file is opened as file number 1.

Kjata
Reply with quote
nutsnbolts
Apprentice


Joined: 01 May 2002
Posts: 188
Location: USA

PostPosted: Sun Jun 09, 2002 2:34 pm   
 
Well, I'm only gonna use one file.

If in the future, after applying your script and learning more how everything is manipulated, I may add more files.

Thank you for creating the script for me. I have tried reading the help manuals but it's like foreign language to me. I need to see a script and see how it's applied before I am able to understand it.

Thank you for everything, it's always appreciated.
Reply with quote
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Sun Jun 09, 2002 4:58 pm   
 
This seems like a very interesting idea, so I tried it with my settings, but for some reason it will only list the first line, or if there are more than 5 of the requested item in the list, it just lists the top 5 lines.

Ex- List is
Sword
Shield
Armor
Mace
Flail
Whip

And I search for "Mace". It will return "Sword".

If the list is:
Sword
Shield
Armor
Mace
Flail
Whip
Sword 2
Sword 3
Sword 4
Sword 5

It returns:
Sword
Shield
Armor
Mace
Flail

Read all the info I could find on the %read and %grep functions, still not luck. Anybody know what could fix it?

Fat Tony
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Sun Jun 09, 2002 5:47 pm   
 
The problem here(I think) is that %grep fills the @matches var with a stringlist of the actual line(not the line number). %read uses numerical parameters. Hence the %read isnt very usefull.My suggestion is go ahead and read directly from the variable, since it has already been populated:

#ALIAS ID {#VAR matches %grep(1, "%-1");#IF (!@matches) {#SAY No matches found.} {#IF (%numitems(@matches) > 5) {#SAY Too many matches.;#SAY Outputing first five matches:;#LOOP 1,5 {#SAY %pop(matches)}} {say Items matching '%-1' are:;#FORALL @matches {say %pop(matches))}}}}
Reply with quote
nutsnbolts
Apprentice


Joined: 01 May 2002
Posts: 188
Location: USA

PostPosted: Sun Jun 09, 2002 6:18 pm   
 
quote:

This seems like a very interesting idea, so I tried it with my settings, but for some reason it will only list the first line, or if there are more than 5 of the requested item in the list, it just lists the top 5 lines.

Ex- List is
Sword
Shield
Armor
Mace
Flail
Whip

And I search for "Mace". It will return "Sword".

If the list is:
Sword
Shield
Armor
Mace
Flail
Whip
Sword 2
Sword 3
Sword 4
Sword 5

It returns:
Sword
Shield
Armor
Mace
Flail

Read all the info I could find on the %read and %grep functions, still not luck. Anybody know what could fix it?

Fat Tony



Kewl Fat Tony,

The mud I want to use this for is currently down, so I couldn't really test anything but since you tried it, let me know what else is not going right.

BTW:
What directory do I put the file for reading?

I may do some echo command testing with the correct data file.

Thank you for everything, it's always appreciated.
Reply with quote
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Sun Jun 09, 2002 6:23 pm   
 
Absolutely perfect, thank you very much.

- nutsnbolts, Just place the file in the main zMUD directory and enter #file 1 nameoffile.txt and read away. If you have any more trouble with it let me know, I'll show you what I have working.

Fat Tony
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Sun Jun 09, 2002 6:25 pm   
 
Put the file in the same directory as the Zmud.exe file is in. The default I believe is 'C:ZMUD'

Also, for the script to work, you need to open the file with script. Like so:
#FILE 1 yourfile.txt
#CLOSE 1
I always make sure to put #FILE and #CLOSE into my alias/triggers, but thats just personal preference. I dont like to leave open files laying about.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Jun 09, 2002 6:59 pm   
 
You are right dacheeba. I got confused because of the example in the help file - I didn't analyze it a bit more. However, you can't use %pop because that function does not exist in 6.16, only in the beta versions. So, the alias should be for 6.16:

#ALIAS ID {#VAR matches %grep(1, "%-1");#IF (!@matches) {#SAY No matches found.} {#IF (%numitems(@matches) > 5) {#SAY Too many matches.;#SAY Outputing first five matches:;#LOOP 1,5 {#SAY %item(@matches, %i)}} {say Items matching '%-1' are:;#FORALL @matches {say %i}}}}

Kjata
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Sun Jun 09, 2002 7:16 pm   
 
quote:

However, you can't use %pop because that function does not exist in 6.16, only in the beta versions.


Opps!

Hard to keep track of my versions :P
Reply with quote
nutsnbolts
Apprentice


Joined: 01 May 2002
Posts: 188
Location: USA

PostPosted: Mon Jun 10, 2002 4:26 pm   
 
Call me a monkey but How do you go about doing this with a trigger.

As of now, the ALIAS is ID

But how do I trigger it by

Anyname says, 'ID mask'



Thank you for everything, it's always appreciated.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Mon Jun 10, 2002 4:56 pm   
 
#TRIGGER {%w says, 'ID (*)'} {ID %1}

Kjata
Reply with quote
nutsnbolts
Apprentice


Joined: 01 May 2002
Posts: 188
Location: USA

PostPosted: Tue Jun 11, 2002 1:31 am   
 
Well this was a sucess. After toying with getting something into the database and then utilizing the databse to tranfer information from a db to the mud which did not work too well, this actually was a better way of doing things. Everything is working marvelously.

Thank you for everything, it's always appreciated.
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