Odd Simple Error

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
DecarCC
Prole
Posts: 1
Joined: Sun Feb 14, 2021 8:16 pm

Odd Simple Error

Post by DecarCC »

I am having a weird but simple error in my code and I was wondering if anyone would be able to help me fix this. I'll upload my error message and the code with this post. Thanks for any help!
main.lua
(20.05 KiB) Downloaded 135 times
Error Message:
Error

Syntax error: main.lua:164: 'then' expected near '='

Traceback

[C]: at 0x7ffa33b728f0
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
User avatar
Xii
Party member
Posts: 137
Joined: Thu Aug 13, 2020 9:09 pm
Contact:

Re: Odd Simple Error

Post by Xii »

Here is the offending code,

Code: Select all

if firetype = "Minigun" then
	baseRate = 0.75
elseif firetype = "Laser" then
	baseRate = 0.6
end
it's because you accidentally used assignment = instead of comparison == in an if statement.

Code: Select all

if firetype == "Minigun" then
	baseRate = 0.75
elseif firetype == "Laser" then
	baseRate = 0.6
end
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Odd Simple Error

Post by togFox »

I still do that mistake.
Every.
Single.
Time.

Can't kill some habits.:(
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
Post Reply

Who is online

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