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
Mostly Harmless
Newbie


Joined: 28 May 2004
Posts: 2
Location: USA

PostPosted: Sun Jul 11, 2004 7:59 pm   

Multistate triggers & file read/write
 
Basically what I'm trying to do is capture the output of an object identity spell to a file so that I can read it back. I'm trying to avoid databases at all costs (because they scare me), but I don't know if I can. Here are a few lines from the MUD:

(624/624hp 1208/1208m 688/688mv 7481tnl 11 PM) comm iden ring
You furrow your brow as you look through your possessions.
----------------------------------------
This object, the Black King's scepter can be referred to as 'black scepter'.
It is worth 10000 copper, and is of the 45th level of power.
It is made of adamantite and weighs 14 pounds 15 ounces.
It radiates light.
It has been imbued with a blessing.
It is unusable for those of a pure soul.
It can cause 13d3 points of damage, at average 26.
When worn, it affects your mana by 20 points, your hp by 20 points,
your damage roll by 5 points and your hit roll by 5 points.

(624/624hp 1196/1208m 688/688mv 7481tnl 12 AM)



Anyway, I have the following trigger, which works fine in capturing the output I want to a variable:

#TRIGGER IdenTrig {This object, (*) can be referred to as (*)} {#VAR IdItem {%1};#TEMP {^$} {#STATE IdenTrig 0}}
#COND {} {#ADDITEM IdItem %line} {LoopLines|Param=99}


Now, I changed that trigger to look a little something like:

#TRIGGER IdenTrig {This object, (*) can be referred to as (*)} {#VAR IdItem {%1};#TEMP {^$} {#STATE IdenTrig 0;#FILE 2 "itemid.txt";#WRITE 2 {@IdItem};#CLOSE 2}}
#COND {} {#ADDITEM IdItem %line} {LoopLines|Param=99}


And it writes to a file no problem, except, instead of writing it the way the mud displays it, it separates each line with a pipe (|). I want to know if there's a way to write to the file as the mud displays eat, that is, each line separately. Then, I'd like to be able to read from the file (grep, perhaps?) and display the results, something in the way of typing item black scepter or some such thing. I was thinking of using sequential files or something, but I don't know. Any help would be hugely appreciated. Thanks in advance.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Jul 12, 2004 12:59 am   
 
Just write each line directly to the file without using a variable first.
#TR IdenTrig {(This object, * can be referred to as *)} {#FILE 2 "itemid.txt";#WRITE 2 {%1};#TEMP {^$} {#STATE IdenTrig 0;#CLOSE 2}}
#COND {(*)} {#WRITE 2 {%1}} {LoopLines|Param=99}


I can't imagine why you think it will be easier to write your own search and retrieval routines instead of using the built-in database.
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