Anonymous functions 
2 comments For the few who hate not being able to hook local or anonymous functions to actions or timers, I wrote this little script.
It doesn't do anything cool, you don't get awesome admin powers or way too many images or npc's or whatever it is you lot like so much, it only makes scripting a little easier for a few of you.
None of the above would work normally (try it), now it does.
It doesn't do anything cool, you don't get awesome admin powers or way too many images or npc's or whatever it is you lot like so much, it only makes scripting a little easier for a few of you.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
local function lolz(id, txt)
msg(player(id, "name") .. " wrote: " .. txt)
end
addhook("say", "lolz") -- works
addhook("say", lolz, 3) -- works
addhook("say", function(...) lolz(...) end) -- works
freehook("say", "lolz") -- works
freehook("say", lolz) -- same
freehook("say", function(...) lolz(...) end) -- can't work because it creates a new function
timer(1000, "lolz")
timer(1000, lolz)
timer(1000, function(p) print(p) end, "hi", 2) -- works
msg(player(id, "name") .. " wrote: " .. txt)
end
addhook("say", "lolz") -- works
addhook("say", lolz, 3) -- works
addhook("say", function(...) lolz(...) end) -- works
freehook("say", "lolz") -- works
freehook("say", lolz) -- same
freehook("say", function(...) lolz(...) end) -- can't work because it creates a new function
timer(1000, "lolz")
timer(1000, lolz)
timer(1000, function(p) print(p) end, "hi", 2) -- works
None of the above would work normally (try it), now it does.

Comments
2 comments



Log in!
You need to log in to be able to write comments!Log in



