ID:2270870
 
(See the best response by Nadrew.)
Code:
mob/verb/list_directory()
shell("cd > dir.txt")
usr << file2text("dir.txt")


Problem description:

It should in theory just output the current directory of the world, but it does nothing. Not sure if shell() uses the world directory by default though, documentation isn't helpful at all.
Best response
Depends on whether you're on Windows or Linux, on Linux the 'cd' command doesn't output anything ('pwd' is what you'd want on Linux). On Windows it does.

Is 'dir.txt' being created at all? If the world is running in trusted mode, you should check in your C:\ directory for it, if it's there you may want to do something like

shell("cd > ./dir.txt")


To see if that helps, I don't work a lot in the Windows command-line these days.
No luck sadly. The file is never made as far as I can tell. It is running in Trusted. Checked C:\, C:\Windows\, the directory the world us running in, BYOND install folder.

Is there any other way to get the current world directory?

EDIT: Tried making the file in the world directory first, still no luck.
Workaround found in the end.
shell("cmd /C cd > dir.txt")

Imperfect but this is merely a test tool so the brief CMD window that pops up is fine for the most part.