naev 0.11.5
nlua_diff.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include "nstring.h"
11#include <lauxlib.h>
12#include <lua.h>
13#include <math.h>
14#include <stdio.h>
15#include <stdlib.h>
18#include "naev.h"
19
20#include "nlua_diff.h"
21
22#include "log.h"
23#include "nluadef.h"
24#include "unidiff.h"
25
26/* diffs */
27static int diffL_apply( lua_State *L );
28static int diffL_remove( lua_State *L );
29static int diffL_isapplied( lua_State *L );
30static const luaL_Reg diffL_methods[] = {
31 { "apply", diffL_apply },
32 { "remove", diffL_remove },
33 { "isApplied", diffL_isapplied },
34 {0,0}
35};
42int nlua_loadDiff( nlua_env env )
43{
44 nlua_register(env, "diff", diffL_methods, 0);
45 return 0;
46}
47
71static int diffL_apply( lua_State *L )
72{
73 const char *name = luaL_checkstring(L,1);
74 diff_apply( name );
75 return 0;
76}
77
84static int diffL_remove( lua_State *L )
85{
86 const char *name = luaL_checkstring(L,1);
87 diff_remove( name );
88 return 0;
89}
90
98static int diffL_isapplied( lua_State *L )
99{
100 const char *name = luaL_checkstring(L,1);
101 lua_pushboolean(L,diff_isApplied(name));
102 return 1;
103}
Header file with generic functions and naev-specifics.
static const luaL_Reg diffL_methods[]
Definition nlua_diff.c:30
static int diffL_isapplied(lua_State *L)
Checks to see if a diff is currently applied.
Definition nlua_diff.c:98
static int diffL_remove(lua_State *L)
Removes a diff by name.
Definition nlua_diff.c:84
static int diffL_apply(lua_State *L)
Lua bindings to apply/remove Universe Diffs.
Definition nlua_diff.c:71
int nlua_loadDiff(nlua_env env)
Loads the diff Lua library.
Definition nlua_diff.c:42
int diff_apply(const char *name)
Applies a diff to the universe.
Definition unidiff.c:284
void diff_remove(const char *name)
Removes a diff from the universe.
Definition unidiff.c:1507
int diff_isApplied(const char *name)
Checks if a diff is currently applied.
Definition unidiff.c:257