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 );
142 ret = nlua_pcall(ev->
env, nargs, 0);
144 err = (lua_isstring(naevL,-1)) ? lua_tostring(naevL,-1) : NULL;
145 if ((err==NULL) || (strcmp(err,NLUA_DONE)!=0)) {
146 WARN(_(
"Event '%s' -> '%s': %s"),
157 nlua_getenv(naevL, ev->
env,
"__evt_delete");
158 evt_delete = lua_toboolean(naevL,-1);
186 const char *func, *name, *desc;
191 func = luaL_checkstring(L, 1);
192 name = luaL_checkstring(L, 2);
194 desc = luaL_checkstring(L, 4);
197 priority = luaL_optinteger(L,5,5);
198 if (!lua_isnoneornil(L,6))
206 id =
npc_add_event( cur_event->
id, func, name, priority, portrait, desc, bg );
212 lua_pushnumber( L,
id );
232 id = luaL_checklong(L, 1);
240 NLUA_ERROR(L, _(
"Invalid NPC ID!"));
255 int b = lua_toboolean(L,1);
256 lua_pushboolean( L, 1 );
257 nlua_setenv( L, cur_event->
env,
"__evt_delete" );
262 lua_pushstring(L, NLUA_DONE);
280 if (lua_gettop(L)==0)
283 b = lua_toboolean(L,1);
311 int onlytest, inclusive;
316 onlytest = lua_toboolean(L,2);
317 inclusive = lua_toboolean(L,3);
320 if (!onlytest && (cur_event->
claims != NULL)) {
321 NLUA_ERROR(L, _(
"Event trying to claim but already has."));
329 if (lua_istable(L,1)) {
332 while (lua_next(L, 1) != 0) {
335 else if (lua_isstring(L,-1))
342 else if (lua_isstring(L, 1))
345 NLUA_INVALID_PARAMETER(L);
357 lua_pushboolean(L,0);
362 cur_event->
claims = claim;
364 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.
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.