Syntax Error

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
FiFolker
Prole
Posts: 1
Joined: Sun Feb 21, 2021 11:59 am

Syntax Error

Post 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
DerpChest
Prole
Posts: 27
Joined: Tue Oct 06, 2020 1:11 pm

Re: Syntax Error

Post by DerpChest »

can you give me the .love and ill take a look at it
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Syntax Error

Post by togFox »

I'll bet it's a missing END.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
User avatar
pgimeno
Party member
Posts: 3673
Joined: Sun Oct 18, 2015 2:58 pm

Re: Syntax Error

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 7 guests