mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Lunatic translator: handle RETURN across events.
git-svn-id: https://svn.eduke32.com/eduke32@3526 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
fa61fed75c
commit
c5c1aa2331
5 changed files with 25 additions and 6 deletions
|
@ -124,7 +124,7 @@ int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lD
|
|||
|
||||
// TODO: handling of RETURN gamevar / iReturn / this function's return value
|
||||
if (L_IsInitialized(&g_ElState) && El_HaveEvent(iEventID))
|
||||
if (El_CallEvent(&g_ElState, iEventID, iActor, iPlayer, lDist)==1)
|
||||
if (El_CallEvent(&g_ElState, iEventID, iActor, iPlayer, lDist, &iReturn)==1)
|
||||
VM_KillIt(iActor, iPlayer);
|
||||
|
||||
g_eventTotalMs[iEventID] += gethitickms()-t;
|
||||
|
|
|
@ -157,6 +157,7 @@ local bcarray = require("bcarray")
|
|||
|
||||
local bcheck = require("bcheck")
|
||||
local check_sector_idx, check_tile_idx = bcheck.sector_idx, bcheck.tile_idx
|
||||
local check_sprite_idx = bcheck.sprite_idx
|
||||
local check_weapon_idx, check_inventory_idx = bcheck.weapon_idx, bcheck.inventory_idx
|
||||
local check_sound_idx = bcheck.sound_idx
|
||||
|
||||
|
@ -498,6 +499,7 @@ const char *s_buildRev;
|
|||
const char *g_sizes_of_what[];
|
||||
int32_t g_sizes_of[];
|
||||
int32_t g_elCallDepth;
|
||||
int32_t g_elEventRETURN;
|
||||
char g_modDir[];
|
||||
actor_t actor[MAXSPRITES];
|
||||
camera_t g_camera;
|
||||
|
@ -1077,6 +1079,14 @@ function gv_access._set_guniqhudid(id)
|
|||
ffiC.guniqhudid = id
|
||||
end
|
||||
|
||||
function gv_access._RETURN(setval)
|
||||
if (setval ~= nil) then
|
||||
ffiC.g_elEventRETURN = setval
|
||||
else
|
||||
return ffiC.g_elEventRETURN
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO: make return 1-based index
|
||||
function gv_access.currentEpisode()
|
||||
return ffiC.ud.volume_number
|
||||
|
|
|
@ -344,8 +344,12 @@ function on.state_end(funcname, codetab)
|
|||
end
|
||||
|
||||
function on.event_end(eventidx, codetab)
|
||||
assert(type(codetab)=="table")
|
||||
addcodef("gameevent(%d, function (_aci, _pli, _dist)", eventidx)
|
||||
add_code_and_end(codetab, "end)")
|
||||
addcode(CSV".RETURN=gv._RETURN()")
|
||||
addcode(codetab)
|
||||
addcodef("gv._RETURN(%s)", CSV".RETURN")
|
||||
addcode("end)")
|
||||
|
||||
g_code.event[eventidx] = codetab
|
||||
end
|
||||
|
@ -1780,9 +1784,9 @@ local Cinner = {
|
|||
soundoncevar = cmd(R)
|
||||
/ handle.soundonce,
|
||||
stopactorsound = cmd(R,R)
|
||||
/ "_stopactorsound(%1,%2)",
|
||||
/ "_con._stopactorsound(%1,%2)",
|
||||
stopallsounds = cmd()
|
||||
/ "_stopallsounds()",
|
||||
/ "_con._stopallsounds()",
|
||||
mikesnd = cmd()
|
||||
/ format("_con._soundonce(_aci,%s)", SPS".yvel"),
|
||||
setactorsoundpitch = cmd(R,R,R)
|
||||
|
|
|
@ -24,6 +24,7 @@ uint8_t g_elEvents[MAXEVENTS];
|
|||
el_actor_t g_elActors[MAXTILES];
|
||||
|
||||
int32_t g_elCallDepth = 0;
|
||||
int32_t g_elEventRETURN;
|
||||
|
||||
// for timing events and actors
|
||||
uint32_t g_eventCalls[MAXEVENTS], g_actorCalls[MAXTILES];
|
||||
|
@ -442,7 +443,7 @@ static void El_EventErrorPrint(const char *errmsg)
|
|||
EventNames[g_eventIdx], errmsg);
|
||||
}
|
||||
|
||||
int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t iPlayer, int32_t lDist)
|
||||
int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t *iReturn)
|
||||
{
|
||||
// XXX: estate must be the one where the events were registered...
|
||||
// make a global?
|
||||
|
@ -450,10 +451,14 @@ int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t
|
|||
lua_State *const L = estate->L;
|
||||
int32_t i;
|
||||
|
||||
g_elEventRETURN = *iReturn;
|
||||
|
||||
g_elCallDepth++;
|
||||
i = call_regd_function3(L, &g_elEvents[eventidx], iActor, iPlayer, lDist);
|
||||
g_elCallDepth--;
|
||||
|
||||
*iReturn = g_elEventRETURN;
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
g_eventIdx = eventidx;
|
||||
|
|
|
@ -34,7 +34,7 @@ void El_DisplayErrors(void);
|
|||
int32_t El_CreateState(L_State *estate, const char *name);
|
||||
void El_DestroyState(L_State *estate);
|
||||
|
||||
int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t iPlayer, int32_t lDist);
|
||||
int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t *iReturn);
|
||||
int32_t El_CallActor(L_State *estate, int32_t actortile, int32_t iActor, int32_t iPlayer, int32_t lDist);
|
||||
|
||||
static inline int32_t El_HaveEvent(int32_t eventidx) { return g_elEvents[eventidx]!=0; }
|
||||
|
|
Loading…
Reference in a new issue