Forum

> > CS2D > Scripts > Extending native functions
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Extending native functions

28 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Re: Extending native functions

Avo
User Off Offline

Zitieren
Everythink is really awesome, but I have one question. Why "Love API"? I miss Ohaz as a moderator, but why "love"?

alt Re: Extending native functions

Livia
User Off Offline

Zitieren
Do you find it too girlish? I think love is the best word to describe US.de community so why not use it.

on topic: Is there something missing in L{insert_anything_here} API?

alt Re: Extending native functions

Infinite Rain
Reviewer Off Offline

Zitieren
Livia hat geschrieben
I think love is the best word to describe US.de community so why not use it.

Lol.

OT: You could also make every copy of a cosnole command into a function, smth like:

Console:hudtxt2(blah)

alt Re: Extending native functions

Livia
User Off Offline

Zitieren
@user Infinite Rain: Very good idea. I almost forgot hudtxt!

I added a small TODO list:
https://github.com/tarjoilija/lapi/blob/master/TODO

Edit: Done.
Spoiler >
1× editiert, zuletzt 24.09.13 16:23:49

alt Re: Extending native functions

KimKat
GAME BANNED Off Offline

Zitieren
@user Livia: I like the name of Love API even if it's not the best choice of name for Lua stuff I still admire it though. Unreal Software does need some love. About the L{} thing, is there hudtxt2, sv_sound and sv_sound2? could be useful things to include if not already implemented of course, can you tell me if you have them in the Love API?

Maybe shortening stuff to save memory or lines of code would be desirable, as it would affect the load times of the Lua scripts. Kind of user-friendly. The JQuery library also compress their code to save memory and stuff like such. Maybe you could do a similar thing, by creating a minified version and a standard version. It would be much appreciated.
lua "function P(o)parse(o)end"
lua "P('sv_sound2 1 wc3tft_2d/entangleroots.ogg')"

alt Re: Extending native functions

Livia
User Off Offline

Zitieren
@user KimKat: There's plenty of things included that hasn't been documented yet. Current status is very unstable and things may change in the near future. All feedback is taken into account.

There's no such thing as hudtxt2 in Love API. It's just Hudtxt(ply, id) where ply is a player object. Passing zero as a first parameter would cause the script to use regular hudtxt instead of player specific hudtxt2. Shortcut for this is ply:hudtxt(id).

Let me give you an example of a very simple hudtxt:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- called when player joins the server
Hook('join', function(ply)
    -- create hudtxt for current player with id of 1
    local txt = ply:hudtxt(1)
    -- e.g. Welcome, Livia
    local message = Color(20, 220, 20) .. "Welcome, " .. ply.name
    
    -- show hudtxt in player's screen at bottom left corner
    txt:show(message, 10, 420, 0)
    
    -- after 5 seconds (5000 milliseconds)
    Timer(5000, function()
        -- hide the message
        txt:hide()
    end)
end)

I don't think compressing is necessary. It would only make debugging very hard (it's already).

alt Re: Extending native functions

Livia
User Off Offline

Zitieren
Sorry for bumping an old thread but Love API is not dead yet!

@user MikuAuahDark: Timers are also objects that you can destroy with remove() method. I'm sorry but the documentation is very poor.
1
2
3
4
5
local my_timer = Timer(2000, function()
    msg("hello world")
end)

my_timer:remove()

I also added a simple way of iterating playerobjects:
1
2
3
4
Player.each_living(function(p)
    p.health = 100
    p:msg("healed")
end)

I'll probably also add a simple plugin which let's you create one-tigger-only hooks like:
1
2
3
4
5
6
local p = Player(1)

-- will trigger only once
p.onSpawn(function()
	p.shake(200)
end)
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht