[Help] Table "self" Error [Help]

This is the error I’m getting in the console:


 lua_openscript_cl autorun/client/polymorphism.lua
Running script autorun/client/polymorphism.lua...
[lua\autorun\client\polymorphism.lua:4] attempt to index global 'self' (a nil value


This is “polymorphism.lua”:
[lua]
local Funcs = {
File = “PolyMorphic.txt”,
T = function()
if file.Exists(self.File) then

	else
		self.TT()
	end
end,
TT = function()
	f1 = self.TTT()
	file.Write(self.File, 
	[[
		function ]]..f1..[[()
			print("test")
		end
		]]..f1..[[()
	]])
end,
TTT = function()
	ret = ""
	for i = 1, math.random(25,30) do
		ret = ret .. string.char(math.random(97, 122))
	end
	return ret
end

}
Funcs.T()
[/lua]

Could you help me out here? I have no idea why this wouldn’t work… Thanks.

In the function parameter put self (or anything else for that matter, but if you do replace self with that) inside.

There are anonymous functions, you have to declare the self parameter.

And you also need to call it Funcs:T() not . .

[lua]

local Funcs = {
File = “PolyMorphic.txt”,
T = function(self)
if file.Exists(self.File) then
else
self:TT()
end
end,
TT = function(self)
f1 = self:TTT()
file.Write(self.File,
[[
function ]]…f1…[[()
print(“test”)
end
]]…f1…[[()
]])
end,
TTT = function(self)
ret = “”
for i = 1, math.random(25,30) do
ret = ret … string.char(math.random(97, 122))
end
return ret
end
}
Funcs:T()
[/lua]

Facepunch fucked the formatting, posting again.

[editline]12th November 2011[/editline]

Wrong.

@Wizard I basically said put something in the function parameter. Yeah I also said that it couldn’t be self but still.

You edited your post after my post…

Don’t try to play the smartass here(thats my job).

Yes your point is? I don’t want to confuse anyone here.
Anyways I simply restated what I had already said, more clearly.

Oh I’m sorry, did I piss you off you German fuck?