naev 0.11.5
nlua_shiplog.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include <math.h>
11#include <stdio.h>
12#include <stdlib.h>
13
14#include "naev.h"
17#include "nlua_shiplog.h"
18
19#include "array.h"
20#include "gui_osd.h"
21#include "land.h"
22#include "log.h"
23#include "mission.h"
24#include "music.h"
25#include "ndata.h"
26#include "nlua.h"
27#include "nlua_bkg.h"
28#include "nlua_camera.h"
29#include "nlua_faction.h"
30#include "nlua_hook.h"
31#include "nlua_misn.h"
32#include "nlua_music.h"
33#include "nlua_player.h"
34#include "nlua_system.h"
35#include "nlua_tex.h"
36#include "nlua_tk.h"
37#include "nluadef.h"
38#include "npc.h"
39#include "nstring.h"
40#include "nxml.h"
41#include "player.h"
42#include "rng.h"
43#include "shiplog.h"
44#include "toolkit.h"
45
46int shiplog_loadShiplog( nlua_env env );
47static int shiplog_createLog( lua_State *L );
48static int shiplog_appendLog( lua_State *L );
49static const luaL_Reg shiplog_methods[] = {
50 { "create", shiplog_createLog },
51 { "append", shiplog_appendLog },
52 {0,0}
53};
55/*
56 * individual library loading
57 */
62int nlua_loadShiplog( nlua_env env )
63{
64 nlua_register(env, "shiplog", shiplog_methods, 0);
65 return 0;
66}
67
93static int shiplog_createLog( lua_State *L )
94{
95 const char *idstr, *logname, *logtype;
96 int overwrite,maxLen;
97 /* Parameters. */
98 idstr = luaL_checkstring(L,1);
99 logname = luaL_checkstring(L,2);
100 logtype = luaL_checkstring(L,3);
101 overwrite = lua_toboolean(L,4);
102 maxLen = luaL_optinteger(L,5,0);
103 /* Create a new shiplog */
104 shiplog_create( idstr, logname, logtype, overwrite, maxLen );
105 return 0;
106}
107
118static int shiplog_appendLog( lua_State *L )
119{
120 const char *idstr = luaL_checkstring(L, 1);
121 const char *msg = luaL_checkstring(L, 2);
122 int ret = shiplog_append(idstr, msg);
123 lua_pushboolean(L, !ret);
124 return 1;
125}
Provides macros to work with dynamic arrays.
Header file with generic functions and naev-specifics.
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:174
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:54