summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ddb1de6)
raw | patch | inline | side by side (parent: ddb1de6)
author | FGSFDSFGS <derp.primus@gmail.com> | |
Wed, 29 Jun 2016 15:01:38 +0000 (18:01 +0300) | ||
committer | FGSFDSFGS <derp.primus@gmail.com> | |
Wed, 29 Jun 2016 15:02:16 +0000 (18:02 +0300) |
diff --git a/build.bat b/build.bat
index ff46ff553647afd27557beefc149b108afb400b8..96699ca5083e1eb303a4680663a0d0529b8b54bc 100644 (file)
--- a/build.bat
+++ b/build.bat
@echo off
cd "./src/game"
-fpc -dUSE_FMOD -MDELPHI -O2 -Fi../lib/vampimg -Fi../lib/vampimg/JpegLib -Fi../lib/vampimg/ZLib -Fu../lib/vampimg -Fu../lib/vampimg/JpegLib -Fu../lib/vampimg/ZLib -FE../../bin -FU../../tmp Doom2DF.dpr
+fpc -dUSE_FMOD -MDELPHI -O2 -Fi../lib/lua -Fi../lib/vampimg -Fi../lib/vampimg/JpegLib -Fi../lib/vampimg/ZLib -Fu../lib/vampimg -Fu../lib/vampimg/JpegLib -Fu../lib/vampimg/ZLib -FE../../bin -FU../../tmp Doom2DF.dpr
cd "../.."
pause
diff --git a/build_headless.bat b/build_headless.bat
index d5c317fbb8ad4b943afa54e609d539cb3e0e4fc5..1a029bc7882488496277b1232f5e9941644c8fd3 100644 (file)
--- a/build_headless.bat
+++ b/build_headless.bat
@echo off
cd "./src/game"
-fpc -dUSE_FMOD -dHEADLESS -MDELPHI -O2 -Fi../lib/vampimg -Fi../lib/vampimg/JpegLib -Fi../lib/vampimg/ZLib -Fu../lib/vampimg -Fu../lib/vampimg/JpegLib -Fu../lib/vampimg/ZLib -FE../../bin -FU../../tmp -oDoom2DF_H.exe Doom2DF.dpr
+fpc -dUSE_FMOD -dHEADLESS -MDELPHI -O2 -Fi../lib/lua -Fi../lib/vampimg -Fi../lib/vampimg/JpegLib -Fi../lib/vampimg/ZLib -Fu../lib/vampimg -Fu../lib/vampimg/JpegLib -Fu../lib/vampimg/ZLib -FE../../bin -FU../../tmp -oDoom2DF_H.exe Doom2DF.dpr
cd ".."
pause
\ No newline at end of file
diff --git a/src/game/Doom2DF.dpr b/src/game/Doom2DF.dpr
index 3fbd82967e4ab008d93e2f75585f3aad9b4ddc49..17f17b77fb2922dff852b8e48a958e8a61ca4ecf 100644 (file)
--- a/src/game/Doom2DF.dpr
+++ b/src/game/Doom2DF.dpr
g_language in 'g_language.pas',
ImagingTypes,
Imaging,
- ImagingUtility;
+ ImagingUtility,
+ lua in '../lib/lua/lua.pas',
+ lualib in '../lib/lua/lualib.pas',
+ lauxlib in '../lib/lua/lauxlib.pas';
{$IFDEF WINDOWS}
{$R *.res}
diff --git a/src/game/g_scripts.pas b/src/game/g_scripts.pas
index b3011579f0c93c159dbb56a9cbd200bc621c1c35..d1113c9e97eb9b7cc51b99dae2f46ff6c6d707a0 100644 (file)
--- a/src/game/g_scripts.pas
+++ b/src/game/g_scripts.pas
const
// reset levels
- RESET_ALL = 0;
- RESET_SRV = 1;
- RESET_WAD = 2;
- RESET_MAP = 3;
+ RESET_SRV_BIT = 4;
+ RESET_WAD_BIT = 2;
+ RESET_MAP_BIT = 1;
+ RESET_SRV = RESET_SRV_BIT or RESET_WAD_BIT or RESET_MAP_BIT;
+ RESET_WAD = RESET_WAD_BIT or RESET_MAP_BIT;
+ RESET_MAP = RESET_MAP_BIT;
+ RESET_ALL = 255;
type
PScriptContext = Plua_State;
gScriptInit: Boolean = False;
function g_Scripts_Init(): Boolean;
-procedure g_Scripts_Reset(What: Integer);
+procedure g_Scripts_Reset(What: Byte);
function g_Scripts_ProcExec(PName: string; const Args: array of const; Namespace: string = ''): Integer;
function g_Scripts_ProcExists(PName: string): Boolean;
function g_Scripts_ProcInstall(PName: string; PPtr: PScriptProc): Boolean;
SysUtils, g_console, g_scriptprocs;
type
- POpenFunc = function(L: Plua_State): LongBool; cdecl;
TLuaReg = record
name: PAnsiChar;
- func: POpenFunc;
+ func: lua_CFunction;
end;
const
- LUA_LIBS: array [0..3] of TLuaReg = (
+ LUA_LIBS: array [0..6] of TLuaReg = (
(name: ''; func: luaopen_base),
+ (name: LUA_LOADLIBNAME; func: luaopen_package),
(name: LUA_TABLIBNAME; func: luaopen_table),
- (name: LUA_STRLINAME; func: luaopen_string), // STRLINAME is actually a typo in fpc's lua module
- (name: LUA_MATHLIBNAME; func: luaopen_math)
+ (name: LUA_STRLIBNAME; func: luaopen_string),
+ (name: LUA_MATHLIBNAME; func: luaopen_math),
+ (name: LUA_OSLIBNAME; func: luaopen_os), // TODO: something to restrict these two
+ (name: LUA_IOLIBNAME; func: luaopen_io)
);
function LuaInstallGameFuncs(): Boolean;
// don't open all the libs
for i := 0 to High(LUA_LIBS) do
begin
- //lua_pushcfunction(gScriptCtx, LUA_LIBS[i].func);
+ lua_pushcfunction(gScriptCtx, LUA_LIBS[i].func);
lua_pushstring(gScriptCtx, LUA_LIBS[i].name);
- //lua_call(gScriptCtx, 1, 0);
- LUA_LIBS[i].func(gScriptCtx);
+ lua_call(gScriptCtx, 1, 0);
end;
// create a table for game-related functions
end;
// TODO: maybe actually put some fields into these?
-procedure g_Scripts_Reset(What: Integer);
+procedure g_Scripts_Reset(What: Byte);
begin
if not gScriptInit then Exit;
- if What in [RESET_ALL, RESET_SRV] then
+ if LongBool(What and RESET_SRV_BIT) then
begin
lua_newtable(gScriptCtx);
lua_setglobal(gScriptCtx, 'srv');
end;
- if What in [RESET_ALL, RESET_WAD] then
+ if LongBool(What and RESET_WAD_BIT) then
begin
lua_newtable(gScriptCtx);
lua_setglobal(gScriptCtx, 'wad');
end;
- if What in [RESET_ALL, RESET_MAP] then
+ if LongBool(What and RESET_MAP_BIT) then
begin
lua_newtable(gScriptCtx);
lua_setglobal(gScriptCtx, 'map');
+
+ // disable io and os modules on any kind of reset
+ lua_pushnil(gScriptCtx);
+ lua_pushnil(gScriptCtx);
+ lua_setglobal(gScriptCtx, 'os');
+ lua_setglobal(gScriptCtx, 'io');
end;
end;
index 6498b13e315c3a608f1bbfd4bebf7c929728b3a7..2ff21708160b0e1e063545a508f405f87453be4a 100644 (file)
--- a/src/game/g_triggers.pas
+++ b/src/game/g_triggers.pas
TRIGGER_SCRIPT:
begin
g_Scripts_ProcExec(Data.SCRProc, [ID, ActivateUID, actType, Data.SCRArg], 'map');
- TimeOut := 1;
+ TimeOut := 0;
Result := True;
end;
end;