![]() |
naev 0.12.6
|
Handles the event Lua bindings. More...
#include "nlua_evt.h"#include "event.h"#include "land.h"#include "log.h"#include "ndata.h"#include "nlua.h"#include "nlua_system.h"#include "nlua_tex.h"#include "nluadef.h"#include "npc.h"#include "player.h"
Go to the source code of this file.
Functions | |
| static int | evtL_npcAdd (lua_State *L) |
| Event system Lua bindings. | |
| static int | evtL_npcRm (lua_State *L) |
| Removes an NPC. | |
| static int | evtL_finish (lua_State *L) |
| Finishes the event. | |
| static int | evtL_save (lua_State *L) |
| Saves an event. | |
| static int | evtL_claim (lua_State *L) |
| Tries to claim systems or strings. | |
| int | nlua_loadEvt (nlua_env env) |
| Loads the event Lua library. | |
| void | event_runStart (unsigned int eventid, const char *func) |
| Starts running a function, allows programmer to set up arguments. | |
| int | event_run (unsigned int eventid, const char *func) |
| Runs the event function. | |
| Event_t * | event_getFromLua (lua_State *L) |
| Gets the current running event from user data. | |
| int | event_runFunc (unsigned int eventid, const char *func, int nargs) |
| Runs a function previously set up with event_runStart. | |
Variables | |
| static const luaL_Reg | evtL_methods [] |
Handles the event Lua bindings.
Definition in file nlua_evt.c.
| Event_t * event_getFromLua | ( | lua_State * | L | ) |
Gets the current running event from user data.
This should ONLY be called below an nlua_pcall, so __NLUA_CURENV is set
Definition at line 103 of file nlua_evt.c.
| int event_run | ( | unsigned int | eventid, |
| const char * | func ) |
Runs the event function.
| eventid | ID of the event to run Lua function on. |
| func | Name of the function to run. |
Definition at line 90 of file nlua_evt.c.
| int event_runFunc | ( | unsigned int | eventid, |
| const char * | func, | ||
| int | nargs ) |
Runs a function previously set up with event_runStart.
Definition at line 120 of file nlua_evt.c.
| void event_runStart | ( | unsigned int | eventid, |
| const char * | func ) |
Starts running a function, allows programmer to set up arguments.
Definition at line 67 of file nlua_evt.c.
|
static |
Tries to claim systems or strings.
Claiming systems and strings is a way to avoid mission collisions preemptively.
Note it does not actually perform the claim if it fails to claim. It also does not work more than once.
Lua usage parameter: if not evt.claim( { system.get("Gamma Polaris") } ) then evt.finish( false ) end Lua usage parameter: if not evt.claim( system.get("Gamma Polaris") ) then evt.finish( false ) end Lua usage parameter: if not evt.claim( 'some_string' ) then evt.finish( false ) end Lua usage parameter: if not evt.claim( { system.get("Gamma Polaris"), 'some_string' } ) then evt.finish( false ) end
Lua function parameter: System|String|{System,String...} params Table of systems/strings to claim or a single system/string. Lua function parameter:[opt=false] boolean inclusive Whether or not to allow the claim to include other inclusive claims. Multiple missions/events can inclusively claim the same system, but only one system can exclusively claim it. Lua return parameter: boolean true if was able to claim, false otherwise.
| L | Lua State |
Lua function: claim
Definition at line 313 of file nlua_evt.c.
|
static |
Finishes the event.
Lua function parameter:[opt=false] boolean properly If true and the event is unique it marks the event as completed. If false it deletes the event but doesn't mark it as completed.
| L | Lua State |
Lua function: finish
Definition at line 251 of file nlua_evt.c.
|
static |
Event system Lua bindings.
Adds an NPC.
An example would be:
Lua module: evt
Lua usage parameter: npc_id = evt.npcAdd( "my_func", "Mr. Test", "none.webp", "A test." ) – Creates an NPC.
Lua function parameter: string func Name of the function to run when approaching, gets passed the npc_id when called. Lua function parameter: string name Name of the NPC Lua function parameter: string portrait Portrait file name to use for the NPC (from GFX_PATH/portraits/). Lua function parameter: string desc Description associated to the NPC. Lua function parameter:[opt=5] number priority Optional priority argument (highest is 0, lowest is 10). Lua function parameter:[opt=nil] string background Background file name to use (from GFX_PATH/portraits/). Lua return parameter: number The ID of the NPC to pass to npcRm.
| L | Lua State |
Lua function: npcAdd
Definition at line 180 of file nlua_evt.c.
|
static |
Removes an NPC.
Lua usage parameter: evt.npcRm( npc_id )
Lua function parameter: number id ID of the NPC to remove.
| L | Lua State |
Lua function: npcRm
Definition at line 225 of file nlua_evt.c.
|
static |
Saves an event.
Lua usage parameter: evt.save() – Saves an event, which is by default disabled.
Lua function parameter:[opt=true] boolean enable If true sets the event to save, otherwise tells the event to not save.
| L | Lua State |
Lua function: save
Definition at line 276 of file nlua_evt.c.
| int nlua_loadEvt | ( | nlua_env | env | ) |
Loads the event Lua library.
| env | Lua environment. |
Definition at line 58 of file nlua_evt.c.
|
static |
Mission Lua methods.
Definition at line 46 of file nlua_evt.c.