Slash in parenthesis [SOLVED]

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
test
Prole
Posts: 28
Joined: Sun Apr 14, 2019 2:36 pm

Slash in parenthesis [SOLVED]

Post by test »

Code: Select all

for i = 1, 4 do img[i] = love.graphics.newImage('1' .. '/' .. i .. '.png') end
I want to open the i.png in the folder which is named '1'. How can I achieve this? Thanks.
Last edited by test on Fri May 17, 2019 9:56 am, edited 1 time in total.
User avatar
steVeRoll
Party member
Posts: 131
Joined: Sun Feb 14, 2016 1:13 pm

Re: Slash in parenthesis

Post by steVeRoll »

I don't see anything wrong with the code you posted. Other than the useless concatenation of '1' and '/'.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Slash in parenthesis

Post by raidho36 »

If you want to open "1/i.png" you should do just that.

Code: Select all

newImage ( "1/i.png" )
In the code you posted, the string is produced out of whatever was in variable "i", which is numbers 1 through 4, so it would load "1/1.png", "1/2.png", "1/3.png" and "1/4.png".
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 52 guests