Eluna tweak load order. You can now freely use require() on any script. all lua files are loaded alphabetically (path is taken into account) and the extensions folder is loaded first always

This commit is contained in:
Rochet2
2014-07-02 00:44:54 +03:00
parent 6b01113a70
commit 637ee5fff9
3 changed files with 76 additions and 26 deletions

View File

@@ -350,7 +350,14 @@ private:
Eluna& operator=(const Eluna&);
public:
typedef std::set<std::string> ScriptPaths;
struct LuaScript
{
std::string fileext;
std::string filename;
std::string filepath;
std::string modulepath;
};
typedef std::list<LuaScript> ScriptList;
static Eluna* GEluna;
static bool reload;
@@ -378,18 +385,20 @@ public:
Eluna();
~Eluna();
static ScriptPaths scripts;
static ScriptList lua_scripts;
static ScriptList lua_extensions;
static std::string lua_folderpath;
static void Initialize();
static void Uninitialize();
// Use Eluna::reload = true; instead.
// This will be called on next update
static void ReloadEluna();
void static GetScripts(std::string path, ScriptPaths& scripts);
static void GetScripts(std::string path, ScriptList& scripts);
static void report(lua_State*);
static void ExecuteCall(lua_State* L, int params, int res);
void Register(uint8 reg, uint32 id, uint32 evt, int func);
void RunScripts(ScriptPaths& scripts);
void RunScripts();
static void RemoveRef(const void* obj);
// Pushes