Log In  

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!

P#104923 2022-01-12 22:32

what

P#104928 2022-01-12 23:17

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.

P#104931 2022-01-12 23:36 ( Edited 2022-01-12 23:37)
1

getkstudio: please post useful messages

dw: don’t know what you’re saying, ls() works in code in current version

P#104951 2022-01-13 03:00

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.

P#104974 2022-01-13 04:39 ( Edited 2022-01-13 04:40)
2

@dw817

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
P#104975 2022-01-13 05:09 ( Edited 2022-01-13 05:10)

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 ...

P#104976 2022-01-13 05:31 ( Edited 2022-01-13 05:34)

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

P#104980 2022-01-13 06:39

You’re right, it’s not in the manual, but in the changelog!
https://www.lexaloffle.com/dl/docs/pico-8_changelog.txt

P#105001 2022-01-13 16:59

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.

P#105033 2022-01-13 20:46 ( Edited 2022-01-13 21:14)

Hence this request!

P#105051 2022-01-14 02:47

This is the best I can do. So, yep, 2nd your request, @merwok.

https://www.lexaloffle.com/bbs/?tid=46159

P#105052 2022-01-14 02:49
1

Reminded me of this.

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

P#111324 2022-05-05 12:59

an extcmd for splore is requested here: https://www.lexaloffle.com/bbs/?tid=44591

P#111334 2022-05-05 14:35

ah, okay. Thanks! sorry about the semi-hijack prolly could've hidden it

Still hope this suggestion goes through!

P#111338 2022-05-05 15:48
5

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.
P#111371 2022-05-06 03:49

nice

thank you!

P#111377 2022-05-06 09:44

fyi @zep ls subdir and ls("subdir") work in the command prompt, but ls(subdir) segfaults

P#112719 2022-06-04 10:28 ( Edited 2022-06-04 10:28)

oh, this is for next version!

P#113769 2022-06-28 17:04

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2022-11-30 07:59:37 | 0.037s | Q:36