From 30c505a16e55c6d616d000c254e3ae097aa0de3c Mon Sep 17 00:00:00 2001 From: Sokomine Date: Mon, 30 Jul 2018 23:25:58 +0200 Subject: [PATCH] better support for citybuilder --- analyze_file.lua | 5 +++++ build_chest.lua | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/analyze_file.lua b/analyze_file.lua index 9902ef6..4c6e19d 100644 --- a/analyze_file.lua +++ b/analyze_file.lua @@ -86,9 +86,14 @@ handle_schematics.analyze_file = function( file_name, origin_offset, store_as_mt -- print error message only if all import methods failed if( not( res )) then print('[handle_schematics] ERROR: Failed to import file \"'..tostring( file_name )..'\"[.mts|.we|.wem|.schematic]'); + return; -- convert to .mts for later usage elseif( store_as_mts ) then handle_schematics.store_mts_file( store_as_mts, res ); + res = handle_schematics.analyze_mts_file( file_name ); + if( not( res )) then + return; + end end -- .we and .schematic do not provide on_construct/after_palce_node diff --git a/build_chest.lua b/build_chest.lua index 6c15c2e..e24122f 100644 --- a/build_chest.lua +++ b/build_chest.lua @@ -57,12 +57,19 @@ build_chest.end_pos_list = {}; -build_chest.read_building = function( building_name ) +build_chest.read_building = function( building_name, building_data ) + if( not( building_data )) then + building_data = {}; + end + if( not( build_chest.building[ building_name ] )) then + build_chest.building[ building_name ] = building_data; + end -- read data - local res = handle_schematics.analyze_file( building_name, nil, nil ); + local res = handle_schematics.analyze_file( building_name, nil, nil, build_chest.building[ building_name ]); if( not( res )) then return; end +--[[ build_chest.building[ building_name ].size = res.size; build_chest.building[ building_name ].nodenames = res.nodenames; build_chest.building[ building_name ].rotated = res.rotated; @@ -73,7 +80,8 @@ build_chest.read_building = function( building_name ) build_chest.building[ building_name ].bed_list = res.bed_list; -- scm_data_cache is not stored as that would take up too much storage space --build_chest.building[ building_name ].scm_data_cache = res.scm_data_cache; - +--]] + build_chest.building[ building_name ] = res; -- create a statistic about how often each node occours build_chest.building[ building_name ].statistic = handle_schematics.count_nodes( res );