mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 09:21:36 +00:00
Lunatic translator: a couple of quote commands, while*n.
git-svn-id: https://svn.eduke32.com/eduke32@3504 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
fd2790da82
commit
8637a7aa22
4 changed files with 107 additions and 15 deletions
|
@ -418,13 +418,15 @@ end
|
|||
--- expose the functionality in a better fashion than merely giving access to
|
||||
--- the C functions.)
|
||||
|
||||
-- quotes
|
||||
local MAXQUOTES = con_lang.MAXQUOTES
|
||||
local MAXQUOTELEN = con_lang.MAXQUOTELEN
|
||||
|
||||
function _definequote(qnum, quotestr)
|
||||
bcheck.quote_idx(qnum)
|
||||
assert(type(quotestr)=="string")
|
||||
ffiC.C_DefineQuote(qnum, quotestr)
|
||||
return (#quotestr >= con_lang.MAXQUOTELEN)
|
||||
return (#quotestr >= MAXQUOTELEN)
|
||||
end
|
||||
|
||||
function _quote(pli, qnum)
|
||||
|
@ -434,11 +436,84 @@ function _quote(pli, qnum)
|
|||
end
|
||||
|
||||
function _echo(qnum)
|
||||
bcheck.quote_idx(qnum)
|
||||
-- XXX: ugly round-trip
|
||||
print(ffi.string(ffiC.ScriptQuotes[qnum]))
|
||||
local cstr = bcheck.quote_idx(qnum)
|
||||
ffiC.OSD_Printf("%s\n", cstr)
|
||||
end
|
||||
|
||||
function _userquote(qnum)
|
||||
local cstr = bcheck.quote_idx(qnum)
|
||||
-- NOTE: G_AddUserQuote strcpy's the string
|
||||
ffiC.G_AddUserQuote(cstr)
|
||||
end
|
||||
|
||||
local function strlen(cstr)
|
||||
for i=0,math.huge do
|
||||
if (cstr[i]==0) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
assert(false)
|
||||
end
|
||||
|
||||
local function strcpy(dst, src)
|
||||
local i=-1
|
||||
repeat
|
||||
i = i+1
|
||||
dst[i] = src[i]
|
||||
until (src[i]~=0)
|
||||
end
|
||||
|
||||
function _qstrlen(qnum)
|
||||
return strlen(bcheck.quote_idx(qnum))
|
||||
end
|
||||
|
||||
function _qstrcpy(qdst, qsrc)
|
||||
local cstr_dst = bcheck.quote_idx(qdst)
|
||||
local cstr_src = bcheck.quote_idx(qsrc)
|
||||
strcpy(cstr_dst, cstr_src)
|
||||
end
|
||||
|
||||
function _qstrcat(qdst, qsrc)
|
||||
local cstr_dst = bcheck.quote_idx(qdst)
|
||||
local cstr_src = bcheck.quote_idx(qsrc)
|
||||
|
||||
local i, j = strlen(cstr_dst), 0
|
||||
while (i < MAXQUOTELEN-1) do
|
||||
cstr_dst[i] = cstr_src[j]
|
||||
i = i+1
|
||||
j = j+1
|
||||
end
|
||||
cstr_dst[i] = 0
|
||||
end
|
||||
|
||||
function _getkeyname(qdst, gfuncnum, which)
|
||||
local cstr_dst = bcheck.quote_idx(qdst)
|
||||
|
||||
if (gfuncnum >= ffiC.NUMGAMEFUNCTIONS+0ULL) then
|
||||
error("invalid game function number "..gfuncnum, 2)
|
||||
end
|
||||
|
||||
if (which >= 3+0ULL) then
|
||||
error("third argument to getkeyname must be 0, 1 or 2", 2)
|
||||
end
|
||||
|
||||
local cstr_src
|
||||
|
||||
for i = (which==2 and 0 or which), (which==2 and 1 or which) do
|
||||
local scancode = ffiC.ud.config.KeyboardKeys[gfuncnum][i]
|
||||
cstr_src = ffiC.KB_ScanCodeToString(scancode)
|
||||
if (cstr_src[0] ~= 0) then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if (cstr_src[0] ~= 0) then
|
||||
-- All key names are short, no problem strcpy'ing them
|
||||
strcpy(cstr_dst, cstr_src)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- text rendering
|
||||
function _minitext(x, y, qnum, shade, pal)
|
||||
local cstr = bcheck.quote_idx(qnum)
|
||||
|
|
|
@ -525,6 +525,7 @@ int32_t A_Spawn(int32_t j, int32_t pn);
|
|||
void A_AddToDeleteQueue(int32_t i);
|
||||
int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype);
|
||||
void P_DoQuote(int32_t q, DukePlayer_t *p);
|
||||
void G_AddUserQuote(const char *daquote);
|
||||
void G_ClearCameraView(DukePlayer_t *ps);
|
||||
void G_DrawTileGeneric(int32_t x, int32_t y, int32_t zoom, int32_t tilenum,
|
||||
int32_t shade, int32_t orientation, int32_t p);
|
||||
|
@ -533,6 +534,8 @@ void G_GetTimeDate(int32_t *vals);
|
|||
int32_t G_ToggleWallInterpolation(int32_t w, int32_t doset);
|
||||
int32_t G_StartTrack(int32_t level);
|
||||
|
||||
const char *KB_ScanCodeToString(uint8_t scancode);
|
||||
|
||||
int32_t A_CheckAnySoundPlaying(int32_t i);
|
||||
int32_t A_PlaySound(uint32_t num, int32_t i);
|
||||
int32_t S_CheckSoundPlaying(int32_t i, int32_t num);
|
||||
|
|
|
@ -144,6 +144,7 @@ A_Spawn;
|
|||
A_AddToDeleteQueue;
|
||||
A_MoveSprite;
|
||||
P_DoQuote;
|
||||
G_AddUserQuote;
|
||||
G_ClearCameraView;
|
||||
G_DrawTileGeneric;
|
||||
G_InitTimer;
|
||||
|
@ -151,6 +152,8 @@ G_GetTimeDate;
|
|||
G_ToggleWallInterpolation;
|
||||
G_StartTrack;
|
||||
|
||||
KB_ScanCodeToString;
|
||||
|
||||
A_CheckAnySoundPlaying;
|
||||
A_PlaySound;
|
||||
S_CheckSoundPlaying;
|
||||
|
|
|
@ -1751,17 +1751,26 @@ local Cinner = {
|
|||
|
||||
-- quotes
|
||||
qsprintf = sp1 * tok.rvar * sp1 * tok.rvar * (sp1 * tok.rvar)^-32,
|
||||
qgetsysstr = cmd(R,R),
|
||||
qstrcat = cmd(R,R),
|
||||
qstrcpy = cmd(R,R),
|
||||
qstrlen = cmd(R,R),
|
||||
qstrncat = cmd(R,R),
|
||||
qsubstr = cmd(R,R),
|
||||
qgetsysstr = cmd(R,R)
|
||||
/ handle.NYI,
|
||||
qstrcat = cmd(R,R)
|
||||
/ "_con._qstrcat(%1,%2)",
|
||||
qstrcpy = cmd(R,R)
|
||||
/ "_con._qstrcpy(%1,%2)",
|
||||
qstrlen = cmd(W,R)
|
||||
/ "%1=_con._qstrlen(%2)",
|
||||
qstrncat = cmd(R,R)
|
||||
/ handle.NYI,
|
||||
qsubstr = cmd(R,R)
|
||||
/ handle.NYI,
|
||||
quote = cmd(D)
|
||||
/ "_con._quote(_pli,%1)",
|
||||
userquote = cmd(R),
|
||||
getkeyname = cmd(R,R,R),
|
||||
getpname = cmd(R,R),
|
||||
userquote = cmd(R)
|
||||
/ "_con._userquote(%1)",
|
||||
getkeyname = cmd(R,R,R)
|
||||
/ "_con._getkeyname(%1,%2,%3)",
|
||||
getpname = cmd(R,R)
|
||||
/ handle.NYI,
|
||||
|
||||
-- array stuff
|
||||
copy = sp1 * tok.gamearray * arraypat * sp1 * tok.gamearray * arraypat * sp1 * tok.rvar
|
||||
|
@ -2469,8 +2478,10 @@ local Grammar = Pat{
|
|||
+ Var("if_else_bodies"))
|
||||
* (Pat("")/end_if_else_fn),
|
||||
|
||||
while_stmt = Keyw("whilevarvarn") * sp1 * tok.rvar * sp1 * tok.rvar * sp1 * Var("single_stmt")
|
||||
+ Keyw("whilevarn") * sp1 * tok.rvar * sp1 * tok.define/"WHILE_XXX" * sp1 * Var("single_stmt"),
|
||||
while_stmt = Keyw("whilevarvarn") * sp1 * tok.rvar * sp1 * tok.rvar / "while (%1~=%2) do"
|
||||
* sp1 * Var("single_stmt") * lpeg.Cc("end")
|
||||
+ Keyw("whilevarn") * sp1 * tok.rvar * sp1 * tok.define / "while (%1~=%2) do"
|
||||
* sp1 * Var("single_stmt") * lpeg.Cc("end"),
|
||||
|
||||
stmt_common = Keyw("{") * sp1 * "}" -- space separation of commands in CON is for a reason!
|
||||
+ Keyw("{") * sp1 * stmt_list * sp1 * "}"
|
||||
|
|
Loading…
Reference in a new issue