In game code, calling ls()
only returns names of cart files.
To make it possible to write local game launchers and other mini-splores, it would be nice to have a way to get directories too (some of us are hoarders and have to organize carts).
Ideas:
ls() -- same as now ls(0x2) -- get directories only ls(0x3) -- (maybe) get other kinds of files -- (for art tools and such, to build dialogs instead of -i / stdin / drag n drop) -- or ls() -- unchanged lsdir() -- new -- will also need `cd(path)` to go there and list carts, or `ls(path)` |
Thanks for considering this!
If we're gonna talk about LS()
or DIR()
, @merwok, may I suggest it RETURN back into Pico-8, that it can be used inside code.
Current Pico-8 it does nothing now, and I've been on this site long enough to know that previous versions of Pico-8, it USED to work inside code. For some reason it was disabled.
As for your suggestions, I agree with you. It would be nice to navigate existing carts in this manner.
You can also type dir *
to view all files in a directory regardless of extension. Not great, but better than listing only directories and a handful of extensions.
getkstudio: please post useful messages
dw: don’t know what you’re saying, ls()
works in code in current version
It doesn't work here, @merwok. I know I posted my computer stats at one point. Running Windows 10. Literally one line of code in Pico-8:
ls() |
Does absolutely nothing here. Not even a carriage return.
Running Pico-8 version 0.2.4.
it does work it returns a table of the output.
ls() by itself doesn't work because it doesn't print anything
Run this in a new cart
a=ls() for i in all(a) do print(i) end |
Oh for goodness sakes ... I seem to remember, something about this @b0b89. Right outta my mind.
It probably comes from thinking of QBasic. It never had that. It had files
and files by itself would list everything in the directory.
Some QBasic games that didn't really wanna go the distance for showing a clean directory, would just do files "*.gam"
and stuff like that.
Let me try what you have here ...
Oh my gosh there it is. Huh ... So, yeah, we can make a file base program then ...
In fact the help file doesn't even list it. Searched for ls(
by itself and nothing came up.
And it =IS= ls
not dir
dir
works in immediate mode, but does nothing in code. dir
is more familiar to me, from DOS. ls
I knew was from UNIX so I just avoided it.
So many factors here that would never let me see that ls()
is not a verb in code but a noun. It does no action by itself, but it =DOES= contain data.
Thanks for showing me this, @b0b89. Without that - I never would've solved this - especially since I can't even find it in the HELP file.
Committing this to memory and my notes ...
Yea it's pretty weird it appears to be undocumented. I never would have thought to try it if you didn't mention it. I first did print(ls()) and it said "[table]"
glad to have helped
You’re right, it’s not in the manual, but in the changelog!
https://www.lexaloffle.com/dl/docs/pico-8_changelog.txt
Trouble in paradise. You cannot use any arguments with ls()
So you cannot, for instance, use ls("..")
or what have you.
And no, cd
for change directory does not work at all. So ... to the best of my knowledge it's not possible to make an effective filer program in Pico-8 where you can change directories, see all extensions, and examine files.
This is the best I can do. So, yep, 2nd your request, @merwok.
I like the idea! (not that I’d end up using it much other than a small thought in my head)
I’ve also thought up (while we’re at it) being able to launch SPLORE from carts. Or at least getting a handful of cart IDs from it (custom splore!)
But yeah ls()
and cd()
first
an extcmd for splore is requested here: https://www.lexaloffle.com/bbs/?tid=44591
ah, okay. Thanks! sorry about the semi-hijack prolly could've hidden it
Still hope this suggestion goes through!
Hi @merwok
This has been added for 0.2.4d. For security reasons, it can only run locally, and resolves only inside PICO-8's drive. From the manual:
LS([DIRECTORY]) List .p8 and .p8.png files in given directory (folder), relative to the current directory. Items that are directories end in a slash (e.g. "foo/"). When called from a running cartridge, LS can only be used locally and returns a table of the results. When called from a BBS cart, LS returns nil. Directories can only resolve inside of PICO-8's virtual drive; LS("..") from the root directory will resolve to the root directory. |
fyi @zep ls subdir
and ls("subdir")
work in the command prompt, but ls(subdir)
segfaults
[Please log in to post a comment]