15#include "nlua_pilotoutfit.h"
18#include "nlua_outfit.h"
23int pilotoutfit_modified = 0;
29static int poL_set( lua_State *L );
48 nlua_register(env, PILOTOUTFIT_METATABLE,
poL_methods, 1);
79 luaL_typerror(L, ind, PILOTOUTFIT_METATABLE);
96 luaL_typerror(L, ind, PILOTOUTFIT_METATABLE);
101 NLUA_ERROR(L, _(
"Pilot Outfit is invalid."));
116 luaL_getmetatable(L, PILOTOUTFIT_METATABLE);
117 lua_setmetatable(L, -2);
131 if (lua_getmetatable(L,ind)==0)
133 lua_getfield(L, LUA_REGISTRYINDEX, PILOTOUTFIT_METATABLE);
136 if (lua_rawequal(L, -1, -2))
167 const char *state = luaL_optstring(L,2,NULL);
168 PilotOutfitState pos = po->
state;
171 NLUA_ERROR( L, _(
"'pilotoutfit.%s' only works with modifier outfits!"),
"state");
173 if (state==NULL || strcmp(state,
"off")==0)
174 po->
state = PILOT_OUTFIT_OFF;
175 else if (strcmp(state,
"warmup")==0)
176 po->
state = PILOT_OUTFIT_WARMUP;
177 else if (strcmp(state,
"on")==0)
178 po->
state = PILOT_OUTFIT_ON;
179 else if (strcmp(state,
"cooldown")==0)
180 po->
state = PILOT_OUTFIT_COOLDOWN;
182 NLUA_ERROR( L, _(
"Unknown PilotOutfit state '%s'!"), state );
185 if (pos != po->
state)
186 pilotoutfit_modified = 1;
203 NLUA_ERROR( L, _(
"'pilotoutfit.%s' only works with modifier outfits!"),
"progress");
220 const char *name = luaL_checkstring(L,2);
221 double value = luaL_checknumber(L,3);
223 pilotoutfit_modified = 1;
237 pilotoutfit_modified = 1;
Header file with generic functions and naev-specifics.
const Outfit ** lua_pushoutfit(lua_State *L, const Outfit *outfit)
Pushes a outfit on the stack.
static const luaL_Reg poL_methods[]
int nlua_loadPilotOutfit(nlua_env env)
Loads the pilot outfit library.
PilotOutfitSlot * luaL_validpilotoutfit(lua_State *L, int ind)
Makes sure the outfit is valid or raises a Lua error.
static int poL_progress(lua_State *L)
Sets the state progress of the PilotOutfit.
PilotOutfitSlot * luaL_checkpilotoutfit(lua_State *L, int ind)
Gets outfit at index or raises error if there is no outfit at index.
PilotOutfitSlot ** lua_pushpilotoutfit(lua_State *L, PilotOutfitSlot *po)
Pushes a pilot outfit on the stack.
static int poL_set(lua_State *L)
Sets a temporary ship stat modifier of the pilot outfit.
static int poL_outfit(lua_State *L)
Gets the outfit of the PilotOutfit.
PilotOutfitSlot * lua_topilotoutfit(lua_State *L, int ind)
Lua bindings to interact with pilot outfits.
int lua_ispilotoutfit(lua_State *L, int ind)
Checks to see if ind is a pilot outfit.
static int poL_state(lua_State *L)
Sets the state of the PilotOutfit.
static int poL_clear(lua_State *L)
Clears all the temporary ship stat modifiers of the pilot outfit.
int outfit_isMod(const Outfit *o)
Checks if outfit is a ship modification.
int ss_statsInit(ShipStats *stats)
Initializes a stat structure.
int ss_statsSet(ShipStats *s, const char *name, double value, int overwrite)
Sets a ship stat by name.
Stores an outfit the pilot has.