void LoadFurnitureLua(string filePath) { string luaCode = System.IO.File.ReadAllText(filePath); // Instantiate the singleton LuaUtilities.LoadScript(luaCode); }
public static void LoadScriptFromFile(string filePath) { string luaCode = System.IO.File.ReadAllText(filePath); try { LuaUtilities.LoadScript(luaCode); } catch (MoonSharp.Interpreter.SyntaxErrorException e) { Debug.LogError("[" + Path.GetFileName(filePath) + "] LUA Parse error: " + e.DecoratedMessage); } }
/// <summary> /// Loads all TileType definitions in Data\ and Data\Mods /// </summary> public static void LoadTileTypes() { // Load lua code string luaPath = System.IO.Path.Combine(Application.streamingAssetsPath, "LUA"); string luaFilePath = System.IO.Path.Combine(luaPath, "Tile.lua"); string luaCode = System.IO.File.ReadAllText(luaFilePath); LuaUtilities.LoadScript(luaCode); // Load all mod defined lua code foreach (DirectoryInfo mod in WorldController.Instance.modsManager.GetMods()) { foreach (FileInfo file in mod.GetFiles("Tiles.lua")) { Debug.ULogChannel("TileType", "Loading mod " + mod.Name + " TileType definitions!"); luaCode = System.IO.File.ReadAllText(file.FullName); LuaUtilities.LoadScript(luaCode); } } // Load TileType xml definitions string dataPath = System.IO.Path.Combine(Application.streamingAssetsPath, "Data"); string xmlPath = System.IO.Path.Combine(dataPath, "Tiles.xml"); string xmlText = System.IO.File.ReadAllText(xmlPath); readTileTypesFromXml(xmlText); // Load all mod defined TileType definitions foreach (DirectoryInfo mod in WorldController.Instance.modsManager.GetMods()) { foreach (FileInfo file in mod.GetFiles("Tiles.xml")) { Debug.ULogChannel("TileType", "Loading mod " + mod.Name + " TileType definitions!"); xmlText = System.IO.File.ReadAllText(file.FullName); readTileTypesFromXml(xmlText); } } }