Jump to content




Can't use paintutils from a diskette

media help lua

2 replies to this topic

Poll: My OS!

Should I make it?

You cannot see the results of the poll until you have voted. Please login and cast your vote to see the results of this poll.
Vote Guests cannot vote

#1 Windows10User

  • Members
  • 62 posts
  • LocationC:\Minecraft\saves\stuff\computer

Posted 07 April 2018 - 11:37 AM

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):
Spoiler


#2 Jummit

  • Members
  • 306 posts
  • LocationJulfander Squad Studio

Posted 07 April 2018 - 12:11 PM

You have your image is on the disk, why are you using the path "bkg.npf" instead of "disk/bkg.nfp"?

Edited by Jummit, 07 April 2018 - 12:13 PM.


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 07 April 2018 - 12: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users