mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
Lunatic: add actor.delete() and various 'length' methods to geom.vec3/ivec3.
git-svn-id: https://svn.eduke32.com/eduke32@3821 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
a52130a996
commit
360aae414f
6 changed files with 42 additions and 3 deletions
|
@ -1573,6 +1573,8 @@ function _sound(aci, sndidx)
|
||||||
CF.A_PlaySound(sndidx, aci)
|
CF.A_PlaySound(sndidx, aci)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- NOTE: This command is really badly named in CON. It issues a sound that
|
||||||
|
-- emanates from the current player instead of being 'system-global'.
|
||||||
function _globalsound(pli, sndidx)
|
function _globalsound(pli, sndidx)
|
||||||
-- TODO: conditional on coop, fake multimode
|
-- TODO: conditional on coop, fake multimode
|
||||||
if (pli==ffiC.screenpeek) then
|
if (pli==ffiC.screenpeek) then
|
||||||
|
|
|
@ -5,6 +5,9 @@ local require = require
|
||||||
local ffi = require("ffi")
|
local ffi = require("ffi")
|
||||||
local ffiC = ffi.C
|
local ffiC = ffi.C
|
||||||
|
|
||||||
|
-- Lua C API functions.
|
||||||
|
local CF = CF
|
||||||
|
|
||||||
local bit = bit
|
local bit = bit
|
||||||
local string = string
|
local string = string
|
||||||
local table = table
|
local table = table
|
||||||
|
@ -576,6 +579,7 @@ const char *s_buildRev;
|
||||||
const char *g_sizes_of_what[];
|
const char *g_sizes_of_what[];
|
||||||
int32_t g_sizes_of[];
|
int32_t g_sizes_of[];
|
||||||
int32_t g_elCallDepth;
|
int32_t g_elCallDepth;
|
||||||
|
int32_t block_deletesprite;
|
||||||
const char **g_argv;
|
const char **g_argv;
|
||||||
const char **g_elModules;
|
const char **g_elModules;
|
||||||
char g_modDir[];
|
char g_modDir[];
|
||||||
|
@ -775,6 +779,26 @@ do
|
||||||
actor_static_members.FLAGS = defs_c.conststruct(our_SFLAG)
|
actor_static_members.FLAGS = defs_c.conststruct(our_SFLAG)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Delete sprite with index <i>.
|
||||||
|
-- TODO: make this (also?) sprite.delete() even though it's game-side?
|
||||||
|
function actor_static_members.delete(i)
|
||||||
|
check_sprite_idx(i)
|
||||||
|
|
||||||
|
if (ffiC.sprite[i].statnum == ffiC.MAXSTATUS) then
|
||||||
|
error("Attempt to delete a sprite already not in the game world", 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
if (ffiC.block_deletesprite ~= 0) then
|
||||||
|
error("Attempt to delete sprite in EVENT_EGS", 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
if (ffiC.g_player_ps[0].i == i) then
|
||||||
|
error("Attempt to delete player 0's APLAYER sprite", 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
CF.A_DeleteSprite(i)
|
||||||
|
end
|
||||||
|
|
||||||
local tile_static_members = {}
|
local tile_static_members = {}
|
||||||
do
|
do
|
||||||
tile_static_members.sizx = defs_c.creategtab(ffiC.tilesizx, ffiC.MAXTILES, "tilesizx[]")
|
tile_static_members.sizx = defs_c.creategtab(ffiC.tilesizx, ffiC.MAXTILES, "tilesizx[]")
|
||||||
|
|
|
@ -101,6 +101,7 @@ s_buildRev;
|
||||||
g_sizes_of_what;
|
g_sizes_of_what;
|
||||||
g_sizes_of;
|
g_sizes_of;
|
||||||
g_elCallDepth;
|
g_elCallDepth;
|
||||||
|
block_deletesprite;
|
||||||
g_RETURN;
|
g_RETURN;
|
||||||
g_argv;
|
g_argv;
|
||||||
g_elModules;
|
g_elModules;
|
||||||
|
|
|
@ -63,7 +63,7 @@ local arshift = require("bit").arshift
|
||||||
-- The vec3 metatable is shared between the integer- and double-based 3-vector
|
-- The vec3 metatable is shared between the integer- and double-based 3-vector
|
||||||
-- types. However, some operations are slightly different.
|
-- types. However, some operations are slightly different.
|
||||||
local vec3_mt = {
|
local vec3_mt = {
|
||||||
-- Arithmetic operations. Note that they always return the a dvec3.
|
-- Arithmetic operations. Note that they always return a dvec3.
|
||||||
__add = function(a, b) return dvec3_t(a.x+b.x, a.y+b.y, a.z+b.z) end,
|
__add = function(a, b) return dvec3_t(a.x+b.x, a.y+b.y, a.z+b.z) end,
|
||||||
__sub = function(a, b) return dvec3_t(a.x-b.x, a.y-b.y, a.z-b.z) end,
|
__sub = function(a, b) return dvec3_t(a.x-b.x, a.y-b.y, a.z-b.z) end,
|
||||||
__unm = function(a) return dvec3_t(-a.x, -a.y, -a.z) end,
|
__unm = function(a) return dvec3_t(-a.x, -a.y, -a.z) end,
|
||||||
|
@ -92,6 +92,7 @@ local vec3_mt = {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- The # operator returns the Euclidean length.
|
-- The # operator returns the Euclidean length.
|
||||||
|
-- TODO: REMOVE.
|
||||||
__len = function(a) return math.sqrt(a.x*a.x + a.y*a.y + a.z*a.z) end,
|
__len = function(a) return math.sqrt(a.x*a.x + a.y*a.y + a.z*a.z) end,
|
||||||
|
|
||||||
-- INTERNAL: Calling a vector calls the constructor of its type.
|
-- INTERNAL: Calling a vector calls the constructor of its type.
|
||||||
|
@ -105,9 +106,17 @@ local vec3_mt = {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
__index = {
|
__index = {
|
||||||
|
-- Euclidean 3D length.
|
||||||
|
len = function(a) return math.sqrt(a.x*a.x + a.y*a.y + a.z*a.z) end,
|
||||||
|
-- Euclidean 3D squared length.
|
||||||
lensq = function(a) return a.x*a.x + a.y*a.y + a.z*a.z end,
|
lensq = function(a) return a.x*a.x + a.y*a.y + a.z*a.z end,
|
||||||
|
|
||||||
-- Manhattan-distance length:
|
-- Euclidean 2D length.
|
||||||
|
len2 = function(a) return math.sqrt(a.x*a.x + a.y*a.y) end,
|
||||||
|
-- Euclidean 2D squared length.
|
||||||
|
len2sq = function(a) return a.x*a.x + a.y*a.y end,
|
||||||
|
|
||||||
|
-- Manhattan-distance 3D length:
|
||||||
mhlen = function(a) return math.abs(a.x)+math.abs(a.y)+math.abs(a.z) end,
|
mhlen = function(a) return math.abs(a.x)+math.abs(a.y)+math.abs(a.z) end,
|
||||||
|
|
||||||
toivec3 = function(v) return ivec3_t(v.x, v.y, v.z) end,
|
toivec3 = function(v) return ivec3_t(v.x, v.y, v.z) end,
|
||||||
|
|
|
@ -176,7 +176,7 @@ local function new_initial_codetab()
|
||||||
|
|
||||||
-- Cache globals into locals.
|
-- Cache globals into locals.
|
||||||
"local sector, sprite, wall, spriteext, atsprite = sector, sprite, wall, spriteext, atsprite",
|
"local sector, sprite, wall, spriteext, atsprite = sector, sprite, wall, spriteext, atsprite",
|
||||||
"local actor, player, projectile = actor, player, projectile",
|
"local actor, player, projectile, g_tile = actor, player, projectile, g_tile",
|
||||||
"local gameactor, gameevent, _gv = gameactor, gameevent, gv",
|
"local gameactor, gameevent, _gv = gameactor, gameevent, gv",
|
||||||
"local updatesector, updatesectorz, cansee = updatesector, updatesectorz, cansee",
|
"local updatesector, updatesectorz, cansee = updatesector, updatesectorz, cansee",
|
||||||
"local print, printf = print, printf",
|
"local print, printf = print, printf",
|
||||||
|
|
|
@ -271,6 +271,7 @@ extern int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s
|
||||||
int32_t s_xr,int32_t s_yr,int32_t s_a,int32_t s_ve,int32_t s_zv,int32_t s_ow,int32_t s_ss);
|
int32_t s_xr,int32_t s_yr,int32_t s_a,int32_t s_ve,int32_t s_zv,int32_t s_ow,int32_t s_ss);
|
||||||
extern void A_AddToDeleteQueue(int32_t i);
|
extern void A_AddToDeleteQueue(int32_t i);
|
||||||
extern int32_t A_PlaySound(uint32_t num, int32_t i);
|
extern int32_t A_PlaySound(uint32_t num, int32_t i);
|
||||||
|
extern void A_DeleteSprite(int32_t s);
|
||||||
|
|
||||||
#define LARG(index) lua_tointeger(L, index)
|
#define LARG(index) lua_tointeger(L, index)
|
||||||
|
|
||||||
|
@ -315,6 +316,7 @@ DEFINE_RET_CFUNC(A_InsertSprite, LARG(1), LARG(2), LARG(3), LARG(4), LARG(5), LA
|
||||||
LARG(7), LARG(8), LARG(9), LARG(10), LARG(11), LARG(12), LARG(13))
|
LARG(7), LARG(8), LARG(9), LARG(10), LARG(11), LARG(12), LARG(13))
|
||||||
DEFINE_VOID_CFUNC(A_AddToDeleteQueue, ONE_ARG)
|
DEFINE_VOID_CFUNC(A_AddToDeleteQueue, ONE_ARG)
|
||||||
DEFINE_RET_CFUNC(A_PlaySound, TWO_ARGS)
|
DEFINE_RET_CFUNC(A_PlaySound, TWO_ARGS)
|
||||||
|
DEFINE_VOID_CFUNC(A_DeleteSprite, ONE_ARG)
|
||||||
|
|
||||||
#define CFUNC_REG(Name) { #Name, Name##_CF }
|
#define CFUNC_REG(Name) { #Name, Name##_CF }
|
||||||
|
|
||||||
|
@ -333,6 +335,7 @@ struct { const char *name; lua_CFunction func; } cfuncs[] =
|
||||||
CFUNC_REG(A_Spawn),
|
CFUNC_REG(A_Spawn),
|
||||||
CFUNC_REG(A_AddToDeleteQueue),
|
CFUNC_REG(A_AddToDeleteQueue),
|
||||||
CFUNC_REG(A_PlaySound),
|
CFUNC_REG(A_PlaySound),
|
||||||
|
CFUNC_REG(A_DeleteSprite),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Creates a global table "CF" containing the functions from cfuncs[].
|
// Creates a global table "CF" containing the functions from cfuncs[].
|
||||||
|
|
Loading…
Reference in a new issue