Log In  

Cart #lib_utilinst-0 | 2024-03-17 | Embed ▽ | License: CC4-BY-NC-SA
2

This cartridge is a library cartridge intended to be used by some of my other cartridges. You can use it too, if you'd like. For utilities, it offers the one-button ability to permanently install or uninstall the files from your Picotron system drive. I use this to install new utilities to/from /appdata/system/util/, but you can install and uninstall files to any permanent storage location with it.

Once loaded, in /ram/cart/exports/, you will find main.lua. This can be copied into your project and included, or installed by my yotta dependency and package manager (released separately). This utility shim offers the following functions which you can either call in your init/draw/update lifecycle functions, or use to replace your lifecycle functions outright. I tend to do the latter.

Here is an example of an installable utility cart using this library, with some special initialization logic but standard draw/update handled by this library.

include "path/to/util_stub/main.lua"
function _init()
  util_init_installable()
  -- ... do other init stuff ...
end

_draw = util_draw
_update = util_update

If you are packaging a system utility or package, the util_init_installable function is used. This will create an installable/uninstallable package. For this to work, it expects a /ram/cart/exports/ directory which contains a root filesystem overlay. So, if you'd like to install a file to a specific location (like /appdata/system/util/new.lua), you would need to place new.lua at /ram/cart/exports/appdata/system/util/new.lua. Upon running the cartridge, it will detect if all its files are present or not on the system already, and will offer to install or uninstall the data from your system accordingly at a key or button press.

If you are packaging a code library not intended for installation, the util_init_library function is used in place of the util_init_installable function. The only major difference is that it does not offer to install/uninstall the package to the system.

An option to view the exports is always provided by the running cartridge using this library regardless of release type.

If you are using my yotta dependency and package manager (released separately), you can also use the BBS 'hash ID' (like the one used in the 'load' command) of any library-mode cartridge in this format to automatically add the library to your own cartridge's lib/ directory. See the details for this on the yotta utility release page.

P#143587 2024-03-17 23:24


[Please log in to post a comment]