Naev

Module misn

Mission Lua bindings.

An example would be:

 misn.setNPC( "Keer", "empire/unique/keer" )
 misn.setDesc( "You see here Commodore Keer." )
 

Functions

setTitle (title) Sets the current mission title.
setDesc (desc) Sets the current mission description.
setReward (reward) Sets the current mission reward description.
markerAdd (sys, type) Adds a new marker.
markerMove (id, sys) Moves a marker to a new system.
markerRm (id) Removes a mission system marker.
setNPC (name, portrait) Sets the current mission NPC.
factions () Gets the factions the mission is available for.
accept () Attempts to accept the mission.
finish ([properly]) Finishes the mission.
cargoAdd (cargo, quantity) Adds some mission cargo to the player.
cargoRm (cargoid) Removes the mission cargo.
cargoJet (cargoid) Jettisons the mission cargo.
osdCreate (title, list) Creates a mission OSD.
osdDestroy () Destroys the mission OSD.
osdActive (n) Sets active in mission OSD.
npcAdd (func, name, portrait, desc[, priority=5]) Adds an NPC.
npcRm (id) Removes an NPC.
claim (params) Tries to claim systems or strings.


Functions

setTitle (title)
Sets the current mission title. ( title )

Parameters:

  • title string Title to use for mission.
setDesc (desc)
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. ( desc )

Parameters:

  • desc string Description to use for mission.
setReward (reward)
Sets the current mission reward description. ( reward )

Parameters:

  • reward string Description of the reward to use.
markerAdd (sys, type)
Adds a new marker. ( sys, type )

Parameters:

  • sys System System to mark.
  • type string Colouring scheme to use.

Returns:

    number A marker ID to be used with markerMove and markerRm.

Usage:

    my_marker = misn.markerAdd( system.get("Gamma Polaris"), "low" )
    
    Valid marker types are:<br/>
     - "plot": Important plot marker.<br/>
     - "high": High importance mission marker (lower than plot).<br/>
     - "low": Low importance mission marker (lower than high).<br/>
     - "computer": Mission computer marker.<br/>
markerMove (id, sys)
Moves a marker to a new system. ( id, sys )

Parameters:

  • id number ID of the mission marker to move.
  • sys System System to move the marker to.

Usage:

    misn.markerMove( my_marker, system.get("Delta Pavonis") )
markerRm (id)
Removes a mission system marker. ( id )

Parameters:

  • id number ID of the marker to remove.

Usage:

    misn.markerRm( my_marker )
setNPC (name, portrait)
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 without the png extension. So for GFX_PATH/portraits/none.png you would just use "none". ( name, portrait )

Parameters:

  • name string Name of the NPC.
  • portrait string Name of the portrait to use for the NPC.

Usage:

    misn.setNPC( "Invisible Man", "none" )
factions ()
Gets the factions the mission is available for. ()

Returns:

    {Faction,...} A table containing the factions for whom the mission is available.

Usage:

    f = misn.factions()
accept ()
Attempts to accept the mission. ()

Returns:

    boolean true if mission was properly accepted.

Usage:

    if not misn.accept() then return end
finish ([properly])
Finishes the mission. ( properly )

Parameters:

  • properly boolean 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). (optional)
cargoAdd (cargo, quantity)
Adds some mission cargo to the player. He cannot sell it nor get rid of it unless he abandons the mission in which case it'll get eliminated. ( cargo, quantity )

Parameters:

  • cargo string Name of the cargo to add. This must match a cargo name defined in commodity.xml.
  • quantity number Quantity of cargo to add.

Returns:

    number The id of the cargo which can be used in cargoRm.
cargoRm (cargoid)
Removes the mission cargo. ( cargoid )

Parameters:

  • cargoid number Identifier of the mission cargo.

Returns:

    boolean true on success.
cargoJet (cargoid)
Jettisons the mission cargo. ( cargoid )

Parameters:

  • cargoid number ID of the cargo to jettison.

Returns:

    boolean true on success.
osdCreate (title, list)
Creates a mission OSD.

( title, list )

Parameters:

  • title string Title to give the OSD.
  • list {string,...} List of elements to put in the OSD.

Usage:

    misn.osdCreate( "My OSD", {"Element 1", "Element 2"})
osdDestroy ()
Destroys the mission OSD. ()
osdActive (n)
Sets active in mission OSD.

( n )

Parameters:

  • n number Element of the OSD to make active.
npcAdd (func, name, portrait, desc[, priority=5])
Adds an NPC.

( func, name, portrait, desc, priority )

Parameters:

  • func string Name of the function to run when approaching, gets passed the npc_id when called.
  • name string Name of the NPC
  • portrait string Portrait to use for the NPC (from GFX_PATH/portraits*.png).
  • desc string Description associated to the NPC.
  • priority number Optional priority argument (highest is 0, lowest is 10). (default 5)

Returns:

    number The ID of the NPC to pass to npcRm.

Usage:

    npc_id = misn.npcAdd( "my_func", "Mr. Test", "none", "A test." ) -- Creates an NPC.
npcRm (id)
Removes an NPC. ( id )

Parameters:

  • id number ID of the NPC to remove.

Usage:

    misn.npcRm( npc_id )
claim (params)
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. ( params )

Parameters:

  • params System, String or {System,String...} Table of systems/strings to claim or a single system/string.

Returns:

    boolean true if was able to claim, false otherwise.

Usage:

  • if not misn.claim( { system.get("Gamma Polaris") } ) then misn.finish( false ) end
  • if not misn.claim( system.get("Gamma Polaris") ) then misn.finish( false ) end
  • if not misn.claim( 'some_string' ) then misn.finish( false ) end
  • if not misn.claim( { system.get("Gamma Polaris"), 'some_string' } ) then misn.finish( false ) end
generated by LDoc 1.4.6 Last updated 2020-11-30 07:37:22