Skip to content

Commit

Permalink
fixing node table name issue,
Browse files Browse the repository at this point in the history
removing any invalide character from model name so that it will give valide lua table name
  • Loading branch information
jharajeev55 committed Oct 3, 2024
1 parent 4120e4c commit 4a4986a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Json_parser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
//using static jsonToLuaParser.Utility;
using static jsonToLuaParser.Utility;
namespace jsonToLuaParser
Expand Down Expand Up @@ -192,7 +193,8 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path)
}

var nodeTable_str = @"{" + string.Join(",\n ", nodeTable) + "\n}";
var nodeTableDetails = $"---@meta\n\n---@class model{file_name}\nmodel{file_name} = {nodeTable_str}" +
var node_class_name = Regex.Replace(file_name, @"[^a-zA-Z0-9_]", "");
var nodeTableDetails = $"---@meta\n\n---@class model{node_class_name}\nmodel{node_class_name} = {nodeTable_str}" +
$"\n--#region node details\n--#endregion";

Directory.CreateDirectory(Path.Combine(base_lib_dir, model));
Expand Down

0 comments on commit 4a4986a

Please sign in to comment.