While poking around in Picotron, I found myself wanting to view the contents of a file without opening it in the editor (via the edit command), so I wrote a little cat function. In order to implement it I needed to grab the current working directory so I went ahead and implemented a pwd command as well. Both of these are very simple and really just wrap existing Picotron functions for ease of use in the command line.
-=cat=-
local argv = env().argv local foldr = env().path if #argv < 1 or #argv > 1 then print("usage: cat filename") else local f = foldr.."/"..argv[1] print(fetch(f)) end |
-=pwd=-
local foldr = env().path print(foldr) |
To implement these, just save each in it's own project in the /appdata/system/util folder, using the name of each command as the filename- so copy the code for cat into 'main.lua' and cd into /appdata/system/util and type save cat
. Same goes for pwd. Once you do this, you can run them straight from the Picotron command line.
Hope these are helpful to someone else :). Thanks to @Hessery and @scrapSavage for introducing me to the fetch function!
pwd()
is actually built-in!
You can give it a go in the terminal with ?pwd()
or in any cartridge.
Ah, so it is! And printing output with ? is a great timesaver! I totally forgot about that in Pico-8. Thanks for that and for the heads up :)
Yep!
Not to mention (though it is nice to have a shortcut, like in your case) cat
can be achieved with
?fetch("file")
[Please log in to post a comment]