Jump to content




paintutils.drawImage not working


11 replies to this topic

#1 Ghifari160

  • Members
  • 4 posts

Posted 15 March 2014 - 09:21 PM

For some reason, paintutils.drawImage is not working for me. I already put the right path but it still returning error.

local version = "1.0"
local url = "" --Update URL
img = paintutils.loadImage("/background.nfp") -- Background Image

--function init()

--end

paintutils.drawImage(img, 1, 1)


#2 CometWolf

  • Members
  • 1,283 posts

Posted 15 March 2014 - 10:53 PM

I swear, there's one of these every day lol. Your image does not exist, or is an invalid format.

#3 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 16 March 2014 - 12:02 AM

What's the error?

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 March 2014 - 02:11 AM

View PostCometWolf, on 15 March 2014 - 10:53 PM, said:

I swear, there's one of these every day lol.
I can't wait for CC 1.6 and a large amount of people to update to it, I asked dan a few weeks ago to add throwbacks to the error calls in all the APIs and he did, so finally there will be less 'problems' with APIs and more problems with peoples scripts which they'll realise and fix. fingers crossed again.

Edited by theoriginalbit, 16 March 2014 - 02:16 AM.


#5 Ghifari160

  • Members
  • 4 posts

Posted 22 March 2014 - 11:55 PM

I swear i already write there's everything that I need in there! Image in the right path and right format. I tried everything.

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 23 March 2014 - 01:28 AM

What's the error? Clearly, not everything is correct, so at least help us narrow down what's wrong.

#7 Dayrider10

  • Members
  • 32 posts

Posted 23 March 2014 - 01:34 AM

Please tell us the error. As a suggestion you could try to move the "/background.nfp" to just "background.nfp".

#8 CometWolf

  • Members
  • 1,283 posts

Posted 23 March 2014 - 01:57 AM

View PostDayrider10, on 23 March 2014 - 01:34 AM, said:

Please tell us the error. As a suggestion you could try to move the "/background.nfp" to just "background.nfp".
Removing the slash is considered worse, though either way works.

Last time someone had an issue with paintutils images, i suggested the following

View PostCometWolf, on 14 March 2014 - 07:29 AM, said:

local paintutils = setmetatable(
  {
	loadImage = function(path)
	  assert(fs.exists(path),"Attempted to load non-existent image file "..path)
	  local image = _G.paintutils.loadImage(path)
	  assert(image,"Attempted to load non image file "..path)
	  return image
	end
  },
  {
	__index = _G.paintutils
  }
)
Putting that at the top of your code should give you some clearer error messages. Provided the issue is the image file.

#9 Dayrider10

  • Members
  • 32 posts

Posted 23 March 2014 - 02:15 AM

View PostCometWolf, on 23 March 2014 - 01:57 AM, said:

View PostDayrider10, on 23 March 2014 - 01:34 AM, said:

Please tell us the error. As a suggestion you could try to move the "/background.nfp" to just "background.nfp".
Removing the slash is considered worse, though either way works.

Last time someone had an issue with paintutils images, i suggested the following

View PostCometWolf, on 14 March 2014 - 07:29 AM, said:

local paintutils = setmetatable(
  {
	loadImage = function(path)
	  assert(fs.exists(path),"Attempted to load non-existent image file "..path)
	  local image = _G.paintutils.loadImage(path)
	  assert(image,"Attempted to load non image file "..path)
	  return image
	end
  },
  {
	__index = _G.paintutils
  }
)
Putting that at the top of your code should give you some clearer error messages. Provided the issue is the image file.

Thanks for letting me know. I thought it was better to do that. Maybe I will have to change my code to fix that up. Thanks. As for this I can't really tell you. Try to make the file a normal paint file with the default paint instead of .nfp. Like this
    bgimg = paintutils.loadImage("background")
    paintutils.drawImage(bgimg ,1 ,1)


#10 Ghifari160

  • Members
  • 4 posts

Posted 29 March 2014 - 12:05 AM

View PostCometWolf, on 23 March 2014 - 01:57 AM, said:

View PostDayrider10, on 23 March 2014 - 01:34 AM, said:

Please tell us the error. As a suggestion you could try to move the "/background.nfp" to just "background.nfp".
Removing the slash is considered worse, though either way works.

Last time someone had an issue with paintutils images, i suggested the following

View PostCometWolf, on 14 March 2014 - 07:29 AM, said:

local paintutils = setmetatable(
  {
	loadImage = function(path)
	  assert(fs.exists(path),"Attempted to load non-existent image file "..path)
	  local image = _G.paintutils.loadImage(path)
	  assert(image,"Attempted to load non image file "..path)
	  return image
	end
  },
  {
	__index = _G.paintutils
  }
)
Putting that at the top of your code should give you some clearer error messages. Provided the issue is the image file.
I tried the same thing, but it still doesn't work for me. It says the image is not there, but I put the image there.
local paintutils = setmetatable(
  {
    loadImage = function(path)
      assert(fs.exists(path), "Attempted to load non-existent image file"..path)
      local image = _G.paintutils.loadImage(path)
      assert(image,"Attempted to load non image file"..path)
      return image
    end
  },
  {
    __index = _G.paintutils
  }
)

local version = "1.0 BETA"
local updateUrl = ""
local img = paintutils.loadImage("test")


function init()
   paintutils.drawImage(img, 1, 1) 
end

init()


#11 CometWolf

  • Members
  • 1,283 posts

Posted 29 March 2014 - 12:25 AM

Your picture file is in the computer root folder and called "test", correct?

Edited by CometWolf, 29 March 2014 - 12:27 AM.


#12 Ghifari160

  • Members
  • 4 posts

Posted 29 March 2014 - 08:25 PM

View PostCometWolf, on 29 March 2014 - 12:25 AM, said:

Your picture file is in the computer root folder and called "test", correct?
found the problem. It's fixed now.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users