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

Can't use paintutils from a diskette

Started by Windows10User, 07 April 2018 - 10:37 AM
Windows10User #1
Posted 07 April 2018 - 12:37 PM
Even though I have barely started with my OS, I want to have a setup program (on a diskette for the start) right away. So, I started with the good ol' GUI setup program. When I do paintutils.loadImage() on my image (disk/bkg.npf), seems to do "paintutils.lua:38: attempt to call nil" from the Lua prompt. From my disk/startup.lua, it does "startup.lua:4: bad argument #1 (expected table, got nil). Is there a reason for this happening?

Unfinished setup program:

local image = paintutils.loadImage("bkg.npf")

local function clearScreen()
	paintutils.drawImage(image, 1, 1)	
end

clearScreen() --draw the screen for the first time


bkg.npf (from the edit perspective):
Spoilerbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
b0000000000000000000000000000000000000000000000000b
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
Jummit #2
Posted 07 April 2018 - 01:11 PM
You have your image is on the disk, why are you using the path "bkg.npf" instead of "disk/bkg.nfp"?
Edited on 07 April 2018 - 11:13 AM
Bomb Bloke #3
Posted 07 April 2018 - 01:11 PM
Paintutils (like most APIs in ComputerCraft) uses absolute paths: "bkg.npf" isn't the same thing as "disk/bkg.npf". If the file can't be found, paintutils.loadImage() returns nil (as opposed to a table with image data in it), which leads to your "bad argument" error on line 4. Functions such as shell.dir() / shell.resolve() / shell.getRunningProgram() are useful for translating relative paths to absolute ones.

The error on line 38 within the paintutils API is a ComputerCraft bug - you'll need to install a more recent copy in order to resolve that. Check here or here.