using MoonSharp.Interpreter; var script = new Script(CoreModules.Preset_SoftSandbox); script.Options.DebugPrint = s => Console.WriteLine(s); script.DoFile("script.lua"); // Lua script file var searchPath = @"C:\Projects\LuaScripts"; script.DoString($"package.path = package.path .. ';{searchPath}/?.lua'"); // Adding search path
using MoonSharp.Interpreter; var script = new Script(CoreModules.Preset_SoftSandbox); script.Options.DebugPrint = s => Console.WriteLine(s); script.DoFile("script.lua"); // Lua script file var searchPath1 = @"C:\Projects\LuaScripts\module1"; var searchPath2 = @"C:\Projects\LuaScripts\module2"; script.DoString($"package.path = package.path .. ';{searchPath1}/?.lua;{searchPath2}/?.lua'"); // Adding multiple search pathsBrief Description: The first example shows how to add a single search path to the package search path list using LuaState.AddSearchPath(). The second example demonstrates how to add multiple search paths to the list. Package library: The package library in Lua provides a set of functions for loading and managing modules written in Lua or other languages. It allows users to load modules from different paths and in different formats. The LuaState.AddSearchPath() method allows users to add new search paths to the package library's search path list, where the Lua interpreter searches for required packages or files.