naev 0.11.5
nlua_spfx.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include <lauxlib.h>
11#include "physfsrwops.h"
12
13#include "naev.h"
16#include "nlua_spfx.h"
17
18#include "conf.h"
19#include "camera.h"
20#include "debris.h"
21#include "array.h"
22#include "nlua_audio.h"
23#include "nlua_vec2.h"
24#include "nluadef.h"
25#include "sound.h"
26#include "opengl.h"
27#include "nopenal.h"
28#include "player.h"
29
30#define SPFX_GLOBAL (1<<1)
31#define SPFX_RELATIVE (1<<2)
32#define SPFX_MOVING (1<<3)
33#define SPFX_AUDIO (1<<4)
34#define SPFX_CLEANUP (1<<5)
41typedef struct LuaSpfxData_s {
42 int id;
43 unsigned int flags;
44 double ttl;
47 double radius;
48 int data;
52 int update;
53 int remove;
56
60static LuaSpfxData_t *lua_spfx = NULL;
61static LuaSpfxData_t *lua_spfx_queue = NULL;
62static int lua_spfx_idgen = 0;
63static int lua_spfx_lock = 0;
64
65/* Spfx methods. */
66static int spfxL_gc( lua_State *L );
67static int spfxL_eq( lua_State *L );
68static int spfxL_getAll( lua_State *L );
69static int spfxL_new( lua_State *L );
70static int spfxL_rm( lua_State *L );
71static int spfxL_pos( lua_State *L );
72static int spfxL_vel( lua_State *L );
73static int spfxL_setPos( lua_State *L );
74static int spfxL_setVel( lua_State *L );
75static int spfxL_sfx( lua_State *L );
76static int spfxL_data( lua_State *L );
77static int spfxL_debris( lua_State *L );
78static const luaL_Reg spfxL_methods[] = {
79 { "__gc", spfxL_gc },
80 { "__eq", spfxL_eq },
81 { "getAll", spfxL_getAll },
82 { "new", spfxL_new },
83 { "rm", spfxL_rm },
84 { "pos", spfxL_pos },
85 { "vel", spfxL_vel },
86 { "setPos", spfxL_setPos },
87 { "setVel", spfxL_setVel },
88 { "sfx", spfxL_sfx },
89 { "data", spfxL_data },
90 { "debris", spfxL_debris },
91 {0,0}
92};
94static int spfx_cmp( const void *p1, const void *p2 )
95{
96 const LuaSpfxData_t *s1, *s2;
97 s1 = (const LuaSpfxData_t*) p1;
98 s2 = (const LuaSpfxData_t*) p2;
99 return s1->id - s2->id;
100}
101
108int nlua_loadSpfx( nlua_env env )
109{
110 nlua_register(env, SPFX_METATABLE, spfxL_methods, 1);
111 return 0;
112}
113
121LuaSpfx_t* lua_tospfx( lua_State *L, int ind )
122{
123 return (LuaSpfx_t*) lua_touserdata(L,ind);
124}
132LuaSpfx_t* luaL_checkspfx( lua_State *L, int ind )
133{
134 if (lua_isspfx(L,ind))
135 return lua_tospfx(L,ind);
136 luaL_typerror(L, ind, SPFX_METATABLE);
137 return NULL;
138}
139static LuaSpfxData_t* luaL_checkspfxdataNoWarn( lua_State *L, int ind )
140{
141 const LuaSpfx_t *ls = luaL_checkspfx( L , ind );
142 const LuaSpfxData_t key = { .id = *ls };
143 LuaSpfxData_t *f = bsearch( &key, lua_spfx, array_size(lua_spfx), sizeof(LuaSpfxData_t), spfx_cmp );
144 if (f == NULL) {
145 f = bsearch( &key, lua_spfx_queue, array_size(lua_spfx_queue), sizeof(LuaSpfxData_t), spfx_cmp );
146 }
147 return f;
148}
149static LuaSpfxData_t* luaL_checkspfxdata( lua_State *L, int ind )
150{
151 LuaSpfxData_t *f = luaL_checkspfxdataNoWarn( L, ind );
152 if (f == NULL)
153 NLUA_ERROR( L, _("Spfx does not exist.") );
154 return f;
155}
163LuaSpfx_t* lua_pushspfx( lua_State *L, LuaSpfx_t spfx )
164{
165 LuaSpfx_t *la = (LuaSpfx_t*) lua_newuserdata(L, sizeof(LuaSpfx_t));
166 *la = spfx;
167 luaL_getmetatable(L, SPFX_METATABLE);
168 lua_setmetatable(L, -2);
169 return la;
170}
178int lua_isspfx( lua_State *L, int ind )
179{
180 int ret;
181
182 if (lua_getmetatable(L,ind)==0)
183 return 0;
184 lua_getfield(L, LUA_REGISTRYINDEX, SPFX_METATABLE);
185
186 ret = 0;
187 if (lua_rawequal(L, -1, -2)) /* does it have the correct mt? */
188 ret = 1;
189
190 lua_pop(L, 2); /* remove both metatables */
191 return ret;
192}
193
199static void spfx_cleanup( LuaSpfxData_t *ls )
200{
201 /* Unreference stuff so it can get gc'd. */
202 nlua_unref( naevL, ls->data );
203 nlua_unref( naevL, ls->render_bg );
204 nlua_unref( naevL, ls->render_mg );
205 nlua_unref( naevL, ls->render_fg );
206 nlua_unref( naevL, ls->update );
207 nlua_unref( naevL, ls->remove );
208
209 /* Make sure stuff doesn't get run. */
210 ls->data = LUA_NOREF;
211 ls->render_bg = LUA_NOREF;
212 ls->render_mg = LUA_NOREF;
213 ls->render_fg = LUA_NOREF;
214 ls->update = LUA_NOREF;
215 ls->remove = LUA_NOREF;
216
217 /* Clean up audio. */
218 ls->sfx.nocleanup = 0; /* Have to disable so it gets cleaned. */
219 audio_cleanup( &ls->sfx );
220
221 /* Set as cleaned up. */
222 ls->id = -1;
223}
224
237static int spfxL_gc( lua_State *L )
238{
239 LuaSpfx_t *ls = luaL_checkspfx(L,1);
240 (void) ls;
241 return 0;
242}
243
252static int spfxL_eq( lua_State *L )
253{
254 LuaSpfx_t *s1, *s2;
255 s1 = luaL_checkspfx(L,1);
256 s2 = luaL_checkspfx(L,2);
257 lua_pushboolean( L, (memcmp( s1, s2, sizeof(LuaSpfx_t) )==0) );
258 return 1;
259}
260
267static int spfxL_getAll( lua_State *L )
268{
269 int n=1;
270 lua_newtable(L);
271 for (int i=0; i<array_size(lua_spfx); i++) {
272 const LuaSpfxData_t *ls = &lua_spfx[i];
273
274 if (ls->flags & (SPFX_GLOBAL | SPFX_CLEANUP))
275 continue;
276
277 lua_pushspfx( L, ls->id );
278 lua_rawseti( L, -2, n++ );
279 }
280 return 1;
281}
282
303static int spfxL_new( lua_State *L )
304{
305 LuaSpfxData_t ls;
306
307 memset( &ls, 0, sizeof(LuaSpfxData_t) );
308
309 ls.id = ++lua_spfx_idgen;
310 ls.ttl = luaL_checknumber(L,1);
311 ls.update = LUA_NOREF;
312 ls.render_bg = LUA_NOREF;
313 ls.render_mg = LUA_NOREF;
314 ls.render_fg = LUA_NOREF;
315 ls.remove = LUA_NOREF;
316
317 /* Functions. */
318 if (!lua_isnoneornil(L,2))
319 ls.update = nlua_ref( L, 2 );
320 if (!lua_isnoneornil(L,3))
321 ls.render_bg = nlua_ref( L, 3 );
322 if (!lua_isnoneornil(L,4))
323 ls.render_mg = nlua_ref( L, 4 );
324 if (!lua_isnoneornil(L,5))
325 ls.render_fg = nlua_ref( L, 5 );
326
327 /* Position information. */
328 if (!lua_isnoneornil(L,6)) {
329 if (lua_isboolean( L, 6 )) {
330 ls.flags |= SPFX_RELATIVE;
331 if (!lua_toboolean( L, 6 ))
332 ls.flags |= SPFX_GLOBAL;
333 }
334 else
335 ls.pos = *luaL_checkvector( L, 6 );
336 }
337 else
339 if (!lua_isnoneornil(L,7)) {
340 ls.vel = *luaL_checkvector( L, 7 );
341 ls.flags |= SPFX_MOVING;
342 }
343
344 /* Special effect. */
345 if (!lua_isnoneornil(L,8)) {
346 const LuaAudio_t *la = luaL_checkaudio( L, 8 );
347
348 if (!sound_disabled) {
349 ls.flags |= SPFX_AUDIO;
350 audio_clone( &ls.sfx, la );
351 ls.sfx.nocleanup = 1;
352
353 /* Set up parameters. */
354 if (!ls.sfx.ok) {
355 soundLock();
356 alSourcei( ls.sfx.source, AL_LOOPING, AL_FALSE );
357 alSourcef( ls.sfx.source, AL_REFERENCE_DISTANCE, SOUND_REFERENCE_DISTANCE );
358 alSourcef( ls.sfx.source, AL_MAX_DISTANCE, SOUND_MAX_DISTANCE );
359 if (ls.flags & SPFX_RELATIVE) {
360 alSourcei( ls.sfx.source, AL_SOURCE_RELATIVE, AL_TRUE );
361 if (ls.flags & SPFX_GLOBAL)
362 alSourcef( ls.sfx.source, AL_PITCH, 1. );
363 else
364 alSourcef( ls.sfx.source, AL_PITCH, player_dt_default() * player.speed );
365 }
366 else {
367 ALfloat alf[3];
368 alSourcei( ls.sfx.source, AL_SOURCE_RELATIVE, AL_FALSE );
369 alSourcef( ls.sfx.source, AL_PITCH, player_dt_default() * player.speed );
370 alf[0] = ls.pos.x;
371 alf[1] = ls.pos.y;
372 alf[2] = 0.;
373 alSourcefv( ls.sfx.source, AL_POSITION, alf );
374 alf[0] = ls.vel.x;
375 alf[1] = ls.vel.y;
376 alf[2] = 0.;
377 alSourcefv( ls.sfx.source, AL_VELOCITY, alf );
378
379 /* Set the global filter. */
380 if (al_info.efx == AL_TRUE)
381 alSource3i( ls.sfx.source, AL_AUXILIARY_SEND_FILTER, sound_efx_directSlot, 0, AL_FILTER_NULL );
382 }
383 alSourcePlay( ls.sfx.source );
384 al_checkErr();
385 soundUnlock();
386 }
387 }
388 }
389
390 /* Store radius. */
391 ls.radius = luaL_optnumber(L,9,-1.);
392
393 /* Finally remove function if applicable. */
394 if (!lua_isnoneornil(L,10))
395 ls.remove = nlua_ref( L, 10 );
396
397 /* Set up new data. */
398 lua_newtable(L);
399 ls.data = luaL_ref( L, LUA_REGISTRYINDEX ); /* Pops result. */
400
401 /* Add to Lua and stack, depending on if locked or not. */
402 if (lua_spfx_lock) {
403 if (lua_spfx_queue == NULL)
404 lua_spfx_queue = array_create( LuaSpfxData_t );
405 array_push_back( &lua_spfx_queue, ls );
406 }
407 else {
408 if (lua_spfx == NULL)
411 }
412
413 lua_pushspfx( L, ls.id );
414 return 1;
415}
416
423static int spfxL_rm( lua_State *L )
424{
425 LuaSpfxData_t *ls = luaL_checkspfxdataNoWarn(L,1);
426 if (ls != NULL) {
427 if (ls->remove != LUA_NOREF) {
428 lua_rawgeti( naevL, LUA_REGISTRYINDEX, ls->remove );
429 lua_pushspfx( naevL, ls->id );
430 if (lua_pcall( naevL, 1, 0, 0) != 0) {
431 WARN(_("Spfx failed to run 'remove':\n%s"), lua_tostring( naevL, -1 ));
432 lua_pop( naevL, 1 );
433 }
434 }
435
436 ls->flags &= SPFX_CLEANUP;
437 ls->ttl = -1.;
438 }
439 return 0;
440}
441
449static int spfxL_pos( lua_State *L )
450{
451 const LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
452 lua_pushvector( L, ls->pos );
453 return 1;
454}
455
463static int spfxL_vel( lua_State *L )
464{
465 const LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
466 lua_pushvector( L, ls->vel );
467 return 1;
468}
469
477static int spfxL_setPos( lua_State *L )
478{
479 LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
480 const vec2 *v = luaL_checkvector(L,2);
481 ls->pos = *v;
482 return 0;
483}
484
492static int spfxL_setVel( lua_State *L )
493{
494 LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
495 const vec2 *v = luaL_checkvector(L,2);
496 ls->vel = *v;
497 return 0;
498}
499
507static int spfxL_sfx( lua_State *L )
508{
509 const LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
510 lua_pushaudio( L, ls->sfx );
511 return 1;
512}
513
523static int spfxL_data( lua_State *L )
524{
525 LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
526 lua_rawgeti( L, LUA_REGISTRYINDEX, ls->data );
527 return 1;
528}
529
533void spfxL_setSpeed( double s )
534{
535 if (sound_disabled)
536 return;
537
538 soundLock();
539 for (int i=0; i<array_size(lua_spfx); i++) {
540 LuaSpfxData_t *ls = &lua_spfx[i];
541
542 if (!(ls->flags & SPFX_AUDIO))
543 continue;
544
545 if (ls->flags & (SPFX_GLOBAL | SPFX_CLEANUP))
546 continue;
547
548 /* Sound is not valid. */
549 if (ls->sfx.ok)
550 continue;
551
552 alSourcef( ls->sfx.source, AL_PITCH, s );
553 }
554 al_checkErr();
555 soundUnlock();
556}
557
563void spfxL_setSpeedVolume( double v )
564{
565 if (sound_disabled)
566 return;
567
568 soundLock();
569 for (int i=0; i<array_size(lua_spfx); i++) {
570 LuaSpfxData_t *ls = &lua_spfx[i];
571
572 if (!(ls->flags & SPFX_AUDIO))
573 continue;
574
575 if (ls->flags & (SPFX_GLOBAL | SPFX_CLEANUP))
576 continue;
577
578 /* Sound is not valid. */
579 if (ls->sfx.ok)
580 continue;
581
582 alSourcef( ls->sfx.source, AL_GAIN, ls->sfx.volume * v );
583 }
584 al_checkErr();
585 soundUnlock();
586}
587
588static void spfx_lock (void)
589{
590 lua_spfx_lock = 1;
591}
592
593static void spfx_unlock (void)
594{
595 lua_spfx_lock = 0;
596
597 if (lua_spfx_queue==NULL)
598 return;
599
600 for (int i=0; i<array_size(lua_spfx_queue); i++)
601 array_push_back( &lua_spfx, lua_spfx_queue[i] );
602 array_erase( &lua_spfx_queue, array_begin(lua_spfx_queue), array_end(lua_spfx_queue) );
603}
604
608void spfxL_clear (void)
609{
610 for (int i=0; i<array_size(lua_spfx); i++)
611 spfx_cleanup( &lua_spfx[i] );
613 for (int i=0; i<array_size(lua_spfx_queue); i++)
614 spfx_cleanup( &lua_spfx_queue[i] );
615 array_erase( &lua_spfx_queue, array_begin(lua_spfx_queue), array_end(lua_spfx_queue) );
616}
617
618void spfxL_exit (void)
619{
620 spfxL_clear();
622 lua_spfx = NULL;
623 array_free( lua_spfx_queue );
624 lua_spfx_queue = NULL;
625}
626
632void spfxL_update( double dt )
633{
634 spfx_lock();
635 for (int i=array_size(lua_spfx)-1; i>=0; i--) {
636 LuaSpfxData_t *ls = &lua_spfx[i];
637
638 /* Count down. */
639 ls->ttl -= dt;
640 if ((ls->ttl <= 0.) || (ls->flags & SPFX_CLEANUP)) {
641 spfx_cleanup( ls );
642 array_erase( &lua_spfx, &lua_spfx[i], &lua_spfx[i+1] );
643 continue;
644 }
645
646 /* Normal update. */
647 if (ls->flags & SPFX_MOVING) {
648 ls->pos.x += ls->vel.x * dt;
649 ls->pos.y += ls->vel.y * dt;
650
651 /* Check sound. */
652 if ((ls->flags & SPFX_AUDIO) && !(ls->flags & SPFX_RELATIVE) && !ls->sfx.ok) {
653 soundLock();
654 ALfloat alf[3];
655 alf[0] = ls->pos.x;
656 alf[1] = ls->pos.y;
657 alf[2] = 0.;
658 alSourcefv( ls->sfx.source, AL_POSITION, alf );
659 al_checkErr();
660 soundUnlock();
661 }
662 }
663
664 /* Update if necessary. */
665 if (ls->update == LUA_NOREF)
666 continue;
667
668 /* Run update. */
669 lua_rawgeti( naevL, LUA_REGISTRYINDEX, ls->update );
670 lua_pushspfx( naevL, ls->id );
671 lua_pushnumber( naevL, dt );
672 if (lua_pcall( naevL, 2, 0, 0) != 0) {
673 WARN(_("Spfx failed to run 'update':\n%s"), lua_tostring( naevL, -1 ));
674 lua_pop( naevL, 1 );
675 }
676 }
677 spfx_unlock();
678}
679
680static void spfxL_renderLayer( int func, const char *funcname, double dt )
681{
682 double z = cam_getZoom();
683 spfx_lock();
684 for (int i=0; i<array_size(lua_spfx); i++) {
685 vec2 pos;
686 LuaSpfxData_t *ls = &lua_spfx[i];
687 double r = ls->radius;
688 int funcref;
689
690 switch (func) {
691 case 0:
692 funcref = ls->render_bg;
693 break;
694 case 1:
695 funcref = ls->render_mg;
696 break;
697 case 2:
698 funcref = ls->render_fg;
699 break;
700 default:
701 WARN(_("Unknown render layer '%d'!"), func);
702 return;
703 }
704
705 /* Skip no rendering. */
706 if ((funcref == LUA_NOREF) || (ls->flags & SPFX_CLEANUP))
707 continue;
708
709 /* Convert coordinates. */
710 gl_gameToScreenCoords( &pos.x, &pos.y, ls->pos.x, ls->pos.y );
711
712 /* If radius is defined see if in screen. */
713 if ((r > 0.) && ((pos.x < -r) || (pos.y < -r) ||
714 (pos.x > SCREEN_W+r) || (pos.y > SCREEN_H+r)))
715 continue;
716
717 /* Invert y axis. */
718 pos.y = SCREEN_H-pos.y;
719
720 /* Render. */
721 lua_rawgeti( naevL, LUA_REGISTRYINDEX, funcref );
722 lua_pushspfx( naevL, ls->id );
723 lua_pushnumber( naevL, pos.x );
724 lua_pushnumber( naevL, pos.y );
725 lua_pushnumber( naevL, z );
726 lua_pushnumber( naevL, dt );
727 if (lua_pcall( naevL, 5, 0, 0) != 0) {
728 WARN(_("Spfx failed to run '%s':\n%s"), funcname, lua_tostring( naevL, -1 ));
729 lua_pop( naevL, 1 );
730 }
731 }
732 spfx_unlock();
733}
734
738void spfxL_renderbg( double dt )
739{
740 spfxL_renderLayer( 0, "renderbg", dt );
741}
742
746void spfxL_rendermg( double dt )
747{
748 spfxL_renderLayer( 1, "rendermg", dt );
749}
750
754void spfxL_renderfg( double dt )
755{
756 spfxL_renderLayer( 2, "rendermg", dt );
757}
758
768static int spfxL_debris( lua_State *L )
769{
770 double mass = luaL_checknumber( L, 1 );
771 double radius = luaL_checknumber( L, 2 );
772 const vec2 *p = luaL_checkvector( L, 3 );
773 const vec2 *v = luaL_checkvector( L, 4 );
774 debris_add( mass, radius, p->x, p->y, v->x, v->y );
775 return 0;
776}
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
Definition array.h:158
#define array_end(array)
Returns a pointer to the end of the reserved memory space.
Definition array.h:202
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
Definition array.h:140
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
Definition array.h:168
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
Definition array.h:129
#define array_begin(array)
Returns a pointer to the beginning of the reserved memory space.
Definition array.h:194
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
Definition array.h:93
double cam_getZoom(void)
Gets the camera zoom.
Definition camera.c:97
void debris_add(double mass, double r, double px, double py, double vx, double vy)
Creates a cloud of debris.
Definition debris.c:80
Header file with generic functions and naev-specifics.
void nlua_unref(lua_State *L, int idx)
Removes a reference set with nlua_ref.
Definition nlua.c:961
int nlua_ref(lua_State *L, int idx)
Creates a new reference to a Lua structure at a position.
Definition nlua.c:952
LuaAudio_t * lua_pushaudio(lua_State *L, LuaAudio_t audio)
Pushes a audio on the stack.
Definition nlua_audio.c:349
LuaAudio_t * luaL_checkaudio(lua_State *L, int ind)
Gets audio at index or raises error if there is no audio at index.
Definition nlua_audio.c:335
#define SPFX_MOVING
Definition nlua_spfx.c:32
static int spfxL_new(lua_State *L)
Creates a new special effect.
Definition nlua_spfx.c:303
static int spfxL_vel(lua_State *L)
Gets the velocity of a spfx.
Definition nlua_spfx.c:463
static int spfxL_sfx(lua_State *L)
Gets the sound effect of a spfx.
Definition nlua_spfx.c:507
static int spfxL_setVel(lua_State *L)
Sets the velocity of a spfx.
Definition nlua_spfx.c:492
int lua_isspfx(lua_State *L, int ind)
Checks to see if ind is a spfx.
Definition nlua_spfx.c:178
void spfxL_setSpeedVolume(double v)
Sets the speed volume due to autonav and the likes.
Definition nlua_spfx.c:563
static const luaL_Reg spfxL_methods[]
Definition nlua_spfx.c:78
void spfxL_renderbg(double dt)
Renders the Lua SPFX on the background.
Definition nlua_spfx.c:738
static int spfxL_setPos(lua_State *L)
Sets the position of a spfx.
Definition nlua_spfx.c:477
#define SPFX_GLOBAL
Definition nlua_spfx.c:30
static int spfxL_pos(lua_State *L)
Gets the position of a spfx.
Definition nlua_spfx.c:449
void spfxL_rendermg(double dt)
Renders the Lua SPFX in the midground.
Definition nlua_spfx.c:746
static int spfxL_eq(lua_State *L)
Compares two spfxs to see if they are the same.
Definition nlua_spfx.c:252
void spfxL_renderfg(double dt)
Renders the Lua SPFX in the foreground.
Definition nlua_spfx.c:754
void spfxL_clear(void)
Clears the Lua spfx.
Definition nlua_spfx.c:608
static void spfx_cleanup(LuaSpfxData_t *ls)
Cleans up a special effect.
Definition nlua_spfx.c:199
static int spfxL_data(lua_State *L)
Gets the data table of a spfx.
Definition nlua_spfx.c:523
static int spfxL_rm(lua_State *L)
Removes a special effect.
Definition nlua_spfx.c:423
static LuaSpfxData_t * lua_spfx
List of special effects being handled.
Definition nlua_spfx.c:60
void spfxL_update(double dt)
Updates the spfx.
Definition nlua_spfx.c:632
#define SPFX_RELATIVE
Definition nlua_spfx.c:31
#define SPFX_CLEANUP
Definition nlua_spfx.c:34
LuaSpfx_t * luaL_checkspfx(lua_State *L, int ind)
Gets spfx at index or raises error if there is no spfx at index.
Definition nlua_spfx.c:132
static int spfxL_debris(lua_State *L)
Creates a cloud of debris.
Definition nlua_spfx.c:768
static int spfxL_getAll(lua_State *L)
Gets all the active spfx.
Definition nlua_spfx.c:267
int nlua_loadSpfx(nlua_env env)
Loads the spfx library.
Definition nlua_spfx.c:108
LuaSpfx_t * lua_pushspfx(lua_State *L, LuaSpfx_t spfx)
Pushes a spfx on the stack.
Definition nlua_spfx.c:163
#define SPFX_AUDIO
Definition nlua_spfx.c:33
void spfxL_setSpeed(double s)
Sets the speed of the playing spfx sounds.
Definition nlua_spfx.c:533
LuaSpfx_t * lua_tospfx(lua_State *L, int ind)
Gets spfx at index.
Definition nlua_spfx.c:121
static int spfxL_gc(lua_State *L)
Lua bindings to interact with spfx.
Definition nlua_spfx.c:237
vec2 * luaL_checkvector(lua_State *L, int ind)
Gets vector at index making sure type is valid.
Definition nlua_vec2.c:130
vec2 * lua_pushvector(lua_State *L, vec2 vec)
Pushes a vector on the stack.
Definition nlua_vec2.c:145
void gl_gameToScreenCoords(double *nx, double *ny, double bx, double by)
Converts in-game coordinates to screen coordinates.
double player_dt_default(void)
Returns the player's total default time delta based on time dilation stuff.
Definition player.c:1913
Player_t player
Definition player.c:74
int sound_disabled
Definition sound.c:133
ALuint sound_efx_directSlot
Definition sound.c:194
alInfo_t al_info
Definition sound.c:178
int nocleanup
Definition nlua_audio.h:35
double volume
Definition nlua_audio.h:38
ALuint source
Definition nlua_audio.h:36
Handles the special effects Lua-side.
Definition nlua_spfx.c:41
LuaAudio_t sfx
Definition nlua_spfx.c:54
double radius
Definition nlua_spfx.c:47
unsigned int flags
Definition nlua_spfx.c:43
double speed
Definition player.h:110
ALint efx
Definition sound.h:43
Represents a 2d vector.
Definition vec2.h:32
double y
Definition vec2.h:34
double x
Definition vec2.h:33