Reputation: 71
I am working on a some code in Lua and I keep getting this error although it is defined.
It is saying that 'LM' is a nil value when it's clearly not as LM = {}
is the first thing I have in my code. I am using that table for functions.
LM = {}
LM.Classes = {}
LM.Factions = {}
LM.Items = {}
LM.Core = {}
LM.Ent = {}
LM.GUI = {}
LM.Core.ValidLMEntities = {
"fm_item",
"fm_keys",
"fm_fists",
"fm_money",
}
function LM.Core.IsLMEntity(ent)
return IsValid(ent) && table.HasValue(LM.Core.ValidLMEntities, ent:GetClass())
end
Error message:
[ERROR]
gamemodes/lemonmuffin/gamemode/sv_core.lua:1: attempt to index global 'LM' (a nil value)
1. unknown - gamemodes/lemonmuffin/gamemode/sv_core.lua:1
2. include - [C]:-1
3. unknown - gamemodes/lemonmuffin/gamemode/init.lua:1
Upvotes: 0
Views: 888
Reputation: 411
Try This
LM = {Classes,Factions,Items,Core,Ent,GUI}
LM.Classes = {}
LM.Factions = {}
LM.Items = {}
LM.Core = {}
LM.Ent = {}
LM.GUI = {}
LM.Core.ValidLMEntities = {
"fm_item",
"fm_keys",
"fm_fists",
"fm_money",
}
function LM.Core.IsLMEntity(ent)
return IsValid(ent) and table.HasValue(LM.Core.ValidLMEntities, ent:GetClass())
end
Upvotes: 0
Reputation: 122373
Take care, you've used &&
which is not the same as and
.
Here's the full list of all Lua non-word tokens (there's no &
):
+ - * / % ^ #
== ~= <= >= < > =
( ) { } [ ] ::
; : , . .. ...
see Reference Manual for more details.
Upvotes: 4