Help with using/loading an image

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
skiippii
Prole
Posts: 1
Joined: Sun Jun 26, 2016 7:25 pm

Help with using/loading an image

Post by skiippii »

Hi, I am a new LOVE user and I've been sat around for the past hour trying to figure out how to set the directory at which my main.lua will find a file on my computer.

Code: Select all

local imageFile

function love.load()
	imageFile = love.graphics.newImage("wom.png")
	
end
function love.draw()
    love.graphics.draw(imageFile)
end
^ is my current code, however when I run thisI get error " main.lua:10: Could not open file wom.png. Does not exist."
I have seen people before say that the image needs to be in the same directory as the main.lua file
https://love2d.org/imgmirrur/JwncWtP.png

I don't understand why the image won't load up, any tips?
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Help with using/loading an image

Post by pgimeno »

What is line 10 in your file? The snippet you've pasted has 9 lines.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Help with using/loading an image

Post by Nixola »

The image is called "wom.png.png". Thank Windows for hiding files extensions, letting people into this kind of mistakes and into scams. Rename the file to "wom" and you should be fine, but I'd suggest you to search how to see files extensions.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Help with using/loading an image

Post by s-ol »

Nixola wrote:The image is called "wom.png.png". Thank Windows for hiding files extensions, letting people into this kind of mistakes and into scams. Rename the file to "wom" and you should be fine, but I'd suggest you to search how to see files extensions.
folder options > uncheck "hide known extensions". That and "hide system files" are the first two things I do on ANY windows system I get my hands on.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Help with using/loading an image

Post by zorg »

skiippii wrote:Hi, I am a new LOVE user and I've been sat around for the past hour trying to figure out how to set the directory at which my main.lua will find a file on my computer.
Just to clarify, you can't really do that though; you have two "root" folders, the project folder, where your main.lua is, and the save folder where you can create/modify files and folders. The former can be anywhere, the latter has specific locations depending on operating system and whether the game is fused or not.

That said, what the others said above should fix your issue.

s-ol wrote:
Nixola wrote:The image is called "wom.png.png". Thank Windows for hiding files extensions, letting people into this kind of mistakes and into scams. Rename the file to "wom" and you should be fine, but I'd suggest you to search how to see files extensions.
folder options > uncheck "hide known extensions". That and "hide system files" are the first two things I do on ANY windows system I get my hands on.
I go a few steps further and disable UAC, then do a forced takeown(ership) of the root drive and all files so that i can freely delete stuff that i know i don't want running; poweruser :3[/size]
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Help with using/loading an image

Post by Nixola »

I go one step further and don't use it but I'm getting off topic now.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest