private void execOrderFileWriteNewStyle(String targetFile, Dictionary<String, Double> config, LuaTable tableData) { String tableStr = "{"; tableStr += Environment.NewLine; tableStr += "data = "; tableStr += (tableData.GetValue("data") as LuaTable).MyToString(); tableStr += ","; tableStr += Environment.NewLine; tableStr += "order = "; tableStr += generateOrderTable(config); tableStr += Environment.NewLine; tableStr += "}"; this.saveOrderData(targetFile, tableStr); }
private static Dictionary<string, Double> luaOrderTable2DictionaryDouble(LuaTable lTable) { Dictionary<string, Double> ht = new Dictionary<string, Double>(); //probably any mod can do its custom format for the order config file //but the standard seems to be to return two tables ("order" and "data"); //CA uses a dedicated order file returning the order table directly (like in older spring) LuaTable orderTab = (LuaTable)lTable.GetValue("order"); LuaTable dataTab = (LuaTable)lTable.GetValue("data"); if (orderTab != null && dataTab != null) { //we have standard format IDictionaryEnumerator ienum = (IDictionaryEnumerator)orderTab.GetEnumerator(); while (ienum.MoveNext()) { ht.Add((String)ienum.Key, (Double)ienum.Value); } } else { //we have CA-format: dedicated order file IDictionaryEnumerator ienum = (IDictionaryEnumerator)lTable.GetEnumerator(); while (ienum.MoveNext()) { ht.Add((String)ienum.Key, (Double)ienum.Value); } } return ht; }