Page 1 of 1

Syntax Error

Posted: Sun Feb 21, 2021 12:05 pm
by FiFolker
Hi, I developed a small map editor to practice and everything worked pretty well, I wanted to implement the possibility of saving in . lua, so I only touched the code of the main.lua (I use 2 files, main.lua and map.lua) I didn’t touch the map.lua while I was implementing the code. While trying to launch the program again, he put an error in the map.lua when I did not touch it. Here is the error I have as well as the map.lua code and a part of main.lua

Code: Select all

Error

Syntax error: map.lua:1: unexpected symbol near '<eof>'



Traceback

[C]: at 0x7ffb780428f0
[C]: in function 'require'
main.lua:3: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
map.lua =

Code: Select all

map = {}

function drawMap()
	love.graphics.setColor(0.5, 0.5, 0.5, 0.4)
	love.graphics.rectangle("fill", caseX, caseY, TILESIZE, TILESIZE)
	for l=1, map.height do
		for c=1, map.width do
			local id = map.grid[l][c]
			if id ~= 0 then 
				if id == 1 then
					love.graphics.setColor(1, 0, 0, 0.4)
					love.graphics.rectangle("fill", (c-1)*TILESIZE, (l-1)*TILESIZE, TILESIZE, TILESIZE)
				end
			end
			if opt.showMap == true then
				love.graphics.setColor(0, 0, 0, 1)
				love.graphics.print(tostring(id), (c-1)*TILESIZE, (l-1)*TILESIZE)
			end
			love.graphics.setColor(0, 0, 0, 0.4)
			love.graphics.rectangle("line", (c-1)*TILESIZE, (l-1)*TILESIZE, TILESIZE, TILESIZE)
		end
	end
end

function initMap()
	--imgMap = love.graphics.newImage()
	map.height = 19
	map.width = 25
	map.x = 0
	map.y = 0

	map.x = math.floor(map.x/TILESIZE)*TILESIZE
	map.y = math.floor(map.y/TILESIZE)*TILESIZE
	
	map.grid = {}
	for l=1, map.height do 
		map.grid[l] = {}
		for c=1, map.width do
			map.grid[l][c] = 0
		end
	end
end
main.lua =

Code: Select all

io.stdout:setvbuf("no")

require 'map'

opt = {}
opt.showMap = false

TILESIZE = 32

Re: Syntax Error

Posted: Sun Feb 21, 2021 6:07 pm
by DerpChest
can you give me the .love and ill take a look at it

Re: Syntax Error

Posted: Sun Feb 21, 2021 8:41 pm
by togFox
I'll bet it's a missing END.

Re: Syntax Error

Posted: Sun Feb 21, 2021 9:28 pm
by pgimeno
The above map.lua works for me, and the error is strange because it is reported at line 1 and on end-of-file. Something weird is going on, but since it works for me, I can't help.