Description Wardrobe and Scripting

Posted by Balerion on Mon 05 Jan 2004 12:52 PM — 3 posts, 14,005 views.

#0
Hello,

Until recently, I've stored character descriptions on my character object (PennMUSH system) and changed them as needed using some code I made. However, I'd prefer to be able to have the descriptions off-line rather than leading to <Output flushed> messages when I examine myself.

The system I currently use is involves storing the descriptions in attributes named <Name of Character>_Body## and so on, where <Name...> is the name of a character; sometimes I switch to other names to play other roles temporarily, so I have descriptions for those characters. My @desc contains a function that will look at three attributes (BODY, CLOTHES, EXTRA), where I store the name of the piece of desc I want (i.e., BODY: BODY01; CLOTHES: PANTS02; EXTRA: INSPECT01), and then grab them from me depending on my present name and which of the three I use (Sometimes I only use one part, more usually two, and sometimes three; and I suppose if it's possible having an unlimited number of variables would be best).

It seems to me that scripts might offer a solution.

Can scripts in MUSHclient pull data from plain text files (rather than databases), with minimal formatting so that it can parse them? I was thinking something like having a file for each character name, such as John_Doe Descs.txt. Then the descriptions for that character might be stored in a format like:

BODY01
<Description>
-
BODY02
<Description>
-
etc.

When I change desc, the script will recognize the name I currently have and pull from the appropriate file, setting each part of the desc into an attribute of the kind DESC_BODY, DESC_CLOTHES, etc.

Which script system would be best suited for this, and are there any scripts already made that already do some of the things I'm looking for?

Thanks.
USA #1
Well the good news it yes. ;) There are I believe two ways. One option is (straight from the docs):

Sub ReadFiles
   Dim fso, f1, ts, s
   Const ForReading = 1
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f1 = fso.CreateTextFile("c:\testfile.txt", True)
   ' Write a line.
   Response.Write "Writing file <br>"
   f1.WriteLine "Hello World"
   f1.WriteBlankLines(1)
   f1.Close
   ' Read the contents of the file.
   Response.Write "Reading file <br>"
   Set ts = fso.OpenTextFile("c:\testfile.txt", ForReading)
   s = ts.ReadLine
   Response.Write "File contents = '" & s & "'"
   ts.Close
End Sub

This shows the general method of writing to and reading from a text file.

The second option is ironically using the Microsoft.Jet database system. It is equipped with a text parsing engine, since some simple databases exported data in that format, instead of the more managable binary forms. Either way you end up using CreateObject.
Australia Forum Administrator #2
MUSHclient supports an unlimited number of variables (within reason, eg. memory).

A simple approach would be to use the naming system you mention, but just store the descriptions in a variable (per name). Then it is just a case of doing world.GetVariable ("name") and sending that to the MUSH.

You can inspect the variables in the variable configuration window, and alter them when you want.