naev 0.10.4
Functions | Variables
nlua_camera.c File Reference

Bindings for Camera functionality from Lua. More...

#include "nlua_camera.h"
#include "camera.h"
#include "conf.h"
#include "log.h"
#include "nlua_pilot.h"
#include "nlua_vec2.h"
#include "nluadef.h"
#include "player.h"
#include "spfx.h"

Go to the source code of this file.

Functions

static int camL_set (lua_State *L)
 Lua bindings to interact with the Camera. More...
 
static int camL_get (lua_State *L)
 Gets the camera position. More...
 
static int camL_setZoom (lua_State *L)
 Sets the camera zoom. More...
 
static int camL_getZoom (lua_State *L)
 Gets the camera zoom. More...
 
static int camL_shake (lua_State *L)
 Makes the camera shake. More...
 
int nlua_loadCamera (nlua_env env)
 Loads the camera library. More...
 

Variables

static const luaL_Reg cameraL_methods []
 

Detailed Description

Bindings for Camera functionality from Lua.

Definition in file nlua_camera.c.

Function Documentation

◆ camL_get()

static int camL_get ( lua_State *  L)
static

Gets the camera position.

Lua return parameter: Vec2 Position of the camera.

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

Lua function: get

Definition at line 126 of file nlua_camera.c.

◆ camL_getZoom()

static int camL_getZoom ( lua_State *  L)
static

Gets the camera zoom.

Lua return parameter: number Zoom level of the camera. Lua return parameter: number Maximum zoom level of the camera (furthest). Lua return parameter: number Minimum zoom level of the camera (closest).

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

Lua function: get

Definition at line 178 of file nlua_camera.c.

◆ camL_set()

static int camL_set ( lua_State *  L)
static

Lua bindings to interact with the Camera.

An example would be:

Lua module: camera

Sets the camera.

Make sure to reset camera after using it or we'll run into trouble.

Lua usage parameter: camera.set() – Resets the camera to the pilot hard. Lua usage parameter: camera.set( a_pilot, true ) – Flies camera over to a_pilot. Lua usage parameter: camera.set( vec2.new() ) – Jumps camera to 0,0

Lua function parameter: Pilot|Vec2|nil target It will follow pilots around. If nil, it follows the player. Lua function parameter:[opt=false] boolean hard_over Indicates that the camera should instantly teleport instead of fly over. Lua function parameter:[opt=math.min(2000,distance)] speed Speed at which to fly over if hard_over is false.

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

Lua function: set

Definition at line 77 of file nlua_camera.c.

◆ camL_setZoom()

static int camL_setZoom ( lua_State *  L)
static

Sets the camera zoom.

Make sure to reset camera the zoom after using it or we'll run into trouble.

Lua usage parameter: camera.setZoom() – Resets the camera zoom

Lua function parameter: number zoom Level of zoom to use (1 would indicate 1 unit = 1 pixel while 2 would be 1 unit = 2 pixels) Lua function parameter:[opt=false] boolean hard_over Indicates that the camera should change the zoom gradually instead of instantly. Lua function parameter:[opt=naev.conf().zoom_speed] number speed Rate of change to use.

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

Lua function: setZoom

Definition at line 146 of file nlua_camera.c.

◆ camL_shake()

static int camL_shake ( lua_State *  L)
static

Makes the camera shake.

Lua usage parameter: camera.shake() – Shakes the camera with amplitude 1. Lua usage parameter: camera.shake( 0.5 ) – Shakes the camera with amplitude .5

Lua function parameter: float amplitude: amplitude of the shaking

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

Lua function: shake

Definition at line 195 of file nlua_camera.c.

◆ nlua_loadCamera()

int nlua_loadCamera ( nlua_env  env)

Loads the camera library.

Parameters
envLua environment.
Returns
0 on success.

Definition at line 47 of file nlua_camera.c.

Variable Documentation

◆ cameraL_methods

const luaL_Reg cameraL_methods[]
static
Initial value:
= {
{ "set", camL_set },
{ "get", camL_get },
{ "setZoom", camL_setZoom },
{ "getZoom", camL_getZoom },
{ "shake", camL_shake },
{0,0}
}
static int camL_get(lua_State *L)
Gets the camera position.
Definition: nlua_camera.c:126
static int camL_shake(lua_State *L)
Makes the camera shake.
Definition: nlua_camera.c:195
static int camL_getZoom(lua_State *L)
Gets the camera zoom.
Definition: nlua_camera.c:178
static int camL_setZoom(lua_State *L)
Sets the camera zoom.
Definition: nlua_camera.c:146
static int camL_set(lua_State *L)
Lua bindings to interact with the Camera.
Definition: nlua_camera.c:77

Camera Lua methods.

Definition at line 32 of file nlua_camera.c.