Lunatic translator: handle -mx.

git-svn-id: https://svn.eduke32.com/eduke32@3388 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-01-13 16:40:07 +00:00
parent 222e92ef37
commit 56ef10c893
4 changed files with 32 additions and 11 deletions

View file

@ -494,6 +494,9 @@ int32_t kfilelength(int32_t handle);
void kclose(int32_t handle);
int32_t kread(int32_t handle, void *buffer, int32_t leng);
char **g_scriptModules;
int32_t g_scriptModulesNum;
const char *G_ConFile(void);
void G_DoGameStartup(const int32_t *params);
int32_t C_DefineSound(int32_t sndidx, const char *fn, int32_t args[5]);
@ -1139,7 +1142,17 @@ do
read_into_string = readintostr -- for lunacon
local lunacon = require("lunacon")
local confn = ffi.string(ffiC.G_ConFile())
local confn = { ffi.string(ffiC.G_ConFile()) }
local nummods = ffiC.g_scriptModulesNum
if (nummods > 0) then
assert(ffiC.g_scriptModules ~= nil)
for i=1,nummods do
confn[i+1] = ffi.string(ffiC.g_scriptModules[i-1])
end
end
concode = lunacon.compile(confn)
end

View file

@ -63,6 +63,9 @@ kfilelength;
kclose;
kread;
g_scriptModules;
g_scriptModulesNum;
G_ConFile;
G_DoGameStartup;
C_DefineSound;

View file

@ -13,6 +13,7 @@ local table = require("table")
local arg = arg
local assert = assert
local ipairs = ipairs
local pairs = pairs
local pcall = pcall
local print = print
@ -1930,15 +1931,19 @@ if (string.dump) then
end
else
-- running from EDuke32
function compile(filename)
function compile(filenames)
-- TODO: pathsearchmode=1 set in G_CompileScripts
reset_all()
local ok, msg = pcall(do_include_file, "", filename)
if (not ok) then
print_on_failure(msg)
return nil
else
return get_code_string(g_curcode)
for _, fname in ipairs(filenames) do
local ok, msg = pcall(do_include_file, "", fname)
if (not ok) then
print_on_failure(msg)
return nil
end
end
return get_code_string(g_curcode)
end
end

View file

@ -4,19 +4,19 @@ definequote 127 RAN TEST STATE
state teststate1
return
userquote 127
quote 127
ends
onevent EVENT_EGS
ifactor HEAVYHBOMB
{
state teststate1 // after teststate1's return, return from EVENT_EGS!
userquote 126
quote 126
}
endevent
onevent EVENT_FIRE
// the concrete actor is irrelevant, only placeholder
spawn HEAVYHBOMB // --> EVENT_EGS
userquote 125
quote 125
endevent