I have some weird numeric table structures and now want to addhook functions inside my tables. (
addhook)1. How do I make this code work?
1
addhook("attack", "myTbl[1].a.func1")
2. How do I 'addhook' a function I dont know the roots of yet? (See below)
I have n files and they all return the same table structure:
file1.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
return {
	desc="Some file n=1 description",
	["a"] = {
		func1 = function(id)
			print("Foo: "..id)
		end,
		addMe = function()
			-- ???
			addhook("attack","self:func1") -- self not declared
			-- and there is no tostring(self)
		end,
		
	}
	["b"] = {
		func1 = function(id)
			print("Bar: "..id)
		end,
	}
}
And a fileSuper.lua that reads my file1.lua:
fileSuper.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
myFilePathStrings = {
	"sys/lua/file1.lua",
	--"file2.lua",
	-- ...
}
local currFile
local myTbl = {}
-- Load Table
for _,file in pairs(myFilePathStrings)
	currFile = loadfile(file)
	myTbl[#myTbl+1] = currFile()
end
-- Execute function (works fine)
myTbl[1]["a"].func1(5) --> Foo: 5
myTbl[1]["b"].func1(5) --> Bar: 5
-- Addhook?
myTbl[1]["a"].addMe()
addhook("attack", "myTbl[1].a.func1") -- []-accessors
Are there any easy solutions to that?
Addhooking function in anonymious numeric table
1 
Offline

Bowlinghead