English Pseudo Automatically addhook

No replies
Goto Page
To the start Previous 1 Next To the start
09.01.12 06:25:10 am
Up
CmDark
User
Offline Off
Can anyone test this?
I made it a long while ago:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
toTable = function (t, match, ttable)
     local cmd = {};
     if ttable==nil then ttable = cmd; end
          if not match then match = "[^%s]+" end
               for word in string.gmatch(t, match) do
                    table.insert(ttable, word)
               end
     return cmd
end

sethooks = function ()
     fhooks = {};
     local _hooksf = assert( io.open('sys/lua/hooks.cfg','r') );
          if (_hooksf)~=nil then
               for l in io.lines(_defaultconfig,'r') do
                    local _fileparse = toTable(l,"[^%s]+",fhooks);
                    break
               end
          end
     for nmbr=0,#fhooks do
     addhook(tostring(fhooks[nmbr]),"shook_"..tostring(fhooks[nmbr]).."_hook")
     end
end

--[[
Use: sethooks()
It's that simple.
Just make sure you have a file named hooks.cfg
AND that inside hooks.cfg, each line has the hook type on it.
E.g.:

Hooks.cfg

Inside Hooks.cfg=
hit
second

This would make sethooks() add those two hooks.

[!]Important[!]
You can change what the hook name that is used for each hook in the line
with addhook in it.
]]--


No real purpose.
IMG:http://i54.tinypic.com/auk478.png
To the start Previous 1 Next To the start