Optional arguments in the API

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
jseb
Prole
Posts: 3
Joined: Mon Jul 08, 2013 6:13 pm
Location: sat on a chair

Optional arguments in the API

Post by jseb »

Hello,

Seeking how i could get the currently played notes and instruments in a soundtrack module, i've landed on this page:

https://www.love2d.org/wiki/Source:tell

It seems a bit high-level for what i want to get, but i've noticed that the argument is optional (i was reading source at the same time).

Code: Select all


int w_Source_tell(lua_State *L)
{
        Source *t = luax_checksource(L, 1);
        const char *unit = luaL_optstring(L, 2, "seconds");
        Source::Unit u;
        t->getConstant(unit, u);
        lua_pushnumber(L, t->tell(u));
        return 1;
}

Or may be we should understand that the string in parenthesis is used by default ?
TimeUnit unit ("seconds")
The type of unit for the return value.


See you.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Optional arguments in the API

Post by bartbes »

Yes, that is used all over the wiki.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 6 guests