From ce452111b9ed5ee5ebc8c55d6abb44262f3f759d Mon Sep 17 00:00:00 2001
From: Pixel <pixel@nobis-crew.org>
Date: Mon, 9 Nov 2009 08:41:06 +0100
Subject: Actually running this new script.

---
 lua-interface-light.lua | 23 ++++++++++++++++++++---
 src/lua-interface.cpp   |  9 +++++++++
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/lua-interface-light.lua b/lua-interface-light.lua
index f4a019d..0aaa762 100644
--- a/lua-interface-light.lua
+++ b/lua-interface-light.lua
@@ -38,7 +38,13 @@ local error_bad_lua_locale = {
     ["frFR"] = "archive_main.lua ne contient pas de fonction archive_main",
 }
 
+local commandline_locale = {
+    ["default"] = "Command line",
+    ["frFR"] = "Ligne de commande",
+}
+
 local okay = false
+local commandline = false
 local system_locale
 
 local input_file_text
@@ -89,6 +95,11 @@ local function generate_dlg()
     function quit_btn:action()
         return iup.CLOSE
     end
+    local commandline_btn = iup.button { title = commandline_locale[system_locale] }
+    function commandline_btn:action()
+	commandline = true
+	return iup.CLOSE
+    end
     
     return iup.dialog {
         iup.vbox {
@@ -110,7 +121,12 @@ local function generate_dlg()
                 quit_btn,
                 
                 normalizesize = "Horizontal",
-            }
+            },
+            iup.fill { size = "x2" },
+            iup.hbox {
+        	iup.fill{},
+        	commandline_btn,
+            },
         },
         
         resize = "No",
@@ -132,7 +148,8 @@ function lua_interface_light_main()
     iup.MainLoop()
     dlg:hide()
     
-    if not okay then return end
+    if commandline then return true end
+    if not okay then return false end
     
     if not pcall(Archive(input_file_text.value)) then
         error(error_not_archive_locale[system_locale])
@@ -144,5 +161,5 @@ function lua_interface_light_main()
         error(error_bad_lua_locale[system_locale])
     end
 
-    archive_main()
+    return archive_main()
 end
diff --git a/src/lua-interface.cpp b/src/lua-interface.cpp
index 5b9ad5e..1cf320d 100644
--- a/src/lua-interface.cpp
+++ b/src/lua-interface.cpp
@@ -979,6 +979,15 @@ virtual int startup() throw (GeneralException) {
 	
 	try {
     	    L->load(&built);
+    	    L->push("lua_interface_light_main");
+    	    L->gettable("LUA_GLOBALSINDEX");
+    	    L->call(0, 1);
+    	    interactive = L->toboolean();
+    	    L->pop();
+    	    if (interactive) {
+		Lualua_interface::pushstatics(L);
+	        autoload_exports(L);
+    	    }
 	}
         catch (GeneralException e) {
     	    printm(M_WARNING, "There was an error loading built-in lua-interface-light.lua: %s\n", e.GetMsg());
-- 
cgit v1.2.3