This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
coranos's profile picture

distributing programs with peripherals

Started by coranos, 21 December 2012 - 01:17 PM
coranos #1
Posted 21 December 2012 - 02:17 PM
hi,
I made a new peripheral that can read images and convert them into wool creations (statues of player skins, or just pictures of other images)

How can I bundle the programs with my peripheral?

I tried adding a folder called lua/rom into my mod but it didn't do anything.

Also, any idea why the peripheral icon is only 8x8 or so?

I've attached the mod, full source included
Video of the previous version of the mod here:
[media]http://www.youtube.com/watch?v=-8y6mNHTPmo[/media]
coranos #2
Posted 21 December 2012 - 04:31 PM
The current version of the mod also has a mini ee-style alchemy in it, so I don't have to restock the wool after every line.
Xfel #3
Posted 21 December 2012 - 10:39 PM
It's not possible in an easy way. You could mount the files when the peripehral gets attached, but that creates countless complications. You could also copy them to the mods/ComputerCraft/lua/rom directory on mod load.
GopherAtl #4
Posted 25 December 2012 - 09:31 AM
It took me a fair amount of mucking about to get mounting files with the peripheral to work, but eventually I did. The basic process I settled on:

-On mod load, export the lua files from my mod's zip to a fixed directory. Normal file routines don't seem to like paths into zip files, but I was able to do through the main mod class, in my case BioLock, using BioLock.class.getClassLoader().getResourceAsStream(luaFilePath). Then I just copied from this stream to an output stream with the desired path.
-on peripheral attach, through the IComputerAccess object, with "computer.mountFixedDir("rom/programs/biolock", sourcePath, true, 0);"
If you're not using the new beta of the CC API (linked in the first post of the beta 1.48 thread in the beta subforum), you'll still see a form of mountFixedDir that doesn't require the 4th parameter, which is a maximum size for the mounted directory, but that function has been removed, so you have to call the 4-argument version. Despite the name, mountFixedDir will mount a single file, not just a directory.

It might be marginally easier to just extract directly to ComputerCraft/lua/rom, but personally I prefer having the files appear only on the computers that mount the peripheral rather than on all computers. If you are adding an API which needs to be loaded, you might want to go ahead and put it in rom for all computers, otherwise you would have to reboot the computer for the API to load after attaching the peripheral.
coranos #5
Posted 26 December 2012 - 04:58 PM
I Followed your suggestion, and used the following command:
computer.mountFixedDir("bmt", "mods/CCReadImage.lua/rom/bmt", true, 0);

that added the program "bmt" to the root dir, but only for my peripheral.

I wish there was a way of mounting the files from within the zip, rather extracting them to the mods directory.
Cloudy #6
Posted 27 December 2012 - 08:39 AM
That is planned!
coranos #7
Posted 27 December 2012 - 04:30 PM
thanks! btw cloudy, do you know who can assign me a peripheral ID?
The wiki page is locked.

whoops, replied to the wrong thread. meant to reply to my thread in peripherals
Cloudy #8
Posted 27 December 2012 - 11:49 PM
Request wiki edit access in the subforum, then you can edit it yourself!