lua table to e2 table

hello, i’m new to both lua and gmod and i’m trying to make an entity that ouputs a lue table with wiremod so that it can be made use of with e2
the code i’ve written is being run every time but sometimes the value is what i want and others its nil
i would appreciate any constructive thoughts or ideas

here is my code

local E2Table = {}
E2Table[“size”] = 0
E2Table[“s”] = {}
E2Table[“stypes”] = {}
E2Table[“istable”] = true
E2Table[“depth”] = 0
E2Table[“n”] = {}
E2Table[“ntypes”] = {}
for k,v in pairs(self.Vars) do
if(type(v) == “number”) then
E2Table[“size”] = E2Table[“size”] + 1
E2Table[“s”][k] = v
E2Table[“stypes”][k] = “n”
elseif(type(v) == “string”) then
E2Table[“size”] = E2Table[“size”] + 1
E2Table[“s”][k] = v
E2Table[“stypes”][k] = “s”
elseif(type(v) == “boolean”) then
self.Owner:ChatPrint(“boolean type not yet supported”)
elseif(type(v) == “table”) then
self.Owner:ChatPrint(“table type not yet supported”)
elseif(type(v) == “vector”) then
E2Table[“size”] = E2Table[“size”] + 1
E2Table[“s”][k] = v
E2Table[“stypes”][k] = “v”
elseif(type(v) == “angle”) then
E2Table[“size”] = E2Table[“size”] + 1
E2Table[“s”][k] = {v.p, v.y, v.r}
E2Table[“stypes”][k] = “a”
elseif(type(v) == “color”) then
self.Owner:ChatPrint(“color type not yet supported”)
end
end
PrintTable(E2Table)
Wire_TriggerOutput(self.Entity, “Config”, E2Table)

edit:
never mind about it not working, i made a stupid mistake somewhere else in my code and it now works perfectly ^^u

Vector, Angle and Color should be written properly capitalized.

E2 tables are normal lua tables, except the key is prefixed with the lower case type identifier, ie ‘s’ for string, ‘n’ for number ‘xwl’ for wire link. The table you are outputting will not work properly. I can’t be bothered to type out the full list, but [The Expression 2 Wiki Page] contains a list. Remember that while uppercase on the wiki, they are in fact all lower case.

http://wiki.garrysmod.com/?title=Getting_Started_With_Lua :wink: