21#include "nlua_system.h"
77 nlua_setenv(
naevL, ev->
env,
"__evt" );
90int event_run(
unsigned int eventid,
const char *func )
108 evptr = lua_touserdata( L, -1 );
128 ret = nlua_pcall( ev->
env, nargs, 0 );
131 ( lua_isstring(
naevL, -1 ) ) ? lua_tostring(
naevL, -1 ) : NULL;
132 if ( ( err == NULL ) || ( strcmp( err, NLUA_DONE ) != 0 ) ) {
134 ( err ) ? err : _(
"unknown error" ) );
145 WARN( _(
"Event deleted in middle of hook call! Likely caused by another "
146 "hook finishing the event triggered by this hook (\"%s\")." ),
150 nlua_getenv(
naevL, ev->
env,
"__evt_delete" );
151 evt_delete = lua_toboolean(
naevL, -1 );
184 const char *func, *name, *desc;
189 func = luaL_checkstring( L, 1 );
190 name = luaL_checkstring( L, 2 );
192 desc = luaL_checkstring( L, 4 );
195 priority = luaL_optinteger( L, 5, 5 );
196 if ( !lua_isnoneornil( L, 6 ) )
205 npc_add_event( cur_event->
id, func, name, priority, portrait, desc, bg );
211 lua_pushnumber( L,
id );
231 id = luaL_checklong( L, 1 );
239 return NLUA_ERROR( L, _(
"Invalid NPC ID!" ) );
254 int b = lua_toboolean( L, 1 );
255 lua_pushboolean( L, 1 );
256 nlua_setenv( L, cur_event->
env,
"__evt_delete" );
261 lua_pushstring( L, NLUA_DONE );
280 if ( lua_gettop( L ) == 0 )
283 b = lua_toboolean( L, 1 );
322 inclusive = lua_toboolean( L, 2 );
326 return NLUA_ERROR( L, _(
"Event trying to claim but already has." ) );
332 if ( lua_istable( L, 1 ) ) {
335 while ( lua_next( L, 1 ) != 0 ) {
338 else if ( lua_isstring( L, -1 ) )
344 else if ( lua_isstring( L, 1 ) )
347 NLUA_INVALID_PARAMETER( L, 1 );
352 lua_pushboolean( L, 0 );
357 cur_event->
claims = claim;
359 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.
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.