Naev

Module evt

Event system Lua bindings.

An example would be:

 evt.finish() -- finishes the event
 

Functions

npcAdd (func, name, portrait, desc[, priority=5]) Adds an NPC.
npcRm (id) Removes an NPC.
finish ([properly=false]) Finishes the event.
save ([enable=true]) Saves an event.
claim (params) Tries to claim systems or strings.


Functions

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/).
  • 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 = evt.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:

    evt.npcRm( npc_id )
finish ([properly=false])
Finishes the event. ( properly )

Parameters:

  • properly boolean 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. (default false)
save ([enable=true])
Saves an event. ( enable )

Parameters:

  • enable boolean If true sets the event to save, otherwise tells the event to not save. (default true)

Usage:

    evt.save() -- Saves an event, which is by default disabled.
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 evt.claim( { system.get("Gamma Polaris") } ) then evt.finish( false ) end
  • if not evt.claim( system.get("Gamma Polaris") ) then evt.finish( false ) end
  • if not evt.claim( 'some_string' ) then evt.finish( false ) end
  • if not evt.claim( { system.get("Gamma Polaris"), 'some_string' } ) then evt.finish( false ) end
generated by LDoc 1.4.6 Last updated 2020-11-29 22:13:27