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


Joined: 07 Jun 2009
Posts: 1

PostPosted: Sun Jun 07, 2009 9:24 am   

Assistance with Zmud script
 
So I have a setup I used previously in zmud that allowed me to view information from a .txt file when looking up equipment etc. With this alias I had a .txt file saved with all of the stats of my items (IE: jewelled broadsword L30, 8d4 (20), dam 3, hit 3, mithril, w18, Human Sergeant, Ruined Keep ) this is one of the items for example.
I would just type: item jewelled broadsword
and it would return anything in the file matching my query. If I typed sword it would return anything listed with sword in the name etc.
When I first set it up it looked like this (copy and paste from another user):

#ALIAS item {#file 2 NAME_OF_TXT;#var tmp_list %grep( 2, "%1*%2");#close 2;#loop 0,%numitems( @tmp_list) {#echo %item( @tmp_list, %i)};#unvar tmp_list;#GAG Opened NAME_OF_TXT as file 2;#GAG Closed NAME_OF_TXT on file 2;#GAG Variable tmp_list removed.}

This is the information I've managed to pull up. Now when I used the compatibility report all I have showing is to remove the " in %grep( 2, "%1*%2") so it looks like this %grep( 2, %1*%2) and I get no errors.

I just can't seem to get it to display anything at this point in time, and unfortunately since this isn't my code I only understand parts of what each of the commands are doing.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Jun 07, 2009 1:42 pm   
 
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="item" copy="yes">
    <value>#LOCAL ItemTmp
#CALL %pref("echomessage",0)
#FILE 2 NAME_OF_FILE_TO_OPEN
$ItemTmp=%grep( 2, %1*%2)
#CLOSE 2
#LOOP 0,%numitems($ItemTmp) {#echo  %item( $ItemTmp, %i)}
#CALL %pref("echomessage", 1)</value>
  </alias>
</cmud>


This works for me. The one thing you have to be careful about is the file name. If the file is not located in your session folder, you'll need to tell CMUD where to find it, and you can do that with:

#FILE 2 "C:\My Folder\Name of the file I want to open.txt"

Otherwise, if it's in your session folder, then you should be ok. As a side note, if it's in a folder within your session folder, then you can just do:

#FILE 2 "subfoldername/file to open.txt"

Either way, this works. Also, instead of unvariables, you should use local variables. :)

Charneus
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