Files

> > CS2D > Lua Scripts > Anonymous functions
Files overviewCS2D overviewLua Scripts overview

English Anonymous functions >

2 comments2 kb, 362 Downloads

old Anonymous functions

Banaan
User Off Offline

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.

1
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

None of the above would work normally (try it), now it does.
Approved by GeoB99

Download Download

2 kb, 362 Downloads

Comments

2 comments
To the start Previous 1 Next To the start

Log in!

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

old

Kel9290
User Off Offline

lolwut? Not think i need it but o:.
Spoiler >
I like it!
edited 1×, last 05.01.12 01:50:52 pm

old

sheeL
User Off Offline

Good lua!
edited 1×, last 20.07.14 07:43:33 am
To the start Previous 1 Next To the start