naev 0.12.5
nlua_camera.c File Reference

Bindings for Camera functionality from Lua. More...

#include "nlua_camera.h"
#include "camera.h"
#include "conf.h"
#include "nlua_pilot.h"
#include "nlua_vec2.h"
#include "nluadef.h"
#include "player.h"
#include "spfx.h"
Include dependency graph for nlua_camera.c:

Go to the source code of this file.

Functions

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

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()

int camL_get ( lua_State * L)
static

Gets the x/y position and zoom of the camera.

Lua return parameter: number X position of the camera. Lua return parameter: number Y position of the camera. Lua return parameter: number Zoom level of the camera.

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

Lua function: get

Definition at line 130 of file nlua_camera.c.

◆ camL_getZoom()

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 201 of file nlua_camera.c.

◆ camL_pos()

int camL_pos ( 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 146 of file nlua_camera.c.

◆ camL_set()

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 81 of file nlua_camera.c.

◆ camL_setZoom()

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 171 of file nlua_camera.c.

◆ camL_shake()

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: number amplitude Amplitude of the shaking.

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

Lua function: shake

Definition at line 218 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 48 of file nlua_camera.c.

Variable Documentation

◆ cameraL_methods

const luaL_Reg cameraL_methods[]
static
Initial value:
= {
{ "get", camL_get },
{ "set", camL_set },
{ "pos", camL_pos },
{ "setZoom", camL_setZoom },
{ "getZoom", camL_getZoom },
{ "shake", camL_shake },
{ 0, 0 } }
static int camL_get(lua_State *L)
Gets the x/y position and zoom of the camera.
static int camL_shake(lua_State *L)
Makes the camera shake.
static int camL_pos(lua_State *L)
Gets the camera position.
static int camL_getZoom(lua_State *L)
Gets the camera zoom.
static int camL_setZoom(lua_State *L)
Sets the camera zoom.
static int camL_set(lua_State *L)
Lua bindings to interact with the Camera.
Definition nlua_camera.c:81

Camera Lua methods.

Definition at line 33 of file nlua_camera.c.