[never mind] MY LEVEL EDITOR NOT WORKING!!!!11!!

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
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

[never mind] MY LEVEL EDITOR NOT WORKING!!!!11!!

Post by Tesselode »

On the first screen, you can enter a filename for the level. If it doesn't exist, it starts you off with a blank canvas, and you can click on squares in the grid to fill them in (and right click to delete them). When you close the program, it saves the level. This is all working fine. However, it's supposed to load the file if you specify one that already exists. That isn't working.

I have a print function that indicates that it is, indeed, loading the level properly. I think the problem is either in the loading code:

Code: Select all

b=0
for a=1,40 do block[a]={} end
	for line in love.filesystem.lines(filename) do
		b=b+1
		for a=1,40 do
			block[a][b]=line:sub(a,a)
		end
	end
end
or the drawing code:

Code: Select all

for a=1,40 do
	for b=1,30 do
		if block[a][b]==1 then love.graphics.setColor(100,100,100,255)
		elseif block[a][b]==2 then love.graphics.setColor(0,100,0,255) end
		if not (block[a][b]==0) then love.graphics.rectangle("fill",(a-1)*16,(b-1)*16,16,16) end
	end
end
Edit: Crud I forgot the .love file.

Edit 2: Figured out the problem. I should have converted the strings to numbers when loading the file.
Attachments
editor.love
(2.53 KiB) Downloaded 83 times
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 54 guests