I have a Derma window that pops up and displays a DIconLayout.
I'm attmepting to make a config for easy editing/access.
Here is my table so far
[CODE]local gamemode.ents.ShopNpc = {}
local gamemode.ents.ShopNpc = {
--Number of panels
NumPanels = 36;
}[/CODE]
However, I get this error when the table is created
[CODE][ERROR] gamemodes/gamemode/entities/entities/npc_shop/cl_init.lua:27: unexpected symbol near '.'
1. unknown - gamemodes/gamemode/entities/entities/npc_shop/cl_init.lua:0[/CODE]
I access the stored info for NumPanels by using
[CODE]gamemode.ents.ShopNpc.NumPanels[/CODE]
Thanks for you help
(this may seem like a stupid post, but i've barely ever used tables before, so sorry. Also, i have no idea what i'm doing with this code, but you probably already noticed)
You got this error, because table args are separated by "," not ";". And also, you are creating table in existing table and in this case it cant be local
[code]
// Can be local
simpleTable = {}
// Can't be
parentTable.temp = {}
[/code]
[QUOTE=iJohnny;49737047]You got this error, because table args are separated by "," not ";"[/QUOTE]
You can use either one.
So, how do I do this properly. I don't quite understand.
[code]
local gamemode = {} -- im not sure, what u want it to be local
gamemode.ents = {}
local gents = gamemode.ents -- will make code shorten?
gents.ShopNpc = {}
[/code]
[QUOTE=Austin1346;49736971]:snip:[/QUOTE]
[CODE]local gamemode.ents.ShopNpc = {}
local gamemode.ents.ShopNpc = {
--Number of panels
NumPanels = 36;
}[/CODE]
This errors because you are trying to create multiple tables without initializing them. Have a look at this:
[CODE]
local gamemode = {
ents = {
ShopNpc = {
--Number of panels
NumPanels = 36
}
}
[/CODE]
This creates the 3 tables you are looking for.
Alternatively you can do this:
[CODE]
local gamemode = {}
gamemode.ents = {}
gamemode.ents.ShopNpc = {}
gamemode.ents.ShopNpc.NumPanels = 36
[/CODE]
You can get the NumPanels value with gamemode.ents.ShopNpc.NumPanels
But if you want to do it right you want to check every step.
[CODE]if gamemode and gamemode.ents and gamemode.ents.ShopNpc and gamemode.ents.ShopNpc.NumPanels then
-- do some stuff
end[/CODE]
[QUOTE=darkjacky;49737422][CODE]local gamemode.ents.ShopNpc = {}
local gamemode.ents.ShopNpc = {
--Number of panels
NumPanels = 36;
}[/CODE]
This errors because you are trying to create multiple tables without initializing them. Have a look at this:
[CODE]
local gamemode = {
ents = {
ShopNpc = {
--Number of panels
NumPanels = 36
}
}
[/CODE]
This creates the 3 tables you are looking for.
Alternatively you can do this:
[CODE]
local gamemode = {}
gamemode.ents = {}
gamemode.ents.ShopNpc = {}
gamemode.ents.ShopNpc.NumPanels = 36
[/CODE]
You can get the NumPanels value with gamemode.ents.ShopNpc.NumPanels
But if you want to do it right you want to check every step.
[CODE]if gamemode and gamemode.ents and gamemode.ents.ShopNpc and gamemode.ents.ShopNpc.NumPanels then
-- do some stuff
end[/CODE][/QUOTE]
This is exactly what I was looking for!
Sorry, you need to Log In to post a reply to this thread.