naev 0.12.5
nlua_hook.c File Reference

Lua hook module. More...

#include "nlua_hook.h"
#include "array.h"
#include "event.h"
#include "hook.h"
#include "mission.h"
#include "nlua_evt.h"
#include "nlua_misn.h"
#include "nlua_pilot.h"
#include "nlua_time.h"
#include "nluadef.h"
Include dependency graph for nlua_hook.c:

Go to the source code of this file.

Functions

static int hookL_rm (lua_State *L)
 Lua bindings to manipulate hooks.
static int hookL_load (lua_State *L)
 Hooks the function to the player loading the game (starts landed).
static int hookL_land (lua_State *L)
 Hooks the function to the player landing.
static int hookL_info (lua_State *L)
 Hooks the function to the info menu.
static int hookL_takeoff (lua_State *L)
 Hooks the function to the player taking off.
static int hookL_jumpout (lua_State *L)
 Hooks the function to the player jumping (before changing systems).
static int hookL_jumpin (lua_State *L)
 Hooks the function to the player jumping (after changing systems).
static int hookL_enter (lua_State *L)
 Hooks the function to the player entering a system (triggers when taking off too).
static int hookL_hail (lua_State *L)
 Hooks the function to the player hailing any ship (not a spob).
static int hookL_hail_spob (lua_State *L)
 Hooks the function to the player hailing any spob.
static int hookL_board (lua_State *L)
 Hooks the function to the player boarding any ship.
static int hookL_timer (lua_State *L)
 Hooks a timer.
static int hookL_timerClear (lua_State *L)
 Clear all timers added by hook.timer. This only affects timers created by the mission or event calling this function.
static int hookL_date (lua_State *L)
 Hooks a date change with custom resolution.
static int hookL_commbuy (lua_State *L)
 Hooks the function to the player buying any sort of commodity.
static int hookL_commsell (lua_State *L)
 Hooks the function to the player selling any sort of commodity.
static int hookL_commjettison (lua_State *L)
 Hooks the function to the player jettisoning any sort of commodity.
static int hookL_gather (lua_State *L)
 Hooks the function to the player gatehring any sort of commodity in space.
static int hookL_outfitbuy (lua_State *L)
 Hooks the function to the player buying any sort of outfit.
static int hookL_outfitsell (lua_State *L)
 Hooks the function to the player selling any sort of outfit.
static int hookL_shipbuy (lua_State *L)
 Hooks the function to the player buying any sort of ship.
static int hookL_shipsell (lua_State *L)
 Hooks the function to the player selling any sort of ship.
static int hookL_shipswap (lua_State *L)
 Hooks the function to the player swapping their ship.
static int hookL_equip (lua_State *L)
 Hooks the function to the player equipping or deequipping any outfit.
static int hookL_input (lua_State *L)
 Hooks the function to the player pressing any input.
static int hookL_mouse (lua_State *L)
 Hooks the function to the player clicking the mouse.
static int hookL_safe (lua_State *L)
 Hook run once at the end of the next frame regardless of anything that can happen.
static int hookL_update (lua_State *L)
 Hook run at the end of each frame when the update routine is run (game is not paused, etc.).
static int hookL_renderbg (lua_State *L)
 Hook that runs during rendering the background (just above the static background stuff). Meant to be only for rendering things.
static int hookL_renderfg (lua_State *L)
 Hook that runs during rendering the foreground (just below the gui stuff). Meant to be only for rendering things.
static int hookL_rendertop (lua_State *L)
 Hook that runs during rendering aove everything. Meant to be as an alternative to doing post-processing shader effects.
static int hookL_mission_done (lua_State *L)
 Hook that runs when a mission is complete. The entire mission information table is passed similar to player.evtDoneList().
static int hookL_event_done (lua_State *L)
 Hook that runs when a event is complete. The entire event information table is passed similar to player.evtDoneList().
static int hookL_standing (lua_State *L)
 Hooks the function to any faction standing change.
static int hookL_discover (lua_State *L)
 Hooks the function to when the player discovers an spob, jump point or the likes.
static int hookL_asteroidScan (lua_State *L)
 Hooks the function to when the player scans an asteroid.
static int hookL_pay (lua_State *L)
 Hooks the function to when the player receives or loses money through player.pay() (the Lua function only).
static int hookL_custom (lua_State *L)
 Hook run once at the end of the next frame regardless when manually triggered. Can be triggered manually with naev.trigger.
static int hookL_pilot (lua_State *L)
 Hooks the function to a specific pilot.
static int hookL_setarg (unsigned int hook, int ind)
 Sets a Lua argument for a hook.
static unsigned int hookL_generic (lua_State *L, const char *stack, double sec, int pos, ntime_t date, int arg)
 Creates a mission hook to a certain stack.
int nlua_loadHook (nlua_env env)
 Loads the hook Lua library.
void hookL_unsetarg (unsigned int hook)
 Unsets a Lua argument.
int hookL_getarg (unsigned int hook)
 Gets a Lua argument for a hook.

Variables

static const luaL_Reg hookL_methods []

Detailed Description

Lua hook module.

Definition in file nlua_hook.c.

Function Documentation

◆ hookL_asteroidScan()

int hookL_asteroidScan ( lua_State * L)
static

Hooks the function to when the player scans an asteroid.

The parameter passed to the function is the asteroid scanned.

Lua function parameter: string funcname Name of the function to run when the hook is triggered. Lua function parameter: arg Argument to pass to the hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: asteroid_scan

Definition at line 846 of file nlua_hook.c.

◆ hookL_board()

int hookL_board ( lua_State * L)
static

Hooks the function to the player boarding any ship.

The hook receives a single parameter which is the ship being boarded.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: board

Definition at line 510 of file nlua_hook.c.

◆ hookL_commbuy()

int hookL_commbuy ( lua_State * L)
static

Hooks the function to the player buying any sort of commodity.

The hook receives the commodity bought and the quantity being bought.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: comm_buy

Definition at line 595 of file nlua_hook.c.

◆ hookL_commjettison()

int hookL_commjettison ( lua_State * L)
static

Hooks the function to the player jettisoning any sort of commodity.

The hook receives the commodity and the quantity jettisoned.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: comm_jettison

Definition at line 629 of file nlua_hook.c.

◆ hookL_commsell()

int hookL_commsell ( lua_State * L)
static

Hooks the function to the player selling any sort of commodity.

The hook receives the commodity sold and the quantity being sold.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: comm_sell

Definition at line 612 of file nlua_hook.c.

◆ hookL_custom()

int hookL_custom ( lua_State * L)
static

Hook run once at the end of the next frame regardless when manually triggered. Can be triggered manually with naev.trigger.

Lua function parameter: string hookname Name to give the hook. This should not overlap with standard names. Lua function parameter: string funcname Name of function to run when hook is triggered. Lua return parameter: number Hook identifier.

See also
naev.trigger
Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: custom

Definition at line 1005 of file nlua_hook.c.

◆ hookL_date()

int hookL_date ( lua_State * L)
static

Hooks a date change with custom resolution.

The hook receives only the optional argument.

Lua usage parameter: hook.date( time.new( 0, 0, 1000 ), "some_func", nil ) – Hooks with a 1000 second resolution

Lua function parameter: Time resolution Resolution of the timer (should be a time structure). Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: date

Definition at line 577 of file nlua_hook.c.

◆ hookL_discover()

int hookL_discover ( lua_State * L)
static

Hooks the function to when the player discovers an spob, jump point or the likes.

The parameters passed to the function are the type which can be one of:

  • "spob"
  • "jump"
    and the actual spob or jump point discovered with the following format:
    function f( type, discovery )

    Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

    Parameters
    LLua State
    Returns
    Number of variables on the Lua State stack.

    Lua function: discover

Definition at line 828 of file nlua_hook.c.

◆ hookL_enter()

int hookL_enter ( lua_State * L)
static

Hooks the function to the player entering a system (triggers when taking off too).

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: enter

Definition at line 459 of file nlua_hook.c.

◆ hookL_equip()

int hookL_equip ( lua_State * L)
static

Hooks the function to the player equipping or deequipping any outfit.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: equip

Definition at line 696 of file nlua_hook.c.

◆ hookL_event_done()

int hookL_event_done ( lua_State * L)
static

Hook that runs when a event is complete. The entire event information table is passed similar to player.evtDoneList().

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: event_done

Definition at line 987 of file nlua_hook.c.

◆ hookL_gather()

int hookL_gather ( lua_State * L)
static

Hooks the function to the player gatehring any sort of commodity in space.

The hook receives the commodity and the quantity being gathered.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: gather

Definition at line 647 of file nlua_hook.c.

◆ hookL_generic()

unsigned int hookL_generic ( lua_State * L,
const char * stack,
double sec,
int pos,
ntime_t date,
int arg )
static

Creates a mission hook to a certain stack.

Basically a generic approach to hooking.

Parameters
LLua state.
stackStack to put the hook in.
secSeconds to delay (pass stack as NULL to set as timer).
posPosition in the stack of the function name.
dateResolution of the timer. (If passed, create a date-based hook.)
argPosition where the arguments start.
Returns
The hook ID or 0 on error.

Definition at line 256 of file nlua_hook.c.

◆ hookL_getarg()

int hookL_getarg ( unsigned int hook)

Gets a Lua argument for a hook.

Parameters
hookHook to get argument of.
Returns
Number of arguments added.

Definition at line 224 of file nlua_hook.c.

◆ hookL_hail()

int hookL_hail ( lua_State * L)
static

Hooks the function to the player hailing any ship (not a spob).

The hook receives a single parameter which is the ship being hailed.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hail

Definition at line 493 of file nlua_hook.c.

◆ hookL_hail_spob()

int hookL_hail_spob ( lua_State * L)
static

Hooks the function to the player hailing any spob.

The hook receives a single parameter which is the spob being hailed.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hail_spob

Definition at line 476 of file nlua_hook.c.

◆ hookL_info()

int hookL_info ( lua_State * L)
static

Hooks the function to the info menu.

Can also be used to hook the various subparts of the info menu. Possible targets for where are:

  • "main"
  • "ship"
  • "weapons"
  • "cargo"
  • "mission"
  • "standing"
  • "shiplog"

Lua usage parameter: hook.info( "my_function" ) – Info calls my_function Lua usage parameter: hook.info( "my_function", "equipment" ) – Calls my_function at equipment screen

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter:[opt] string where Where to hook the function. Defaults to any. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: info

Definition at line 371 of file nlua_hook.c.

◆ hookL_input()

int hookL_input ( lua_State * L)
static

Hooks the function to the player pressing any input.

It returns the name of the key being pressed like "accel" and whether or not it's a press.

Functions should be in format:
function f( inputname, inputpress, args )

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: input

Definition at line 768 of file nlua_hook.c.

◆ hookL_jumpin()

int hookL_jumpin ( lua_State * L)
static

Hooks the function to the player jumping (after changing systems).

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: jumpin

Definition at line 443 of file nlua_hook.c.

◆ hookL_jumpout()

int hookL_jumpout ( lua_State * L)
static

Hooks the function to the player jumping (before changing systems).

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: jumpout

Definition at line 428 of file nlua_hook.c.

◆ hookL_land()

int hookL_land ( lua_State * L)
static

Hooks the function to the player landing.

Can also be used to hook the various subparts of the landing menu. Possible targets for where are:

  • "land" - when landed (default with no parameter )
  • "outfits" - when visited outfitter
  • "shipyard" - when visited shipyard
  • "bar" - when visited bar
  • "mission" - when visited mission computer
  • "commodity" - when visited commodity exchange
  • "equipment" - when visiting equipment place

Lua usage parameter: hook.land( "my_function" ) – Land calls my_function Lua usage parameter: hook.land( "my_function", "equipment" ) – Calls my_function at equipment screen

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter:[opt] string where Where to hook the function. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: land

Definition at line 333 of file nlua_hook.c.

◆ hookL_load()

int hookL_load ( lua_State * L)
static

Hooks the function to the player loading the game (starts landed).

Lua usage parameter: hook.load( "my_function" ) – Load calls my_function

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: load

Definition at line 398 of file nlua_hook.c.

◆ hookL_mission_done()

int hookL_mission_done ( lua_State * L)
static

Hook that runs when a mission is complete. The entire mission information table is passed similar to player.evtDoneList().

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: mission_done

Definition at line 971 of file nlua_hook.c.

◆ hookL_mouse()

int hookL_mouse ( lua_State * L)
static

Hooks the function to the player clicking the mouse.

The parameter passed to the function is the button pressed (1==left,2==middle,3==right), and whether it is a down (true) or up (false) event.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: mouse

Definition at line 787 of file nlua_hook.c.

◆ hookL_outfitbuy()

int hookL_outfitbuy ( lua_State * L)
static

Hooks the function to the player buying any sort of outfit.

The hook receives the name of the outfit and the quantity being bought.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfit_buy

Definition at line 664 of file nlua_hook.c.

◆ hookL_outfitsell()

int hookL_outfitsell ( lua_State * L)
static

Hooks the function to the player selling any sort of outfit.

The hook receives the name of the outfit and the quantity being sold.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfit_sell

Definition at line 681 of file nlua_hook.c.

◆ hookL_pay()

int hookL_pay ( lua_State * L)
static

Hooks the function to when the player receives or loses money through player.pay() (the Lua function only).

The amount paid (or taken from the player) and reason (which is nil by default) is passed as a parameter:
function f( amount, reason, args )

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: pay

Definition at line 865 of file nlua_hook.c.

◆ hookL_pilot()

int hookL_pilot ( lua_State * L)
static

Hooks the function to a specific pilot.

These hooks only live in the current system and get reset every time the player enters a new system.

You can hook to different actions. Currently hook system only supports:

  • "creation" : triggered when a pilot is created.
  • "death" : triggered when pilot dies (before marked as dead).
  • "exploded" : triggered when pilot has died and the final explosion has begun.
  • "boarding" : triggered when a pilot boards another ship (start of boarding).
  • "board" : triggered when a pilot is boarded by the player (start of boarding).
  • "boardall" : triggered when a pilot is boarded by any pilot (start of boarding).
  • "disable" : triggered when pilot is disabled (with disable set).
  • "undisable" : triggered when pilot recovers from being disabled.
  • "jump" : triggered when pilot jumps to hyperspace (before he actually jumps out).
  • "hail" : triggered when pilot is hailed.
  • "land" : triggered when pilot is landing (right when starting land descent).
  • "attacked" : triggered when the pilot is attacked.
  • "discovered" : triggered when the pilot is in stealth and discovered by another pilot (not necessarily the player).
  • "idle" : triggered when the pilot becomes idle in manual control.
  • "lockon" : triggered when the pilot locked on a missile on its target.
  • "stealth" : triggered when the pilot either enters or leaves stealth.
  • "scanned" : triggered when the pilot is scanned by another pilot.
  • "scan" : triggered when the pilot scans another pilot.


If you pass nil as pilot, it will set it as a global hook that will jump for all pilots.

DO NOT DO UNSAFE THINGS IN PILOT HOOKS. THIS MEANS STUFF LIKE player.teleport(). IF YOU HAVE DOUBTS USE A "safe" HOOK.

These hooks all pass the pilot triggering the hook as a parameter, so they should have the structure of:

function my_hook( pilot, arg )
end

The combat hooks also pass the pilot acting on it, so for example the pilot that disabled, attacked or killed the selected pilot. They have the following format:

function combat_hook( pilot, attacker, arg )
end

Please note that in the case of disable or death hook the attacker may be nil indicating that it was killed by other means like for example the shockwave of a dying ship or nebula volatility.

The land and jump hooks also pass the spob or jump point the pilot is landing at or jumped from, respectively:

function land_hook( pilot, spob, arg )
end

function jump_hook( pilot, jump_point, arg )
end

The stealth hook passes whether or not the ship is stealthing or destealthing as a boolean:

function stealth_hook( pilot, status, arg )
end

Lua function parameter: Pilot|nil pilot Pilot identifier to hook (or nil for all). Lua function parameter: string type One of the supported hook types. Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: pilot

Definition at line 1079 of file nlua_hook.c.

◆ hookL_renderbg()

int hookL_renderbg ( lua_State * L)
static

Hook that runs during rendering the background (just above the static background stuff). Meant to be only for rendering things.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: renderbg

Definition at line 923 of file nlua_hook.c.

◆ hookL_renderfg()

int hookL_renderfg ( lua_State * L)
static

Hook that runs during rendering the foreground (just below the gui stuff). Meant to be only for rendering things.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: renderfg

Definition at line 939 of file nlua_hook.c.

◆ hookL_rendertop()

int hookL_rendertop ( lua_State * L)
static

Hook that runs during rendering aove everything. Meant to be as an alternative to doing post-processing shader effects.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: rendertop

Definition at line 955 of file nlua_hook.c.

◆ hookL_rm()

int hookL_rm ( lua_State * L)
static

Lua bindings to manipulate hooks.

Hooks allow you to trigger functions to certain actions like when the player jumps or a pilot dies.

They can have arguments passed to them which will then get passed to the called hook function.

Example usage would be:

function penter( arg )
-- Function to run when player enters a system
end
hookid = hook.enter( "penter", 5 )
Player_t player
Definition player.c:77

Lua module: hook

Removes a hook previously created.

Lua usage parameter: hook.rm( h ) – Hook is removed

Lua function parameter: number h Identifier of the hook to remove.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: rm

Definition at line 160 of file nlua_hook.c.

◆ hookL_safe()

int hookL_safe ( lua_State * L)
static

Hook run once at the end of the next frame regardless of anything that can happen.

This hook is a good way to do possibly breaking stuff like for example player.teleport().

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: safe

Definition at line 884 of file nlua_hook.c.

◆ hookL_setarg()

int hookL_setarg ( unsigned int hook,
int ind )
static

Sets a Lua argument for a hook.

Parameters
hookHook to set argument for.
indIndex of argument to set.
Returns
0 on success.

Definition at line 178 of file nlua_hook.c.

◆ hookL_shipbuy()

int hookL_shipbuy ( lua_State * L)
static

Hooks the function to the player buying any sort of ship.

The hook receives the name of the ship type bought.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: ship_buy

Definition at line 713 of file nlua_hook.c.

◆ hookL_shipsell()

int hookL_shipsell ( lua_State * L)
static

Hooks the function to the player selling any sort of ship.

The hook receives the name of the ship type sold and the player-given name of the ship.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: ship_sell

Definition at line 731 of file nlua_hook.c.

◆ hookL_shipswap()

int hookL_shipswap ( lua_State * L)
static

Hooks the function to the player swapping their ship.

The hook receives the name of the ship swapped to and the name of the ship swapped from (if applicable).

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: ship_swap

Definition at line 749 of file nlua_hook.c.

◆ hookL_standing()

int hookL_standing ( lua_State * L)
static

Hooks the function to any faction standing change.

The parameters passed to the function are faction whose standing is being changed and the amount changed:
function f( faction, change, system, secondary, primary_fct, args )

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: standing

Definition at line 806 of file nlua_hook.c.

◆ hookL_takeoff()

int hookL_takeoff ( lua_State * L)
static

Hooks the function to the player taking off.

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: takeoff

Definition at line 413 of file nlua_hook.c.

◆ hookL_timer()

int hookL_timer ( lua_State * L)
static

Hooks a timer.

The hook receives only the optional argument.

Lua function parameter: number s Seconds to delay. Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: timer

Definition at line 528 of file nlua_hook.c.

◆ hookL_timerClear()

int hookL_timerClear ( lua_State * L)
static

Clear all timers added by hook.timer. This only affects timers created by the mission or event calling this function.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: timerClear

Definition at line 542 of file nlua_hook.c.

◆ hookL_unsetarg()

void hookL_unsetarg ( unsigned int hook)

Unsets a Lua argument.

Definition at line 201 of file nlua_hook.c.

◆ hookL_update()

int hookL_update ( lua_State * L)
static

Hook run at the end of each frame when the update routine is run (game is not paused, etc.).

It is closely related to hook.safe(), but you have to manually remove it or it continues forever.

The current delta-tick (time passed in game) and real delta-tick (independent of game status) are passed as parameters:
function f( dt, real_dt, args )

Lua function parameter: string funcname Name of function to run when hook is triggered. Lua function parameter: arg Argument to pass to hook. Lua return parameter: number Hook identifier.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: update

Definition at line 907 of file nlua_hook.c.

◆ nlua_loadHook()

int nlua_loadHook ( nlua_env env)

Loads the hook Lua library.

Parameters
envLua environment.
Returns
0 on success.

Definition at line 125 of file nlua_hook.c.

Variable Documentation

◆ hookL_methods

const luaL_Reg hookL_methods[]
static

Hook Lua methods.

Definition at line 71 of file nlua_hook.c.