Page 1 of 1

Weird syntax error[ SOLVED ]

Posted: Fri Dec 31, 2021 2:00 am
by Casfew
Hi!! :DDD

Im a begginer at programming and trying to recreate Space Invader in Löve for Android. But im getting a syntax error that i can't quite understand why im getting it:

Error

Syntax error: bullet.lua:74: 'end' expected (to close 'function' at line 48) near '<eof>'

Traceback

[C]: at 0x97533909
[C]: in function 'require'
main.lua:15: in function 'load'
[C]: in function 'xpcall'
[C]: in function 'xpcall'

It happens in a function that is supposed to handle the player's bullets, the player is supposed to have 5 bullets that he can shoot when they're not already on the screen.
Space_invaders.love
Files of the game
(76.57 KiB) Downloaded 62 times
I'd very thankful if anyone can help me with this, have a good day :))

Re: Weird syntax error

Posted: Fri Dec 31, 2021 6:01 am
by BrotSagtMist
You are not closing the for loops at line 29 and 50 in bullets.lua with an _end_.
Be more careful with indents or get an editor which automatically checks for open blocks.
When you properly indent the block in the for loop you end up seeing a gap underneath, that way coders see where ends are missing.

Fixing another thing, that bullet self thingy is a nil value which you can bypass with _or_ , i get it to at least show the graphics. Looks chaotic tho.

Re: Weird syntax error

Posted: Sat Jan 01, 2022 12:35 am
by Casfew
Thx so much now it's fixed :D

The self thingy was a typing error and the resolution diference probably was what messed up the graphics.