diff --git a/src/g_game.c b/src/g_game.c
index 352a6084ad50379812cdcd9798cb88e509fd428b..4fce4db86faeb6841c5003cb520f0839a5a00015 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -45,6 +45,7 @@
 #include "dehacked.h" // get_number (for ghost thok)
 #include "lua_script.h"	// LUA_ArchiveDemo and LUA_UnArchiveDemo
 #include "lua_hook.h"
+#include "lua_libs.h"	// gL (Lua state)
 #include "b_bot.h"
 #include "m_cond.h" // condition sets
 #include "md5.h" // demo checksums
@@ -7538,7 +7539,12 @@ void G_DoPlayDemo(char *defdemoname)
 // so this is where we are to read our lua variables (if possible!)
 #ifdef HAVE_BLUA
 	if (demoflags & DF_LUAVARS)	// again, used for compability, lua shit will be saved to replays regardless of if it's even been loaded
+	{
+		if (!gL)	// No Lua state! ...I guess we'll just start one...
+			LUA_ClearState();
+
 		LUA_UnArchiveDemo();
+	}
 #endif
 
 	splitscreen = 0;
diff --git a/src/lua_script.c b/src/lua_script.c
index aa6a5652dfc60c16d8d6d76c12f386d4c94ebe51..6961f2e978e01e6af5b064e99af56b5cb649f1a6 100644
--- a/src/lua_script.c
+++ b/src/lua_script.c
@@ -112,7 +112,7 @@ static int noglobals(lua_State *L)
 
 // Clear and create a new Lua state, laddo!
 // There's SCRIPTIN to be had!
-static void LUA_ClearState(void)
+void LUA_ClearState(void)
 {
 	lua_State *L;
 	int i;
diff --git a/src/lua_script.h b/src/lua_script.h
index dffd39c466f7364901c711a0d858e5eb376c4da1..b3ca16bc003ae2099b4f03c401d36b3683d40510 100644
--- a/src/lua_script.h
+++ b/src/lua_script.h
@@ -38,6 +38,8 @@
 void LUA_ClearExtVars(void);
 #endif
 
+void LUA_ClearState(void);
+
 void LUA_LoadLump(UINT16 wad, UINT16 lump);
 #ifdef LUA_ALLOW_BYTECODE
 void LUA_DumpFile(const char *filename);