Naev

Module evt

Event system Lua bindings.

An example would be:

 evt.finish() -- finishes the event
 

Functions

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


Functions

npcAdd (func, name, portrait, desc[, priority=5[, background=nil]])
Adds an NPC.

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 file name 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)
  • background string Background file name to use (from GFX_PATH/portraits/). (default nil)

Returns:

    number The ID of the NPC to pass to npcRm.

Usage:

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

Parameters:

  • id number ID of the NPC to remove.

Usage:

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

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.

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[, inclusive=false])
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.

Parameters:

  • params System, String or {System,String...} Table of systems/strings to claim or a single system/string.
  • inclusive boolean 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. (default false)

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.5.0 Last updated 2024-04-18 17:19:01