Log In  

There are not too many string-handling libraries I have come across in Pico-8. And for visual text this is not too surprising considering the small-size of the screen. :)

However, the point of this cart is to demonstrate a few things. One of which is that it is indeed possible to load a text ".txt" file inside your program. Now unfortunately the TXT file's contents cannot be changed once loaded. Like if you made a loop to view the contents each time.

But this does free you to use any other editor like NOTEPAD to prepare text data inside it.

For instance, you will need this. Highlight all of it, press CTRL-C. Bring up NOTEPAD. Press CTRL-V. Then save it on your HD as YUKON.TXT in a place you normally save your PICO-8 carts.


Day had broken cold and grey, exceedingly cold and grey, when the man turned aside from the main Yukon trail.
It was a steep bank, and he paused for breath at the top, excusing the act to himself by looking at his watch.
It was nine o'clock.
There was no sun nor hint of sun, though there was not a cloud in the sky.
It was a clear day, and yet there seemed an intangible pall over the face of things, a subtle gloom.
This fact did not worry the man.
He was used to the lack of sun.
It had been days since he had seen the sun, and he knew that a few more days must pass before that cheerful orb.
The man flung a look back along the way he had come.
The Yukon lay a mile wide and hidden under three feet of ice.


Notice it has correct uppercase and lowercase letters. If you want to make your own text file to use the libraries in this cart be certain to make your TXT file exactly the same way. With a variable "=" "[[" a skipped line, the data, another skipped line, and "]]" to finish followed by a carriage-return.

Cart #textlib-1 | 2019-09-12 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Alright, now load up this cart direct in PICO-8's editor.

load #textlib-1

The reason is this cart will NOT run either in Lexaloffle BBS or even compiled as an EXE - unless you have the TXT file alongside the EXE. And that could be a problem that needs to be resolved by ZEP. In any case, this =WILL= work in the editor once again provided you have the TXT file separate.

Now once you have the cart loaded, change to the directory where your TXT file is and SAVE your program right then in the same directory. Any name will do, but it must be saved in the same directory as the TXT file so PICO will know where to find it.

You will receive a warning that, "COULD NOT #INCLUDE FILE: YUKON.TXT" even though it's right there, but the file will have saved properly.

NOW IT WILL RUN. Run the cart.

Notice I am using a new function called PRINTS(). The reason is PICO-8 messes up the display if you use PRINT for any string that has \10 (CR) in it, and PICO-8 also has no internal word-wrap for strings. You must instead print out each character manually and handle CRs through code.

The advantage here also is now you can change the TXT file anytime you want and the results are immediately seen in your cart without the need to save it each time.

And that's it ! If you have any questions or difficulties, please let me know.

I hope you find this library useful for all of your import and string-handling needs.

P#67593 2019-09-12 18:23 ( Edited 2019-09-12 18:39)

thinking about using this for bootlegging a super help where you do help("functionname",#help_page#) and it brings up information about that so you dont have to go on the wiki

P#80340 2020-08-04 13:12

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-08-08 09:25 | 0.017s | 4194k | Q:29