26#include "nlua_system.h"
86 evptr = lua_newuserdata( naevL,
sizeof(
Event_t*) );
88 nlua_setenv( naevL, ev->
env,
"__evt" );
91 nlua_getenv( naevL, ev->
env, func );
118 nlua_getenv( L, __NLUA_CURENV,
"__evt" );
119 evptr = lua_touserdata( L, -1 );
141 ret = nlua_pcall(ev->
env, nargs, 0);
143 const char* err = (lua_isstring(naevL,-1)) ? lua_tostring(naevL,-1) : NULL;
144 if ((err==NULL) || (strcmp(err,NLUA_DONE)!=0)) {
145 WARN(_(
"Event '%s' -> '%s': %s"),
157 WARN(_(
"Event deleted in middle of hook call! Likely caused by another hook finishing the event triggered by this hook (\"%s\")."), func);
160 nlua_getenv(naevL, ev->
env,
"__evt_delete");
161 evt_delete = lua_toboolean(naevL,-1);
189 const char *func, *name, *desc;
194 func = luaL_checkstring(L, 1);
195 name = luaL_checkstring(L, 2);
197 desc = luaL_checkstring(L, 4);
200 priority = luaL_optinteger(L,5,5);
201 if (!lua_isnoneornil(L,6))
209 id =
npc_add_event( cur_event->
id, func, name, priority, portrait, desc, bg );
215 lua_pushnumber( L,
id );
235 id = luaL_checklong(L, 1);
243 return NLUA_ERROR(L, _(
"Invalid NPC ID!"));
258 int b = lua_toboolean(L,1);
259 lua_pushboolean( L, 1 );
260 nlua_setenv( L, cur_event->
env,
"__evt_delete" );
265 lua_pushstring(L, NLUA_DONE);
283 if (lua_gettop(L)==0)
286 b = lua_toboolean(L,1);
318 inclusive = lua_toboolean(L,2);
322 return NLUA_ERROR(L, _(
"Event trying to claim but already has."));
328 if (lua_istable(L,1)) {
331 while (lua_next(L, 1) != 0) {
334 else if (lua_isstring(L,-1))
341 else if (lua_isstring(L, 1))
344 NLUA_INVALID_PARAMETER(L,1);
349 lua_pushboolean(L,0);
354 cur_event->
claims = claim;
356 lua_pushboolean(L,1);
int claim_test(const Claim_t *claim)
Tests to see if a system claim would have collisions.
void claim_destroy(Claim_t *claim)
Destroys a system claim.
int claim_addStr(Claim_t *claim, const char *str)
Adds a string claim to a claim.
int claim_addSys(Claim_t *claim, int ss_id)
Adds a claim to a system claim.
void claim_activate(Claim_t *claim)
Activates a claim on a system.
int claim_isNull(const Claim_t *claim)
See if a claim actually contains data.
Claim_t * claim_create(int exclusive)
Creates a system claim.
const char * event_getData(unsigned int eventid)
Gets the name of the event data.
void event_remove(unsigned int eventid)
Removes an event by ID.
Event_t * event_get(unsigned int eventid)
Gets an event.
int event_isUnique(unsigned int eventid)
Checks to see if an event is unique.
void bar_regen(void)
Regenerates the bar list.
Header file with generic functions and naev-specifics.
void event_runStart(unsigned int eventid, const char *func)
Starts running a function, allows programmer to set up arguments.
int event_runFunc(unsigned int eventid, const char *func, int nargs)
Runs a function previously set up with event_runStart.
static int evtL_claim(lua_State *L)
Tries to claim systems or strings.
static int evtL_finish(lua_State *L)
Finishes the event.
int event_run(unsigned int eventid, const char *func)
Runs the event function.
static int evtL_npcAdd(lua_State *L)
Event system Lua bindings.
static int evtL_npcRm(lua_State *L)
Removes an NPC.
Event_t * event_getFromLua(lua_State *L)
Gets the current running event from user data.
static int evtL_save(lua_State *L)
Saves an event.
static const luaL_Reg evtL_methods[]
int nlua_loadEvt(nlua_env env)
Loads the event Lua library.
LuaSystem lua_tosystem(lua_State *L, int ind)
Lua system module.
int lua_issystem(lua_State *L, int ind)
Checks to see if ind is a system.
glTexture * luaL_validtex(lua_State *L, int ind, const char *searchpath)
Gets texture directly or from a filename (string) at index or raises error if there is no texture at ...
unsigned int npc_add_event(unsigned int evt, const char *func, const char *name, int priority, glTexture *portrait, const char *desc, glTexture *background)
Adds a event NPC to the mission computer.
int npc_rm_event(unsigned int id, unsigned int evt)
removes an event NPC.
void player_eventFinished(int id)
Marks a event as completed.
Activated event structure.
Abstraction for rendering sprite sheets.