naev 0.10.4
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 "array.h"
21#include "nlua_audio.h"
22#include "nlua_vec2.h"
23#include "nluadef.h"
24#include "sound.h"
25#include "opengl.h"
26#include "nopenal.h"
27#include "player.h"
28
29#define SPFX_GLOBAL (1<<1)
30#define SPFX_RELATIVE (1<<2)
31#define SPFX_MOVING (1<<3)
32#define SPFX_AUDIO (1<<4)
33#define SPFX_CLEANUP (1<<5)
40typedef struct LuaSpfxData_s {
41 int id;
42 unsigned int flags;
43 double ttl;
46 double radius;
47 int data;
51 int update;
54
58static LuaSpfxData_t *lua_spfx = NULL;
59static LuaSpfxData_t *lua_spfx_queue = NULL;
60static int lua_spfx_idgen = 0;
61static int lua_spfx_lock = 0;
62
63/* Spfx methods. */
64static int spfxL_gc( lua_State *L );
65static int spfxL_eq( lua_State *L );
66static int spfxL_getAll( lua_State *L );
67static int spfxL_new( lua_State *L );
68static int spfxL_rm( lua_State *L );
69static int spfxL_pos( lua_State *L );
70static int spfxL_vel( lua_State *L );
71static int spfxL_setPos( lua_State *L );
72static int spfxL_setVel( lua_State *L );
73static int spfxL_sfx( lua_State *L );
74static int spfxL_data( lua_State *L );
75static const luaL_Reg spfxL_methods[] = {
76 { "__gc", spfxL_gc },
77 { "__eq", spfxL_eq },
78 { "getAll", spfxL_getAll },
79 { "new", spfxL_new },
80 { "rm", spfxL_rm },
81 { "pos", spfxL_pos },
82 { "vel", spfxL_vel },
83 { "setPos", spfxL_setPos },
84 { "setVel", spfxL_setVel },
85 { "sfx", spfxL_sfx },
86 { "data", spfxL_data },
87 {0,0}
88};
90static int spfx_cmp( const void *p1, const void *p2 )
91{
92 const LuaSpfxData_t *s1, *s2;
93 s1 = (const LuaSpfxData_t*) p1;
94 s2 = (const LuaSpfxData_t*) p2;
95 return s1->id - s2->id;
96}
97
104int nlua_loadSpfx( nlua_env env )
105{
106 nlua_register(env, SPFX_METATABLE, spfxL_methods, 1);
107 return 0;
108}
109
117LuaSpfx_t* lua_tospfx( lua_State *L, int ind )
118{
119 return (LuaSpfx_t*) lua_touserdata(L,ind);
120}
128LuaSpfx_t* luaL_checkspfx( lua_State *L, int ind )
129{
130 if (lua_isspfx(L,ind))
131 return lua_tospfx(L,ind);
132 luaL_typerror(L, ind, SPFX_METATABLE);
133 return NULL;
134}
135static LuaSpfxData_t* luaL_checkspfxdataNoWarn( lua_State *L, int ind )
136{
137 LuaSpfx_t *ls = luaL_checkspfx( L , ind );
138 const LuaSpfxData_t key = { .id = *ls };
139 LuaSpfxData_t *f = bsearch( &key, lua_spfx, array_size(lua_spfx), sizeof(LuaSpfxData_t), spfx_cmp );
140 if (f == NULL) {
141 f = bsearch( &key, lua_spfx_queue, array_size(lua_spfx_queue), sizeof(LuaSpfxData_t), spfx_cmp );
142 }
143 return f;
144}
145static LuaSpfxData_t* luaL_checkspfxdata( lua_State *L, int ind )
146{
147 LuaSpfxData_t *f = luaL_checkspfxdataNoWarn( L, ind );
148 if (f == NULL)
149 NLUA_ERROR( L, _("Spfx does not exist.") );
150 return f;
151}
159LuaSpfx_t* lua_pushspfx( lua_State *L, LuaSpfx_t spfx )
160{
161 LuaSpfx_t *la = (LuaSpfx_t*) lua_newuserdata(L, sizeof(LuaSpfx_t));
162 *la = spfx;
163 luaL_getmetatable(L, SPFX_METATABLE);
164 lua_setmetatable(L, -2);
165 return la;
166}
174int lua_isspfx( lua_State *L, int ind )
175{
176 int ret;
177
178 if (lua_getmetatable(L,ind)==0)
179 return 0;
180 lua_getfield(L, LUA_REGISTRYINDEX, SPFX_METATABLE);
181
182 ret = 0;
183 if (lua_rawequal(L, -1, -2)) /* does it have the correct mt? */
184 ret = 1;
185
186 lua_pop(L, 2); /* remove both metatables */
187 return ret;
188}
189
195static void spfx_cleanup( LuaSpfxData_t *ls )
196{
197 /* Unreference stuff so it can get gc'd. */
198 nlua_unref( naevL, ls->data );
199 nlua_unref( naevL, ls->render_bg );
200 nlua_unref( naevL, ls->render_mg );
201 nlua_unref( naevL, ls->render_fg );
202 nlua_unref( naevL, ls->update );
203
204 /* Make sure stuff doesn't get run. */
205 ls->data = LUA_NOREF;
206 ls->render_bg = LUA_NOREF;
207 ls->render_mg = LUA_NOREF;
208 ls->render_fg = LUA_NOREF;
209 ls->update = LUA_NOREF;
210
211 /* Clean up audio. */
212 ls->sfx.nocleanup = 0; /* Have to disable so it gets cleaned. */
213 audio_cleanup( &ls->sfx );
214
215 /* Set as cleaned up. */
216 ls->id = -1;
217}
218
231static int spfxL_gc( lua_State *L )
232{
233 LuaSpfx_t *ls = luaL_checkspfx(L,1);
234 (void) ls;
235 return 0;
236}
237
246static int spfxL_eq( lua_State *L )
247{
248 LuaSpfx_t *s1, *s2;
249 s1 = luaL_checkspfx(L,1);
250 s2 = luaL_checkspfx(L,2);
251 lua_pushboolean( L, (memcmp( s1, s2, sizeof(LuaSpfx_t) )==0) );
252 return 1;
253}
254
261static int spfxL_getAll( lua_State *L )
262{
263 int n=1;
264 lua_newtable(L);
265 for (int i=0; i<array_size(lua_spfx); i++) {
266 LuaSpfxData_t *ls = &lua_spfx[i];
267
268 if (ls->flags & (SPFX_GLOBAL | SPFX_CLEANUP))
269 continue;
270
271 lua_pushspfx( L, ls->id );
272 lua_rawseti( L, -2, n++ );
273 }
274 return 1;
275}
276
296static int spfxL_new( lua_State *L )
297{
298 LuaSpfxData_t ls;
299
300 memset( &ls, 0, sizeof(LuaSpfxData_t) );
301
302 ls.id = ++lua_spfx_idgen;
303 ls.ttl = luaL_checknumber(L,1);
304 ls.update = LUA_NOREF;
305 ls.render_bg = LUA_NOREF;
306 ls.render_mg = LUA_NOREF;
307 ls.render_fg = LUA_NOREF;
308
309 /* Functions. */
310 if (!lua_isnoneornil(L,2))
311 ls.update = nlua_ref( L, 2 );
312 if (!lua_isnoneornil(L,3))
313 ls.render_bg = nlua_ref( L, 3 );
314 if (!lua_isnoneornil(L,4))
315 ls.render_mg = nlua_ref( L, 4 );
316 if (!lua_isnoneornil(L,5))
317 ls.render_fg = nlua_ref( L, 5 );
318
319 /* Position information. */
320 if (!lua_isnoneornil(L,6)) {
321 if (lua_isboolean( L, 6 )) {
322 ls.flags |= SPFX_RELATIVE;
323 if (!lua_toboolean( L, 6 ))
324 ls.flags |= SPFX_GLOBAL;
325 }
326 else
327 ls.pos = *luaL_checkvector( L, 6 );
328 }
329 else
331 if (!lua_isnoneornil(L,7)) {
332 ls.vel = *luaL_checkvector( L, 7 );
333 ls.flags |= SPFX_MOVING;
334 }
335
336 /* Special effect. */
337 if (!lua_isnoneornil(L,8)) {
338 LuaAudio_t *la = luaL_checkaudio( L, 8 );
339
340 if (!sound_disabled) {
341 ls.flags |= SPFX_AUDIO;
342 audio_clone( &ls.sfx, la );
343 ls.sfx.nocleanup = 1;
344
345 /* Set up parameters. */
346 soundLock();
347 alSourcei( ls.sfx.source, AL_LOOPING, AL_FALSE );
348 alSourcef( ls.sfx.source, AL_REFERENCE_DISTANCE, SOUND_REFERENCE_DISTANCE );
349 alSourcef( ls.sfx.source, AL_MAX_DISTANCE, SOUND_MAX_DISTANCE );
350 if (ls.flags & SPFX_RELATIVE) {
351 alSourcei( ls.sfx.source, AL_SOURCE_RELATIVE, AL_TRUE );
352 if (ls.flags & SPFX_GLOBAL)
353 alSourcef( ls.sfx.source, AL_PITCH, 1. );
354 else
355 alSourcef( ls.sfx.source, AL_PITCH, player_dt_default() * player.speed );
356 }
357 else {
358 ALfloat alf[3];
359 alSourcei( ls.sfx.source, AL_SOURCE_RELATIVE, AL_FALSE );
360 alSourcef( ls.sfx.source, AL_PITCH, player_dt_default() * player.speed );
361 alf[0] = ls.pos.x;
362 alf[1] = ls.pos.y;
363 alf[2] = 0.;
364 alSourcefv( ls.sfx.source, AL_POSITION, alf );
365 alf[0] = ls.vel.x;
366 alf[1] = ls.vel.y;
367 alf[2] = 0.;
368 alSourcefv( ls.sfx.source, AL_VELOCITY, alf );
369
370 /* Set the global filter. */
371 if (al_info.efx == AL_TRUE)
372 alSource3i( ls.sfx.source, AL_AUXILIARY_SEND_FILTER, sound_efx_directSlot, 0, AL_FILTER_NULL );
373 }
374 alSourcePlay( ls.sfx.source );
375 al_checkErr();
376 soundUnlock();
377 }
378 }
379
380 /* Store radius. */
381 ls.radius = luaL_optnumber(L,9,-1.);
382
383 /* Set up new data. */
384 lua_newtable(L);
385 ls.data = luaL_ref( L, LUA_REGISTRYINDEX ); /* Pops result. */
386
387 /* Add to Lua and stack, depending on if locked or not. */
388 if (lua_spfx_lock) {
389 if (lua_spfx_queue == NULL)
390 lua_spfx_queue = array_create( LuaSpfxData_t );
391 array_push_back( &lua_spfx_queue, ls );
392 }
393 else {
394 if (lua_spfx == NULL)
397 }
398
399 lua_pushspfx( L, ls.id );
400 return 1;
401}
402
409static int spfxL_rm( lua_State *L )
410{
411 LuaSpfxData_t *ls = luaL_checkspfxdataNoWarn(L,1);
412 if (ls != NULL) {
413 ls->flags &= SPFX_CLEANUP;
414 ls->ttl = -1.;
415 }
416 return 0;
417}
418
426static int spfxL_pos( lua_State *L )
427{
428 LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
429 lua_pushvector( L, ls->pos );
430 return 1;
431}
432
440static int spfxL_vel( lua_State *L )
441{
442 LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
443 lua_pushvector( L, ls->vel );
444 return 1;
445}
446
454static int spfxL_setPos( lua_State *L )
455{
456 LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
457 vec2 *v = luaL_checkvector(L,2);
458 ls->pos = *v;
459 return 0;
460}
461
469static int spfxL_setVel( lua_State *L )
470{
471 LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
472 vec2 *v = luaL_checkvector(L,2);
473 ls->vel = *v;
474 return 0;
475}
476
484static int spfxL_sfx( lua_State *L )
485{
486 LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
487 lua_pushaudio( L, ls->sfx );
488 return 1;
489}
490
500static int spfxL_data( lua_State *L )
501{
502 LuaSpfxData_t *ls = luaL_checkspfxdata(L,1);
503 lua_rawgeti( L, LUA_REGISTRYINDEX, ls->data );
504 return 1;
505}
506
510void spfxL_setSpeed( double s )
511{
512 if (sound_disabled)
513 return;
514
515 soundLock();
516 for (int i=0; i<array_size(lua_spfx); i++) {
517 LuaSpfxData_t *ls = &lua_spfx[i];
518
519 if (!(ls->flags & SPFX_AUDIO))
520 continue;
521
522 if (ls->flags & (SPFX_GLOBAL | SPFX_CLEANUP))
523 continue;
524
525 alSourcef( ls->sfx.source, AL_PITCH, s );
526 }
527 al_checkErr();
528 soundUnlock();
529}
530
536void spfxL_setSpeedVolume( double v )
537{
538 if (sound_disabled)
539 return;
540
541 soundLock();
542 for (int i=0; i<array_size(lua_spfx); i++) {
543 LuaSpfxData_t *ls = &lua_spfx[i];
544
545 if (!(ls->flags & SPFX_AUDIO))
546 continue;
547
548 if (ls->flags & (SPFX_GLOBAL | SPFX_CLEANUP))
549 continue;
550
551 alSourcef( ls->sfx.source, AL_GAIN, ls->sfx.volume * v );
552 }
553 al_checkErr();
554 soundUnlock();
555}
556
557static void spfx_lock (void)
558{
559 lua_spfx_lock = 1;
560}
561
562static void spfx_unlock (void)
563{
564 lua_spfx_lock = 0;
565
566 if (lua_spfx_queue==NULL)
567 return;
568
569 for (int i=0; i<array_size(lua_spfx_queue); i++)
570 array_push_back( &lua_spfx, lua_spfx_queue[i] );
571 array_erase( &lua_spfx_queue, array_begin(lua_spfx_queue), array_end(lua_spfx_queue) );
572}
573
577void spfxL_clear (void)
578{
579 for (int i=0; i<array_size(lua_spfx); i++)
580 spfx_cleanup( &lua_spfx[i] );
582 for (int i=0; i<array_size(lua_spfx_queue); i++)
583 spfx_cleanup( &lua_spfx_queue[i] );
584 array_erase( &lua_spfx_queue, array_begin(lua_spfx_queue), array_end(lua_spfx_queue) );
585}
586
587void spfxL_exit (void)
588{
589 spfxL_clear();
591 lua_spfx = NULL;
592 array_free( lua_spfx_queue );
593 lua_spfx_queue = NULL;
594}
595
601void spfxL_update( double dt )
602{
603 spfx_lock();
604 for (int i=array_size(lua_spfx)-1; i>=0; i--) {
605 LuaSpfxData_t *ls = &lua_spfx[i];
606
607 /* Count down. */
608 ls->ttl -= dt;
609 if ((ls->ttl <= 0.) || (ls->flags & SPFX_CLEANUP)) {
610 spfx_cleanup( ls );
611 array_erase( &lua_spfx, &lua_spfx[i], &lua_spfx[i+1] );
612 continue;
613 }
614
615 /* Normal update. */
616 if (ls->flags & SPFX_MOVING) {
617 ls->pos.x += ls->vel.x * dt;
618 ls->pos.y += ls->vel.y * dt;
619
620 /* Check sound. */
621 if ((ls->flags & SPFX_AUDIO) && !(ls->flags & SPFX_RELATIVE)) {
622 soundLock();
623 ALfloat alf[3];
624 alf[0] = ls->pos.x;
625 alf[1] = ls->pos.y;
626 alf[2] = 0.;
627 alSourcefv( ls->sfx.source, AL_POSITION, alf );
628 al_checkErr();
629 soundUnlock();
630 }
631 }
632
633 /* Update if necessary. */
634 if (ls->update == LUA_NOREF)
635 continue;
636
637 /* Run update. */
638 lua_rawgeti( naevL, LUA_REGISTRYINDEX, ls->update );
639 lua_pushspfx( naevL, ls->id );
640 lua_pushnumber( naevL, dt );
641 if (lua_pcall( naevL, 2, 0, 0) != 0) {
642 WARN(_("Spfx failed to run 'update':\n%s"), lua_tostring( naevL, -1 ));
643 lua_pop( naevL, 1 );
644 }
645 }
646 spfx_unlock();
647}
648
652void spfxL_renderbg (void)
653{
654 double z = cam_getZoom();
655 spfx_lock();
656 for (int i=0; i<array_size(lua_spfx); i++) {
657 vec2 pos;
658 LuaSpfxData_t *ls = &lua_spfx[i];
659
660 /* Skip no rendering. */
661 if ((ls->render_bg == LUA_NOREF) || (ls->flags & SPFX_CLEANUP))
662 continue;
663
664 /* Convert coordinates. */
665 gl_gameToScreenCoords( &pos.x, &pos.y, ls->pos.x, ls->pos.y );
666 pos.y = SCREEN_H-pos.y;
667
668 /* Render. */
669 lua_rawgeti( naevL, LUA_REGISTRYINDEX, ls->render_bg );
670 lua_pushspfx( naevL, ls->id );
671 lua_pushnumber( naevL, pos.x );
672 lua_pushnumber( naevL, pos.y );
673 lua_pushnumber( naevL, z );
674 if (lua_pcall( naevL, 4, 0, 0) != 0) {
675 WARN(_("Spfx failed to run 'renderbg':\n%s"), lua_tostring( naevL, -1 ));
676 lua_pop( naevL, 1 );
677 }
678 }
679 spfx_unlock();
680}
681
685void spfxL_rendermg (void)
686{
687 double z = cam_getZoom();
688 spfx_lock();
689 for (int i=0; i<array_size(lua_spfx); i++) {
690 vec2 pos;
691 LuaSpfxData_t *ls = &lua_spfx[i];
692 double r = ls->radius;
693
694 /* Skip no rendering. */
695 if ((ls->render_mg == LUA_NOREF) || (ls->flags & SPFX_CLEANUP))
696 continue;
697
698 /* Convert coordinates. */
699 gl_gameToScreenCoords( &pos.x, &pos.y, ls->pos.x, ls->pos.y );
700
701 /* If radius is defined see if in screen. */
702 if ((r > 0.) && ((pos.x < -r) || (pos.y < -r) ||
703 (pos.x > SCREEN_W+r) || (pos.y > SCREEN_H+r)))
704 continue;
705
706 /* Invert y axis. */
707 pos.y = SCREEN_H-pos.y;
708
709 /* Render. */
710 lua_rawgeti( naevL, LUA_REGISTRYINDEX, ls->render_mg );
711 lua_pushspfx( naevL, ls->id );
712 lua_pushnumber( naevL, pos.x );
713 lua_pushnumber( naevL, pos.y );
714 lua_pushnumber( naevL, z );
715 if (lua_pcall( naevL, 4, 0, 0) != 0) {
716 WARN(_("Spfx failed to run 'rendermg':\n%s"), lua_tostring( naevL, -1 ));
717 lua_pop( naevL, 1 );
718 }
719 }
720 spfx_unlock();
721}
722
726void spfxL_renderfg (void)
727{
728 double z = cam_getZoom();
729 spfx_lock();
730 for (int i=0; i<array_size(lua_spfx); i++) {
731 vec2 pos;
732 LuaSpfxData_t *ls = &lua_spfx[i];
733 double r = ls->radius;
734
735 /* Skip no rendering. */
736 if ((ls->render_fg == LUA_NOREF) || (ls->flags & SPFX_CLEANUP))
737 continue;
738
739 /* Convert coordinates. */
740 gl_gameToScreenCoords( &pos.x, &pos.y, ls->pos.x, ls->pos.y );
741
742 /* If radius is defined see if in screen. */
743 if ((r > 0.) && ((pos.x < -r) || (pos.y < -r) ||
744 (pos.x > SCREEN_W+r) || (pos.y > SCREEN_H+r)))
745 continue;
746
747 /* Invert y axis. */
748 pos.y = SCREEN_H-pos.y;
749
750 /* Render. */
751 lua_rawgeti( naevL, LUA_REGISTRYINDEX, ls->render_fg );
752 lua_pushspfx( naevL, ls->id );
753 lua_pushnumber( naevL, pos.x );
754 lua_pushnumber( naevL, pos.y );
755 lua_pushnumber( naevL, z );
756 if (lua_pcall( naevL, 4, 0, 0) != 0) {
757 WARN(_("Spfx failed to run 'renderfg':\n%s"), lua_tostring( naevL, -1 ));
758 lua_pop( naevL, 1 );
759 }
760 }
761 spfx_unlock();
762}
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
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:914
int nlua_ref(lua_State *L, int idx)
Creates a new reference to a Lua structure at a position.
Definition: nlua.c:905
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:31
static int spfxL_new(lua_State *L)
Creates a new special effect.
Definition: nlua_spfx.c:296
static int spfxL_vel(lua_State *L)
Gets the velocity of a spfx.
Definition: nlua_spfx.c:440
static int spfxL_sfx(lua_State *L)
Gets the sound effect of a spfx.
Definition: nlua_spfx.c:484
void spfxL_rendermg(void)
Renders the Lua SPFX in the midground.
Definition: nlua_spfx.c:685
static int spfxL_setVel(lua_State *L)
Sets the velocity of a spfx.
Definition: nlua_spfx.c:469
int lua_isspfx(lua_State *L, int ind)
Checks to see if ind is a spfx.
Definition: nlua_spfx.c:174
void spfxL_setSpeedVolume(double v)
Sets the speed volume due to autonav and the likes.
Definition: nlua_spfx.c:536
static const luaL_Reg spfxL_methods[]
Definition: nlua_spfx.c:75
static int spfxL_setPos(lua_State *L)
Sets the position of a spfx.
Definition: nlua_spfx.c:454
#define SPFX_GLOBAL
Definition: nlua_spfx.c:29
static int spfxL_pos(lua_State *L)
Gets the position of a spfx.
Definition: nlua_spfx.c:426
static int spfxL_eq(lua_State *L)
Compares two spfxs to see if they are the same.
Definition: nlua_spfx.c:246
void spfxL_clear(void)
Clears the Lua spfx.
Definition: nlua_spfx.c:577
static void spfx_cleanup(LuaSpfxData_t *ls)
Cleans up a special effect.
Definition: nlua_spfx.c:195
static int spfxL_data(lua_State *L)
Gets the data table of a spfx.
Definition: nlua_spfx.c:500
static int spfxL_rm(lua_State *L)
Removes a special effect.
Definition: nlua_spfx.c:409
void spfxL_renderbg(void)
Renders the Lua SPFX on the background.
Definition: nlua_spfx.c:652
static LuaSpfxData_t * lua_spfx
List of special effects being handled.
Definition: nlua_spfx.c:58
void spfxL_update(double dt)
Updates the spfx.
Definition: nlua_spfx.c:601
#define SPFX_RELATIVE
Definition: nlua_spfx.c:30
void spfxL_renderfg(void)
Renders the Lua SPFX in the foreground.
Definition: nlua_spfx.c:726
#define SPFX_CLEANUP
Definition: nlua_spfx.c:33
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:128
static int spfxL_getAll(lua_State *L)
Gets all the active spfx.
Definition: nlua_spfx.c:261
int nlua_loadSpfx(nlua_env env)
Loads the spfx library.
Definition: nlua_spfx.c:104
LuaSpfx_t * lua_pushspfx(lua_State *L, LuaSpfx_t spfx)
Pushes a spfx on the stack.
Definition: nlua_spfx.c:159
#define SPFX_AUDIO
Definition: nlua_spfx.c:32
void spfxL_setSpeed(double s)
Sets the speed of the playing spfx sounds.
Definition: nlua_spfx.c:510
LuaSpfx_t * lua_tospfx(lua_State *L, int ind)
Gets spfx at index.
Definition: nlua_spfx.c:117
static int spfxL_gc(lua_State *L)
Lua bindings to interact with spfx.
Definition: nlua_spfx.c:231
vec2 * luaL_checkvector(lua_State *L, int ind)
Gets vector at index making sure type is valid.
Definition: nlua_vec2.c:124
vec2 * lua_pushvector(lua_State *L, vec2 vec)
Pushes a vector on the stack.
Definition: nlua_vec2.c:139
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:1871
Player_t player
Definition: player.c:73
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:34
double volume
Definition: nlua_audio.h:37
ALuint source
Definition: nlua_audio.h:35
Handles the special effects Lua-side.
Definition: nlua_spfx.c:40
LuaAudio_t sfx
Definition: nlua_spfx.c:52
double ttl
Definition: nlua_spfx.c:43
double radius
Definition: nlua_spfx.c:46
unsigned int flags
Definition: nlua_spfx.c:42
double speed
Definition: player.h:115
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