 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sun Oct 27, 2002 4:19 am
Building a personal MUDputer |
As I acquire more info about the mud I play on, I've come to realize it would be very cool if I could have it at my fingertips without having to use Task Manager to flip between Zmud and other programs like Notepad or Explorer. Therefore, I'm building up a child window called Computer (later on, I suppose I'll rename it to something a bit snazzier) and modeling the interface much along the lines of DOS. It will/does have the ability to maintain a customizable file system, a help system, and all the other goodies that allow one to navigate and negotiate the DOS terrain.
In one of the aliases (the DIR function), though, I've run into a bit of a snag:
Variable: FileSystem
Commands = "help|mkdir|go|clear"
CurrentDirectory = ""
DirList = "a|b|c|d"
a = "e|f|g|h"
b = ""
c = ""
d = ""
Alias: Dir
Code:
#say ""
#if (@filesystem.currentdirectory = "")
{
#if (%numitems( %db( @FileSystem, @Filesystem.dirlist)))
{
#loop 1,%numitems( %db( @FileSystem, @Filesystem.dirlist))
{
#if (!%mod( %i, 5) or (%i = %numitems( %db( @FileSystem, @Filesystem.dirlist))))
{
#say ~[%item( %db( @FileSystem, @Filesystem.dirlist), %i)~]" "
}
{
#sayprompt ~[%item( %db( @FileSystem, @Filesystem.dirlist), %i)~]" "
}
}
}
{
#say No directories to list
}
}
{
#if (%numitems( %db( @FileSystem, @Filesystem.currentdirectory)))
{
#loop 1,%numitems( %db( @FileSystem, @Filesystem.currentdirectory))
{
#if (!%mod( %i, 5) or (%i = %numitems( %db( @FileSystem, @Filesystem.currentdirectory))))
{
#say ~[%item( %db( @FileSystem, @Filesystem.currentdirectory), %i)~]" "
}
{
#sayprompt ~[%item( %db( @FileSystem, @Filesystem.currentdirectory), %i)~]" "
}
}
}
{
#say No directories to list
}
}
#sayprompt %ansi( green, bold)>
This alias is supposed to verify the contents of @FileSystem.CurrentDirectory. If it's not empty (""), then it uses that variable to step through the stringlist contained in the db key pointed to by CurrentDirectory (ie, if CurrentDirectory = "a", then the alias will use the @FileSystem.A key to build the directory list). If CurrentDirectory is empty, then the root directory needs to be listed by stepping through the DirList key.
Output is supposed to look like this, but all I get is the latter form no matter what CurrentDirectory is set to:
CurrentDirectory = ""
>go
[a] [b] [c] [d]
>
CurrentDirectory <> ""
>go a
[e] [f] [g] [h]
>
GO is similar to the CD command, but I modeled it after a small replacement utility I found long ago that allowed one to jump to any directory in existence on your computer. Aside from user input, it's the only settings entity calling the DIR alias. It looks like this:
#sayprompt %ansi( yellow)~go %-1
#if (%null( %-1)) {
Filesystem.currentdirectory = ""
dir
} {#if (%-1 = @Filesystem.currentdirectory) {
#say ""
#say already in current directory
#sayprompt %ansi( green, bold)>
} {#if (%ismember( %-1, @Filesystem.dirlist)) {
Filesystem.currentdirectory = %-1
dir
} {
#say ""
#say Directory not found
#sayprompt %ansi( green, bold)>
}}}
Anyone see anything I'm missing? Tips of any kind are welcome, too .
li'l shmoe of Dragon's Gate MUD |
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Oct 27, 2002 5:49 am |
%db( @FileSystem, @Filesystem.dirlist)
should be
%db( @FileSystem, dirlist)
That's the only thing I found so far.
LightBulb
Senior Member |
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Sun Oct 27, 2002 10:07 am |
After reading your post six times I finally understood what the problem is. Lightbulb nailed it, what occurs is your current form
%db( @FileSystem, @Filesystem.dirlist)
expands to
%db( @FileSystem, a|b|c|d)
then because having a list for a key does not work the %db function truncates to
%db( @FileSystem, a)
This seems a bug in zMud as it should give null output on the error, but I suspect that behind the scenes the %db converts to the @var.key format and sends that to the parser expansion routine which is what is ignoring the invalid potion starting at the first |. |
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sun Oct 27, 2002 3:32 pm |
quote:
After reading your post six times I finally understood what the problem is. Lightbulb nailed it, what occurs is your current form
%db( @FileSystem, @Filesystem.dirlist)
expands to
%db( @FileSystem, a|b|c|d)
then because having a list for a key does not work the %db function truncates to
%db( @FileSystem, a)
This seems a bug in zMud as it should give null output on the error, but I suspect that behind the scenes the %db converts to the @var.key format and sends that to the parser expansion routine which is what is ignoring the invalid potion starting at the first |.
Ooh, didn't realize how fried my brain was at the time...hey, wait. Woohoo! Vacation, here I come!
li'l shmoe of Dragon's Gate MUD |
|
|
 |
|
|
|
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
|
|