summary refs log tree commit diff stats
path: root/plugins
diff options
context:
space:
mode:
authorculb <the01culb@gmail.com>2017-02-27 18:58:22 -0500
committerPatrick Griffis <tingping@tingping.se>2017-04-28 07:55:14 -0400
commitfc2fe7fd28c5cc3748a95f619c048cfe0a30ab15 (patch)
tree060ac829813c66c1d15cfdec79a7c1d4cc17fb37 /plugins
parent5d72755027ddf4e2e2715ae505c3437f9617a5b4 (diff)
lua: Prevent loading a script if it's already loaded
Closes #1959
Diffstat (limited to 'plugins')
-rw-r--r--plugins/lua/lua.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/plugins/lua/lua.c b/plugins/lua/lua.c
index d284d01a..941342bb 100644
--- a/plugins/lua/lua.c
+++ b/plugins/lua/lua.c
@@ -1361,16 +1361,6 @@ static script_info *create_script(char const *file)
 	return info;
 }
 
-static void load_script(char const *file)
-{
-	script_info *info = create_script(file);
-	if(info)
-	{
-		g_ptr_array_add(scripts, info);
-		check_deferred(info);
-	}
-}
-
 static script_info *get_script_by_file(char const *filename)
 {
 	char const *expanded = expand_path(filename);
@@ -1387,6 +1377,26 @@ static script_info *get_script_by_file(char const *filename)
 	return NULL;
 }
 
+static int load_script(char const *file)
+{
+	script_info *info = get_script_by_file(file);
+
+	if (info != NULL)
+	{
+		hexchat_print(ph, "Lua script is already loaded");
+		return 0;
+	}
+
+	info = create_script(file);
+	if (info)
+	{
+		g_ptr_array_add(scripts, info);
+		check_deferred(info);
+	}
+
+	return 1;
+}
+
 static int unload_script(char const *filename)
 {
 	script_info *script = get_script_by_file(filename);