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 » Fri May 10, 2019 4:05 pm

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.

steVeRoll
Party member
Posts: 102
Joined: Sun Feb 14, 2016 1:13 pm

Re: Slash in parenthesis

Post by steVeRoll » Fri May 10, 2019 5:31 pm

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: 1919
Joined: Mon Jun 17, 2013 12:00 pm

Re: Slash in parenthesis

Post by raidho36 » Fri May 10, 2019 9:18 pm

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: No registered users and 16 guests