From 35e786c2b4632f92518c8881db650ba63beecd5c Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sun, 19 May 2019 15:25:03 +0500 Subject: Implemented lua's "require" for AM --- src/AssetManager.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/AssetManager.cpp') diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp index eb3186a..be69dd0 100644 --- a/src/AssetManager.cpp +++ b/src/AssetManager.cpp @@ -110,6 +110,9 @@ void LoadScripts() { if (child->name == "scripts") { for (auto &script : child->childs) { + if (script->name != "init") + continue; + AssetScript *asset = dynamic_cast(script->asset.get()); if (!asset) { LOG(ERROR) << "Unrecognised script file /" << it->name; @@ -118,9 +121,11 @@ void LoadScripts() { try { PluginSystem::Execute(asset->code, true); } - catch (std::exception& e) { + catch (std::exception & e) { LOG(ERROR) << "Failed loading script '" << script->name << "' in '" << it->name << "'"; } + + break; } } } @@ -171,7 +176,7 @@ void ParseAsset(AssetTreeNode &node) { return; } - if (node.name == "init") { + if (node.parent->name == "scripts") { ParseAssetScript(node); return; } -- cgit v1.2.3