11--- Defold Text Proto format encoder/decoder to lua table
22
33local config = require (" druid.editor_scripts.defold_parser.system.config" )
4- local system = require (" druid.editor_scripts.defold_parser.system.system " )
4+ local parser_internal = require (" druid.editor_scripts.defold_parser.system.parser_internal " )
55
66local M = {}
77
@@ -17,7 +17,7 @@ function M.decode_defold_object(text)
1717
1818 -- For each line in the text, we go through the following steps:
1919 for raw_line in text :gmatch (" [^\r\n ]+" ) do
20- system .parse_line (raw_line , stack )
20+ parser_internal .parse_line (raw_line , stack )
2121 end
2222
2323 return root
@@ -39,8 +39,8 @@ function M.encode_defold_object(obj, spaces, data_level, extension)
3939 end
4040
4141 table.sort (keys , function (a , b )
42- local index_a = system .contains (key_order , a ) or 0
43- local index_b = system .contains (key_order , b ) or 0
42+ local index_a = parser_internal .contains (key_order , a ) or 0
43+ local index_b = parser_internal .contains (key_order , b ) or 0
4444 return index_a < index_b
4545 end )
4646
@@ -63,7 +63,7 @@ function M.encode_defold_object(obj, spaces, data_level, extension)
6363 result = result .. tabString .. key .. ' : "' .. encodedChild .. ' "\n '
6464 elseif item_type == " number" or item_type == " boolean" then
6565 local is_contains_dot = string.find (key , " %." )
66- if item_type == " number" and (system .contains (config .with_dot_params , key ) and not is_contains_dot ) then
66+ if item_type == " number" and (parser_internal .contains (config .with_dot_params , key ) and not is_contains_dot ) then
6767 result = result .. tabString .. key .. ' : ' .. string.format (" %.1f" , array_item ) .. ' \n '
6868 else
6969 result = result .. tabString .. key .. ' : ' .. tostring (array_item ) .. ' \n '
@@ -94,7 +94,7 @@ function M.encode_defold_object(obj, spaces, data_level, extension)
9494 -- Handle scalar values (string, number, boolean)
9595 if value_type == " number" or value_type == " boolean" then
9696 local is_contains_dot = string.find (key , " %." )
97- if value_type == " number" and (system .contains (config .with_dot_params , key ) and not is_contains_dot ) then
97+ if value_type == " number" and (parser_internal .contains (config .with_dot_params , key ) and not is_contains_dot ) then
9898 result = result .. tabString .. key .. ' : ' .. string.format (" %.1f" , value ) .. ' \n '
9999 else
100100 result = result .. tabString .. key .. ' : ' .. tostring (value ) .. ' \n '
125125--- @param file_path string
126126--- @return table | nil , string | nil
127127function M .load_from_file (file_path )
128- local content , reason = system .read_file (file_path )
128+ local content , reason = parser_internal .read_file (file_path )
129129 if not content then
130130 return nil , reason
131131 end
@@ -146,7 +146,7 @@ function M.save_to_file(file_path, lua_table)
146146
147147 local encoded_object = M .encode_defold_object (lua_table , nil , nil , defold_format_name )
148148
149- return system .write_file (file_path , encoded_object )
149+ return parser_internal .write_file (file_path , encoded_object )
150150end
151151
152152
0 commit comments