mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 18:59:47 +00:00
Refactored the Lua module loading & standard libraries from the plugin base to the factory
This commit is contained in:
parent
f885db8f1b
commit
ff17b6749d
@ -69,20 +69,6 @@ public abstract class PluginBase : IPluginMetadata
|
||||
this.state = state;
|
||||
this.Type = type;
|
||||
|
||||
// For security reasons, we don't want to allow the plugin to load modules:
|
||||
this.state.ModuleLoader = new NoModuleLoader();
|
||||
|
||||
// Add some useful libraries:
|
||||
this.state.OpenModuleLibrary();
|
||||
this.state.OpenStringLibrary();
|
||||
this.state.OpenTableLibrary();
|
||||
this.state.OpenMathLibrary();
|
||||
this.state.OpenBitwiseLibrary();
|
||||
this.state.OpenCoroutineLibrary();
|
||||
|
||||
// Add the module loader so that the plugin can load other Lua modules:
|
||||
this.state.ModuleLoader = new PluginLoader(path);
|
||||
|
||||
var issues = new List<string>();
|
||||
if(!string.IsNullOrWhiteSpace(parseError))
|
||||
issues.Add(parseError);
|
||||
|
@ -3,6 +3,7 @@ using System.Text;
|
||||
using AIStudio.Settings;
|
||||
|
||||
using Lua;
|
||||
using Lua.Standard;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem;
|
||||
|
||||
@ -95,6 +96,17 @@ public static partial class PluginFactory
|
||||
|
||||
var state = LuaState.Create();
|
||||
|
||||
// Add the module loader so that the plugin can load other Lua modules:
|
||||
state.ModuleLoader = new PluginLoader(pluginPath);
|
||||
|
||||
// Add some useful libraries:
|
||||
state.OpenModuleLibrary();
|
||||
state.OpenStringLibrary();
|
||||
state.OpenTableLibrary();
|
||||
state.OpenMathLibrary();
|
||||
state.OpenBitwiseLibrary();
|
||||
state.OpenCoroutineLibrary();
|
||||
|
||||
try
|
||||
{
|
||||
await state.DoStringAsync(code, cancellationToken: cancellationToken);
|
||||
|
Loading…
Reference in New Issue
Block a user