Use lua convention for main file in package: init.lua

This commit is contained in:
Mm2PL 2023-02-04 02:23:36 +01:00
parent 4030439766
commit bb412340db
No known key found for this signature in database
GPG key ID: 94AC9B80EFA15ED9
2 changed files with 8 additions and 8 deletions

View file

@ -13,11 +13,11 @@ Each plugin should have its own directory.
``` ```
Chatterino dir/ Chatterino dir/
└── plugin_name/ └── plugin_name/
├── index.lua ├── init.lua
└── info.json └── info.json
``` ```
`index.lua` will be the file loaded when the plugin is enabled. You may load other files using `loadfile` Lua global function. `init.lua` will be the file loaded when the plugin is enabled. You may load other files using `loadfile` Lua global function.
`info.json` contains metadata about the plugin, like its name, description, `info.json` contains metadata about the plugin, like its name, description,
authors, homepage link, tags, version, license name. The version field **must** authors, homepage link, tags, version, license name. The version field **must**

View file

@ -4,7 +4,7 @@
# include "Application.hpp" # include "Application.hpp"
# include "common/QLogging.hpp" # include "common/QLogging.hpp"
# include "controllers/commands/CommandContext.hpp" # include "controllers/commands/CommandContext.hpp"
# include "controllers/plugins/ApiChatterino.hpp" # include "controllers/plugins/LuaApi.hpp"
# include "controllers/plugins/LuaUtilities.hpp" # include "controllers/plugins/LuaUtilities.hpp"
# include "messages/MessageBuilder.hpp" # include "messages/MessageBuilder.hpp"
# include "providers/twitch/TwitchIrcServer.hpp" # include "providers/twitch/TwitchIrcServer.hpp"
@ -72,17 +72,17 @@ void PluginController::actuallyInitialize()
} }
bool PluginController::tryLoadFromDir(const QDir &pluginDir) bool PluginController::tryLoadFromDir(const QDir &pluginDir)
{ {
// look for index.lua // look for init.lua
auto index = QFileInfo(pluginDir.filePath("index.lua")); auto index = QFileInfo(pluginDir.filePath("init.lua"));
qCDebug(chatterinoLua) << "looking for index.lua and info.json in" qCDebug(chatterinoLua) << "looking for init.lua and info.json in"
<< pluginDir.path(); << pluginDir.path();
if (!index.exists()) if (!index.exists())
{ {
qCDebug(chatterinoLua) qCDebug(chatterinoLua)
<< "Missing index.lua in plugin directory" << pluginDir; << "Missing init.lua in plugin directory" << pluginDir;
return false; return false;
} }
qCDebug(chatterinoLua) << "found index.lua, now looking for info.json!"; qCDebug(chatterinoLua) << "found init.lua, now looking for info.json!";
auto infojson = QFileInfo(pluginDir.filePath("info.json")); auto infojson = QFileInfo(pluginDir.filePath("info.json"));
if (!infojson.exists()) if (!infojson.exists())
{ {