naev 0.12.6
nlua_shiplog.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
9#include "nlua_shiplog.h"
10
11#include "nlua.h"
12#include "shiplog.h"
13
14int shiplog_loadShiplog( nlua_env env );
15static int shiplog_createLog( lua_State *L );
16static int shiplog_appendLog( lua_State *L );
17
18static const luaL_Reg shiplog_methods[] = {
19 { "create", shiplog_createLog },
20 { "append", shiplog_appendLog },
21 { 0, 0 } };
22
23/*
24 * individual library loading
25 */
30int nlua_loadShiplog( nlua_env env )
31{
32 nlua_register( env, "shiplog", shiplog_methods, 0 );
33 return 0;
34}
35
69static int shiplog_createLog( lua_State *L )
70{
71 const char *idstr, *logname, *logtype;
72 int overwrite, maxLen;
73 /* Parameters. */
74 idstr = luaL_checkstring( L, 1 );
75 logname = luaL_checkstring( L, 2 );
76 logtype = luaL_checkstring( L, 3 );
77 overwrite = lua_toboolean( L, 4 );
78 maxLen = luaL_optinteger( L, 5, 0 );
79 /* Create a new shiplog */
80 shiplog_create( idstr, logname, logtype, overwrite, maxLen );
81 return 0;
82}
83
94static int shiplog_appendLog( lua_State *L )
95{
96 const char *idstr = luaL_checkstring( L, 1 );
97 const char *msg = luaL_checkstring( L, 2 );
98 int ret = shiplog_append( idstr, msg );
99 lua_pushboolean( L, !ret );
100 return 1;
101}
int nlua_loadShiplog(nlua_env env)
Loads the mission Lua library.
static int shiplog_appendLog(lua_State *L)
Appends to the shiplog.
static const luaL_Reg shiplog_methods[]
static int shiplog_createLog(lua_State *L)
Bindings for adding log entries to the ship log.
int shiplog_append(const char *idstr, const char *msg)
Appends to the log file.
Definition shiplog.c:183
int shiplog_create(const char *idstr, const char *logname, const char *type, int overwrite, int maxLen)
Creates a new log with given title of given type.
Definition shiplog.c:56