Dateien

> > CS2D > Lua Scripts > Anonymous functions
DateiübersichtCS2D-ÜbersichtLua Scripts-Übersicht

Englisch Anonymous functions >

2 Kommentare2 kb, 345 Downloads

alt 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.
Zugelassen von GeoB99

Download Download

2 kb, 345 Downloads

Kommentare

2 Kommentare
Zum Anfang Vorherige 1 Nächste Zum Anfang

Logge dich ein!

Du musst dich einloggen, um selber Kommentare verfassen zu können!Einloggen

alt

Kel9290
User Off Offline

lolwut? Not think i need it but o:.
Spoiler >
Ich mag es!
1× editiert, zuletzt 05.01.12 13:50:52

alt

sheeL
User Off Offline

Good lua!
1× editiert, zuletzt 20.07.14 07:43:33
Zum Anfang Vorherige 1 Nächste Zum Anfang