[Add] Conditionalize the player Lua API.
This commit is contained in:
parent
731a1cee6a
commit
80f2e21429
@ -118,6 +118,13 @@ static const luaL_reg player_methods[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const luaL_reg player_cond_methods[] = {
|
||||
{ "name", player_getname },
|
||||
{ "ship", player_shipname },
|
||||
{ "getFaction", player_getFaction },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
/* Hooks. */
|
||||
static int hook_land(lua_State* L);
|
||||
static int hook_takeoff(lua_State* L);
|
||||
@ -149,7 +156,7 @@ int misn_loadLibs(lua_State* L) {
|
||||
lua_loadVar(L, 0);
|
||||
lua_loadSpace(L, 0);
|
||||
lua_loadTime(L, 0);
|
||||
lua_loadPlayer(L);
|
||||
lua_loadPlayer(L, 0);
|
||||
lua_loadRnd(L);
|
||||
lua_loadTk(L);
|
||||
lua_loadHook(L);
|
||||
@ -160,6 +167,7 @@ int misn_loadLibs(lua_State* L) {
|
||||
int misn_loadCondLibs(lua_State* L) {
|
||||
lua_loadTime(L, 1);
|
||||
lua_loadVar(L, 1);
|
||||
lua_loadPlayer(L, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -177,8 +185,11 @@ int lua_loadVar(lua_State* L, int readonly) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua_loadPlayer(lua_State* L) {
|
||||
luaL_register(L, "player", player_methods);
|
||||
int lua_loadPlayer(lua_State* L, int readonly) {
|
||||
if(readonly == 0)
|
||||
luaL_register(L, "player", player_methods);
|
||||
else
|
||||
luaL_register(L, "player", player_cond_methods);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ int misn_loadCondLibs(lua_State* L); /* Safe read only stuff. */
|
||||
/* Individual library stuff. */
|
||||
int lua_loadMisn(lua_State* L);
|
||||
int lua_loadVar(lua_State* L, int readonly);
|
||||
int lua_loadPlayer(lua_State* L);
|
||||
int lua_loadPlayer(lua_State* L, int readonly);
|
||||
int lua_loadHook(lua_State* L);
|
||||
int lua_loadPilot(lua_State* L);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user