![]() |
naev 0.12.6
|
Handles the mission Lua bindings. More...
#include "nlua_misn.h"#include "array.h"#include "gui_osd.h"#include "land.h"#include "log.h"#include "mission.h"#include "ndata.h"#include "nlua.h"#include "nlua_bkg.h"#include "nlua_camera.h"#include "nlua_commodity.h"#include "nlua_faction.h"#include "nlua_hook.h"#include "nlua_music.h"#include "nlua_spob.h"#include "nlua_system.h"#include "nlua_tex.h"#include "nlua_tk.h"#include "nluadef.h"#include "npc.h"#include "player.h"#include "player_fleet.h"
Go to the source code of this file.
Functions | |
| static int | misn_setTitle (lua_State *L) |
| Mission Lua bindings. | |
| static int | misn_setDesc (lua_State *L) |
| Sets the current mission description. | |
| static int | misn_setReward (lua_State *L) |
| Sets the current mission reward description. | |
| static int | misn_setDistance (lua_State *L) |
| Sets the distance to the mission's goal. Used for sorting missions in the mission computer. Unused otherwise. | |
| static int | misn_setIllegal (lua_State *L) |
| Marks whether or not a mission should be considered illegal in the current system. Used for filtering missions at the mission computer, unused otherwise. | |
| static int | misn_setFaction (lua_State *L) |
| Sets the faction giver of the mission. Used mainly as metadata for sorting and organizing missions in the mission computer. | |
| static int | misn_setNPC (lua_State *L) |
| Sets the current mission NPC. | |
| static int | misn_factions (lua_State *L) |
| Gets the factions the mission is available for. | |
| static int | misn_accept (lua_State *L) |
| Attempts to accept the mission. | |
| static int | misn_finish (lua_State *L) |
| Finishes the mission. | |
| static int | misn_markerAdd (lua_State *L) |
| Adds a new marker. | |
| static int | misn_markerMove (lua_State *L) |
| Moves a marker to a new system. | |
| static int | misn_markerRm (lua_State *L) |
| Removes a mission system marker. | |
| static int | misn_cargoAdd (lua_State *L) |
| Adds some mission cargo to the player. They cannot sell it nor get rid of it unless they abandons the mission in which case it'll get eliminated. | |
| static int | misn_cargoRm (lua_State *L) |
| Removes the mission cargo. | |
| static int | misn_cargoJet (lua_State *L) |
| Jettisons the mission cargo. | |
| static int | misn_osdCreate (lua_State *L) |
| Creates a mission OSD. | |
| static int | misn_osdDestroy (lua_State *L) |
| Destroys the mission OSD. | |
| static int | misn_osdActive (lua_State *L) |
| Sets active in mission OSD. | |
| static int | misn_osdGet (lua_State *L) |
| Gets the current mission OSD information. | |
| static int | misn_osdGetActiveItem (lua_State *L) |
| Gets the active OSD element. | |
| static int | misn_npcAdd (lua_State *L) |
| Adds an NPC. | |
| static int | misn_npcRm (lua_State *L) |
| Removes an NPC. | |
| static int | misn_claim (lua_State *L) |
| Tries to claim systems or strings. | |
| static int | misn_computerRefresh (lua_State *L) |
| Refreshes the mission computer offerings. | |
| int | misn_loadLibs (nlua_env env) |
| Registers all the mission libraries. | |
| int | nlua_loadMisn (nlua_env env) |
| Loads the mission Lua library. | |
| int | misn_tryRun (Mission *misn, const char *func) |
| Tries to run a mission, but doesn't err if it fails. | |
| int | misn_run (Mission *misn, const char *func) |
| Runs a mission function. | |
| Mission * | misn_getFromLua (lua_State *L) |
| Gets the mission that's being currently run in Lua. | |
| void | misn_runStart (Mission *misn, const char *func) |
| Sets up the mission to run misn_runFunc. | |
| int | misn_runFunc (const Mission *misn, const char *func, int nargs) |
| Runs a mission set up with misn_runStart. | |
| void | misn_pushMissionData (lua_State *L, const MissionData *md) |
Variables | |
| static const luaL_Reg | misn_methods [] |
Handles the mission Lua bindings.
Definition in file nlua_misn.c.
|
static |
Attempts to accept the mission.
Note: there is no limit on the maximum number of missions a player can have simultaneously.
Lua usage parameter: if not misn.accept() then return end Lua return parameter: boolean true if mission was properly accepted.
| L | Lua State |
Lua function: accept
Definition at line 616 of file nlua_misn.c.
|
static |
Adds some mission cargo to the player. They cannot sell it nor get rid of it unless they abandons the mission in which case it'll get eliminated.
Lua function parameter: Commodity|string cargo Type of cargo to add, either as a Commodity object or as the raw (untranslated) name of a commodity. Lua function parameter: number quantity Quantity of cargo to add. Lua return parameter: number The id of the cargo which can be used in cargoRm.
| L | Lua State |
Lua function: cargoAdd
Definition at line 699 of file nlua_misn.c.
|
static |
Jettisons the mission cargo.
Lua function parameter: number cargoid ID of the cargo to jettison. Lua return parameter: boolean true on success.
| L | Lua State |
Lua function: cargoJet
Definition at line 755 of file nlua_misn.c.
|
static |
Removes the mission cargo.
Lua function parameter: number cargoid Identifier of the mission cargo. Lua return parameter: boolean true on success.
| L | Lua State |
Lua function: cargoRm
Definition at line 725 of file nlua_misn.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 misn.claim( { system.get("Gamma Polaris") } ) then misn.finish( false ) end Lua usage parameter: if not misn.claim( system.get("Gamma Polaris") ) then misn.finish( false ) end Lua usage parameter: if not misn.claim( 'some_string' ) then misn.finish( false ) end Lua usage parameter: if not misn.claim( { system.get("Gamma Polaris"), 'some_string' } ) then misn.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 1036 of file nlua_misn.c.
|
static |
Refreshes the mission computer offerings.
Do not use from a mission 'create' function.
| L | Lua State |
Lua function: computerRefresh
Definition at line 1151 of file nlua_misn.c.
|
static |
Gets the factions the mission is available for.
Lua usage parameter: f = misn.factions() Lua return parameter: {Faction,...} A table containing the factions for whom the mission is available.
| L | Lua State |
Lua function: factions
Definition at line 592 of file nlua_misn.c.
|
static |
Finishes the mission.
Lua function parameter:[opt] boolean properly If true and the mission is unique it marks the mission as completed. If false it deletes the mission but doesn't mark it as completed. If the parameter isn't passed it just ends the mission (without removing it from the player's list of active missions).
| L | Lua State |
Lua function: finish
Definition at line 671 of file nlua_misn.c.
| Mission * misn_getFromLua | ( | lua_State * | L | ) |
Gets the mission that's being currently run in Lua.
This should ONLY be called below an nlua_pcall, so __NLUA_CURENV is set
Definition at line 180 of file nlua_misn.c.
| int misn_loadLibs | ( | nlua_env | env | ) |
Registers all the mission libraries.
| env | Lua environment. |
Definition at line 115 of file nlua_misn.c.
|
static |
Adds a new marker.
Lua usage parameter: my_marker = misn.markerAdd( system.get("Gamma Polaris"), "low" )
Valid marker types are:
"computer": Mission computer marker.
Lua function parameter: System|Spob target System or spob to mark. Lua function parameter:[opt="high"] string type Colouring scheme to use. Lua return parameter: number A marker ID to be used with markerMove and markerRm.
| L | Lua State |
Lua function: markerAdd
Definition at line 390 of file nlua_misn.c.
|
static |
Moves a marker to a new system.
Lua usage parameter: misn.markerMove( my_marker, system.get("Delta Pavonis") )
Lua function parameter: number id ID of the mission marker to move. Lua function parameter: System sys System to move the marker to.
| L | Lua State |
Lua function: markerMove
Definition at line 445 of file nlua_misn.c.
|
static |
Removes a mission system marker.
Lua usage parameter: misn.markerRm( my_marker )
Lua function parameter:[opt] number id ID of the marker to remove. If no parameter is passed, all markers associated with the mission are removed.
| L | Lua State |
Lua function: markerRm
Definition at line 496 of file nlua_misn.c.
|
static |
Adds an NPC.
Lua usage parameter: npc_id = misn.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 951 of file nlua_misn.c.
|
static |
Removes an NPC.
Lua usage parameter: misn.npcRm( npc_id )
Lua function parameter: number id ID of the NPC to remove.
| L | Lua State |
Lua function: npcRm
Definition at line 997 of file nlua_misn.c.
|
static |
Sets active in mission OSD.
Lua function parameter: number n Element of the OSD to make active.
| L | Lua State |
Lua function: osdActive
Definition at line 869 of file nlua_misn.c.
|
static |
Creates a mission OSD.
Lua usage parameter: misn.osdCreate( "My OSD", {"Element 1", "Element 2"})
Lua function parameter: string title Title to give the OSD. Lua function parameter: {string,...} list List of elements to put in the OSD.
| L | Lua State |
Lua function: osdCreate
Definition at line 790 of file nlua_misn.c.
|
static |
Destroys the mission OSD.
| L | Lua State |
Lua function: osdDestroy
Definition at line 849 of file nlua_misn.c.
|
static |
Gets the current mission OSD information.
Lua return parameter: string Title of the OSD. Lua return parameter: table List of items in the OSD. Lua return parameter: number ID of the current active OSD element.
| L | Lua State |
Lua function: osdGet
Definition at line 913 of file nlua_misn.c.
|
static |
Gets the active OSD element.
Lua return parameter: number|nil The active element or nil if not active.
| L | Lua State |
Lua function: osdGetActive
Definition at line 891 of file nlua_misn.c.
| void misn_pushMissionData | ( | lua_State * | L, |
| const MissionData * | md ) |
Definition at line 1085 of file nlua_misn.c.
| int misn_run | ( | Mission * | misn, |
| const char * | func ) |
Runs a mission function.
| misn | Mission that owns the function. |
| func | Name of the function to call. |
Definition at line 169 of file nlua_misn.c.
| int misn_runFunc | ( | const Mission * | misn, |
| const char * | func, | ||
| int | nargs ) |
Runs a mission set up with misn_runStart.
| misn | Mission that owns the function. |
| func | Name of the function to call. |
| nargs | Number of arguments to pass. |
Definition at line 215 of file nlua_misn.c.
| void misn_runStart | ( | Mission * | misn, |
| const char * | func ) |
Sets up the mission to run misn_runFunc.
Definition at line 195 of file nlua_misn.c.
|
static |
Sets the current mission description.
Also sets the mission OSD unless you explicitly force an OSD, however you can't specify bullet points or other fancy things like with the real OSD.
Lua function parameter: string desc Description to use for mission.
| L | Lua State |
Lua function: setDesc
Definition at line 292 of file nlua_misn.c.
|
static |
Sets the distance to the mission's goal. Used for sorting missions in the mission computer. Unused otherwise.
Lua function parameter: number Distance from the current player position.
| L | Lua State |
Lua function: setDistance
Definition at line 334 of file nlua_misn.c.
|
static |
Sets the faction giver of the mission. Used mainly as metadata for sorting and organizing missions in the mission computer.
Lua function parameter: faction Faction to set the mission to or nil to disable.
| L | Lua State |
Lua function: setFaction
Definition at line 364 of file nlua_misn.c.
|
static |
Marks whether or not a mission should be considered illegal in the current system. Used for filtering missions at the mission computer, unused otherwise.
Lua function parameter: boolean Whether or not the mission should be considered illegal.
| L | Lua State |
Lua function: setIllegal
Definition at line 350 of file nlua_misn.c.
|
static |
Sets the current mission NPC.
This is used in bar missions where you talk to a person. The portraits are the ones found in GFX_PATH/portraits. (For GFX_PATH/portraits/none.webp you would use "none.webp".)
Note that this NPC will disappear when either misn.accept() or misn.finish() is called.
Lua usage parameter: misn.setNPC( "Invisible Man", "none.webp", _("You see a levitating mug drain itself.") )
Lua function parameter: string name Name of the NPC. Lua function parameter: string portrait File name of the portrait to use for the NPC. Lua function parameter: string desc Description of the NPC to use.
| L | Lua State |
Lua function: setNPC
Definition at line 552 of file nlua_misn.c.
|
static |
Sets the current mission reward description.
Lua function parameter: string|number reward Description of the reward to use. Can pass a number to signify a monetary reward, and allow for sorting.
| L | Lua State |
Lua function: setReward
Definition at line 307 of file nlua_misn.c.
|
static |
Mission Lua bindings.
Sets the current mission title.
An example would be:
Lua module: misn
Lua function parameter: string title Title to use for mission.
| L | Lua State |
Lua function: setTitle
Definition at line 275 of file nlua_misn.c.
| int misn_tryRun | ( | Mission * | misn, |
| const char * | func ) |
Tries to run a mission, but doesn't err if it fails.
| misn | Mission that owns the function. |
| func | Name of the function to call. |
Definition at line 148 of file nlua_misn.c.
| int nlua_loadMisn | ( | nlua_env | env | ) |
Loads the mission Lua library.
| env | Lua environment. |
Definition at line 134 of file nlua_misn.c.
|
static |
Mission Lua methods.
Definition at line 81 of file nlua_misn.c.